View Single Post
  #10  
Old January 20th 07, 05:47 AM posted to rec.games.chess.computer
Mr. Question
external usenet poster
 
Posts: 16
Default efficient in_check routine

"Loomis Philanthrope" wrote in message
...

My move generator doesn't check whether it generates legal moves. But my
make_move function will return false for an illegal move (so that I can


Some people do the valid castling incheck stuff there, but I don't think
many do.

remove it from the list). I think this is necessary for me. I tried
various things allowing illegal moves but making them evaluate as very
poor, but nothing quite worked right. I don't like that there is the
possibility of illegal moves, inevitably, my engine will try to make one
;-).


I can understand that feeling. I've written a few chess programs over the
years and I often included a few extra checking things just to make sure my
program wouldn't do something stupid.

Basically though, all the search routine has to do is:

1) see if the king is being captured. If it is, then immediately return an
'invalid move' score to the previous level. This can be done either in
MakeMove() or the search. Where ever convenient.

2) If the search has returned an 'illegal move' score, then you know that
the move you just tried was illegal.

3) If the best score ends up being 'illegal move' (meaning there were no
legal moves, else the score would be something else) then you know you are
either in stalemate or checkmate. Then you can do InCheck().

There are a few other complications, of course, depending on whether you
generate all the moves or just some of them, but the key is that capturing
the king will result in an immediately returned absolute worst possible
score.


Still, there are lots of ways of doing a chess program. Whatever makes you
happy is all that really counts.





----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Ads
 

Loans - Loans - Home Insurance - Dan brown - Home Loan