Author: James Swafford
Date: 07:43:54 01/23/06
Go up one level in this thread
On January 23, 2006 at 00:42:19, Joshua Shriver wrote:
Josh,
My advice to you would be to forget about everything else and just
focus on creating one function: MoveList genMoves(Position p) .
That is, given any chess position, give me a list of *legal* moves.
Here's how you might break that process down:
1. Decide what a Move should look like. Don't try to do bit
twiddling like Crafty does... just keep it simple. Some
structure with :
a. source (from) square
b. dest (to) square
c. piece that's moving
d. type (or flags) to indicate special moves, like
e.p., promotions, captures, whatever.
2. Decide what a MoveList should look like.
3. Create a simple Position data structure. At a minimum, you need
some way to record which piece is on which square. A 64 element
array would work, or some of the other variants you mentioned.
You also need to have fields to record who is on move, what the
castling rights for each player are, the 'e.p. square'.
4. Create a routine to initialize a position
5. Create a function to generate pseudo-legal moves for a given
position. You could break this down into even smaller tasks:
pseudo legal moves for knights, pseudo legal moves for pawns,
etc. FORGET about whether said move is legal (if it leaves
your king in check)... just use the basic rules for movement
for each piece. Call this genPseudoMoves().
6. Create a routine to update your position structure given a
move. makeMove(Move m)
6. Create your perft function to count the nodes your movegen
creates to a depth of 1. Should be 20. To a depth of 2; should
be 400.
7. Now, add a genMoves() that takes the list produced by
genPseudoMoves() and discards the moves that are illegal.
The best way to do this is to :
a. make the move
b. see if it left your king in check
c. unmake the move (or restore the position using a copy)
d. if the move was illegal, flag it or throw it out somehow
Make sure you get the right node counts. Once you have a fully
functional and debugged move gen, then and only then worry about
search, eval, etc. But by this point you're well on your way.
Basically, divide and conquer. :)
--
James
>Part 1.
>
>I've decided to start my engine from scratch after a couple years leading
>nowhere with little to no advancement, chess burnout, and trying to bite off
>more than I could chew.
>
>In reviewing the code for tscp, I was wondering what are the piece/square tables
>in the eval.c file?
>
>The way I interpret the comments, it adjusts the value of a piece given it's
>location on the board. If this is so, then I dont see how it can be useful since
>the value of a piece (or strength perhaps) would be determined by all other
>pieces on the board and location. Example if the pawn is about to take the
>queen, it would have more strength even if it is in a square that this table
>claims is weak.
>
>I might be totally off.
>
>Part 2.
>
>I've had some fun ideas that I've been wanting to implement over the years but
>could never translate that to code. My major roadblock has been in basic
>components such as a move generator. I've read probably every link that's been
>posted concerning the various board types (0x88, bitboard, etc), algorithms
>(alpha-beta cuttoffs, qsearch, etc) ... however in short of reviewing the code
>for tscp, crafty, fruit there seems to be little to no info of how to implement
>key features given x,y,z. Each piece seems to be effected by prior parts (move
>generator for a bitboard is diff than one for 0x88).
>
>
>On a humble note, guess I'm just not a good programmer. I've tried looking at
>the source for various engines but have no idea what's going on. TSCP seems
>somewhat digestable but finding the flow of it still seems a little rough, let
>alone trying to digest fruit or crafty (no disrespect to their authors it's my
>inabilities to understand).
>
>Any advice or commentary is appreciated. This is a wonderful hobby and
>community. I look forward to having something that really plays even if weak.
>
>Thanks in advance!
>-Josh
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.