Author: Michel Langeveld
Date: 23:11:19 03/05/04
Go up one level in this thread
On March 05, 2004 at 16:33:36, Volker Böhm wrote:
>Hi,
>
>I am currently redesigning my board representation. In Move Generation I´ll
>write something like
>
>for every pawn
> generate & weight & store it´s moves
At the moment I have:
1) In Nullmover a piecelist for each piecetype.
2) A field2piecenr index for each field. This to map a field to the pieceindex.
3) When a piece is captured I move the last piece to this place.
You can make the following variations:
1A) Make a big list for each color: then you can't make a quick isdraw function.
I think GnuChess uses one big list for all pieces.
1b) Keep the kings on index 0. I use this is part of my position structure now
2a) Make for step 2) a board full with pointers (Gerbil): I didn't do this
because I though that pointers are a bit slower. But you don't have to put
field2piecenr to -1. This is actually also not necesarry in my implementation.
2a) Leavy empty holes. Then you can't use the piececounters for each piece. And
looping trough the piecelist takes a bit longer. But doing a move is a bit
faster.
3) You can put stuff in your move (fieldindex in piecelist) and use this in your
piecelist.
A normal whitemove looks like this:
pieceType frompiece = p.board[m.b.fromField];
pieceListType *pl = &piecelist[WHITE][frompiece];
pl->loc[field2piecenr[m.b.fromField]] = m.b.toField;
field2piecenr[m.b.toField] = field2piecenr[m.b.fromField];
field2piecenr[m.b.fromField] = -1;
typedef char pieceNumberType;
typedef pieceNumberType mapType[MAX_BORD_SIZE];
typedef struct {
pieceNumberType number;
char loc[10];
} pieceListType;
Before you start making this take a deep breath. It takes long to get it 100%
correct, bug free and fully working. It advice you to make a validate function
that validates as much as possible and call it after each domove and takeback.
To have a piecelist for each type helps you in:
* isdraw fucntion
* eval
* namilov tablebases access
* calculate pawn structure
* maybe also isAttack function, but I don't see quick how. Anybody?
My isDraw() function looks like this:
bool isDraw()
{
//do we have only 2 kings?
if (p.pieceCount == 2) return true;
//do we have 2 kings and a bishop or knight?
if (p.pieceCount == 3)
{
if (piecelist[WHITE][BISHOP].number == 1) return true;
if (piecelist[WHITE][KNIGHT].number == 1) return true;
if (piecelist[BLACK][BISHOP].number == 1) return true;
if (piecelist[BLACK][KNIGHT].number == 1) return true;
}
return false;
}
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.