Author: Bruce Moreland
Date: 23:03:16 09/19/98
Go up one level in this thread
On September 19, 1998 at 11:14:40, Guillem Barnolas wrote: > > I am currently developing a pascal chess program which I think will be >quite weak, because to generate legal moves I'm generating all the moves and >then discarding the ones that leave the king in check... Generating only legal >ones seems quite tough.. I now crafty does, but considering it's in C and uses >bitboards, it's quite difficult for me to understand it.. I tried tscp, but it >uses the same technique that me (I should say i use the same that it uses..;) I >have thought of some way of doing this, but seem a little weird... I'll try to >explain in few words... I thought I could go from the king_position looking if >there are friendly pieces blocking possible attacks...(I think I might have seen >this in Crafty or some other program, as X_ray attacks...) and mark those >friendly pieces...afterwards i go through all the board and for non-marked >pieces I generate all the movements.. for pieces marked once I generate captures >to the attacking piece and movements on that direction.. for the pieces marked >more than once I generate no movements... I don't know If this would miss >anything... I haven't implemented it because I'm still fighting with the program >;-D... Here is a simple plan for you, which you can follow if you wish. What you want to do is create a list of moves to try. If you are trying to get the last ounce of performance out of a program, this has to be done well, but if you just want to get something running, it doesn't matter even a tiny bit how you do this, other than that the code shouldn't have any bugs. As an example, in the initial chess position, you want to create a list of the 16 pawn moves and the 4 knight moves for white. In more complex positions you'd have a different list of moves, and some captures would be involved, and you might get some pawn promotions, which can be handled as a series of discrete members of the list. When it is time to try out these moves, you go through the list and pick the one that you want to try first. This could be a winning capture, or a move that you remember from the hash table, or a killer move, or something else, it doesn't matter. At the point you decide you want to try a particular move, you make it on the board and *then* you can see if you left yourself in check. Or you can simply ignore whether you left yourself in check, and let the move generator discover that a king is en-prise and somehow properly react to this. In any case, what I am saying is that you don't have to detect check at the time you generate moves, you can detect check at a couple of places thereafter. 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.