Author: Marek Mahdal
Date: 01:38:12 05/02/02
Go up one level in this thread
On April 30, 2002 at 03:55:24, Marek Mahdal wrote: >On April 28, 2002 at 18:12:56, Russell Reagan wrote: > >>If it must be done in a scripting language, then it can certainly be done. It >>will be a little slower, but still not a problem. You need to write a >>pseudo-legal move generator (one that will generate moves for pieces that are >>pinned and can't move and one that will generate moves that move the king into >>check), and then you need to write a function to determine if a square is >>attacked. Use the function that determines if a square is attacked by the >>opposing side to write a function that tells if the king is in check (just see >>if the square the king is on is attacked). Then you need a make move and an undo >>move function, then you need to try all of the moves, make them, see if the king >>is in check, if the king is in check, it's an illegal move so you need to remove >>it from the list. >> >>The other option is to write a function that generates legal moves that are 100% >>legal. For example, you would have to write a function that determine if a piece >>is pinned or not. If the piece is pinned then you don't generate any moves for >>it. Sometimes a piece can be partially pinned. For example: >> >>[D]8/8/5k2/2q5/8/4B3/8/6K1 w - - 0 1 >> >>In this position the bishop cannot move along the c1-h6 diagonal, but it can >>move along the g1-a7 diagonal. I've never written a function to determine if a >>piece is pinned, but it wouldn't be that much harder. Just more special cases. >>If you used this method you would also need to write the function to determine >>if a square was attacked and make sure that the king didn't move into check, so >>you would basically have to do this check anyway, so the first way is probably >>better. >> >>Russell > >Thank you ! I will try to create all the functions according to your >description. I will let you know of the result ! > >Sincerely, >Marek Mahdal Thank you once more ! I've created all the functions in PHP and the 100% legal moves generator works perfectly ! Sincerely, Marek Mahdal
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.