Changes

Jump to: navigation, search

8x8 Board

1,319 bytes added, 02:34, 6 March 2021
Programming
=Programming=
==Board Board Representation=====TSCP===
[[TSCP]] uses two 64 element arrays, containing empty square plus [[Pieces#PieceTypeCoding|pure piece code]], and empty square plus piece color code <ref>[https://jim.sh/svn/jim/vendor/microwindows/current/src/demos/tuxchess/data.c TSCP - data.c]</ref>:.
<pre>
However, when generating moves, TSCP converts the board data into a bigger array [[10x12 Board]].
===FirstChess===
[[FirstChess]] uses two 64 integer arrays, for all tasks, including move generating.
</pre>
===Banksia===
[[Banksia]] uses only one vector from C++ standard library <ref>https://github.com/nguyenpham/Banksia/blob/master/src/base/base.h Banksia - base.h</ref>:
<pre>
}
</pre>
 
==Move Generators==
===Straightforward===
Based on the given cell and the size of the board, programs can calculate if the target cells are out of the board.
In below code [[Banksia]] generates moves for a Rook at position pos:
 
<pre>
case PieceType::rook: // both queen and rook here
{
int col = getColumn(pos);
for (int y=pos - 1; y >= pos - col; y--) { /* go left */
gen_addMove(moves, pos, y, captureOnly);
if (!isEmpty(y)) {
break;
}
}
for (int y=pos + 1; y < pos - col + 8; y++) { /* go right */
gen_addMove(moves, pos, y, captureOnly);
if (!isEmpty(y)) {
break;
}
}
for (int y=pos - 8; y >= 0; y -= 8) { /* go up */
gen_addMove(moves, pos, y, captureOnly);
if (!isEmpty(y)) {
break;
}
}
for (int y=pos + 8; y < 64; y += 8) { /* go down */
gen_addMove(moves, pos, y, captureOnly);
if (!isEmpty(y)) {
break;
}
}
break;
}
</pre>
 
==Precalculate data==
Some programs pre-calculate data for each cell and extract it when generating moves. That method is well-known mentioned by [[GNU Chess]] version 4.0 document (not code).
=Alternatives=

Navigation menu