I dont get it. What is the content of nextMoveTable ?would be a reasonably efficient way to generate moves.
move structure
Moderators: hgm, Rebel, chrisw
-
- Posts: 2657
- Joined: Wed Mar 10, 2010 10:18 pm
- Location: Hamburg, Germany
- Full name: Srdja Matovic
Re: move structure
-
- Posts: 670
- Joined: Mon Dec 03, 2007 3:01 pm
- Location: Barcelona, Spain
Re: move structure
I once wrote a similar move-generator .. maybe it is of any help to you. It is a retro-move generator but in principle you should get the idea.smatovic wrote:I dont get it. What is the content of nextMoveTable ?would be a reasonably efficient way to generate moves.
Code: Select all
int mgen_backward(int color, int * curpc, int * curdir, int * curshift) {
for (;*curpc < pccnt[color]; (*curpc)++) {
U8 curpcflag = pcflag[*curpc];
int curpos = pcsq[color][*curpc];
int curpct = pct[color][*curpc];
for (;offset[curpct][*curdir]; (*curdir)++) {
(*curshift)++;
int newpos = curpos + offset[curpct][*curdir] * (*curshift);
if ((newpos & ~63) || // newpos on the board
(!(table_move[curpos][newpos] & curpcflag)) || // newpos reachable for current piece
((curpct == KING) && (table_move[newpos][pcsq[!color][0]]&pcflag[KING])) || // kings may not stand next to each other
((occ[0]|occ[1]|bbSQ[pcsq[0][dynid]]) & bbSQ[newpos]) ) { // occupied newpos square
*curshift = 0;
continue;
}
pcsq[color][*curpc] = newpos;
return curpos;
}
*curdir = 0;
}
return -1;
}
-
- Posts: 27808
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: move structure
nextMoveTable[0][currentMove] would contain the (encoded) move to try after currentMove in case the toSquare of currentMove was occupied, nextMoveTable[1][currentMove] the one to try if it was empty. For leapers that would be the same, but for sliders the first would be the first step of a new ray, and the second the next step along the same ray.smatovic wrote:I dont get it. What is the content of nextMoveTable ?
There should be an encoding for 'invalid', to indicate that you are done with the current piece, and can start with the next. I forgot to include the test for that in the code I gave.
-
- Posts: 2657
- Joined: Wed Mar 10, 2010 10:18 pm
- Location: Hamburg, Germany
- Full name: Srdja Matovic
Re: move structure
Ok, i got a clue how this works....will think about that.
-
- Posts: 2657
- Joined: Wed Mar 10, 2010 10:18 pm
- Location: Hamburg, Germany
- Full name: Srdja Matovic
Re: move structure
...ran some tests...packing and unpacking lowers performance significantly.