Author: Bruce Moreland
Date: 10:17:24 11/26/99
Go up one level in this thread
On November 25, 1999 at 08:09:49, Jari Huikari wrote: >On November 24, 1999 at 16:54:36, Dan Newman wrote: > >>The first chess program I wrote (about 4 years ago) generated only legal >>moves. Initially 80% of the cpu time was taken by the in-check detection >>code. > >1. When in-check not used and illegal move tried: >Program sees that king will be captured, and king-capture gives penalty >of 10000 points? Or what? You have to be a little careful that you can still detect mates and stalemates. For instance, if your mate/stalemate detection is something like: cMoves = CMoveGen(); if (!cMoves) return (FInCheck()) ? MATE : DRAW; Then you'll have to re-work this, because "cMoves" will be non-zero because there are illegal moves in your list, and you have to figure this out later on in such a way that everything still works. There are a couple of ways to deal with these illegal moves in the search. When you do a move generation, you can detect if you are capturing a king, and if so, the position must be illegal, so you can return a special value from your move generator, which will cause you to return a special value from "search", which will cause you to flag the position you just searched as illegal, and act accordingly. Or you can simply execute the move on the board, then do your in-check test before you recurse into search. Some people will tell you that one or the other is faster, but the fact is that it depends upon numerous features that can change from program to program. >2. Is in-check necessarily so slow? How do you detect it? I do this >still very crudely, but I think there is many helping rules, that one >can conclude that certain moves can't be illegal. You are right, you can do tricks. It is an important function and you'll spend a lot of time on it. bruce
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.