Changes

Jump to: navigation, search

8x8 Board

2,502 bytes added, 00:09, 9 March 2021
no edit summary
Such a board representation is often used redundantly in [[Bitboards|bitboard]] programs to answer the question which piece (if any) resides on a square efficiently. It has to deal with [[Square Mapping Considerations|square mapping]] accordantly.
=Programming=
==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>
int color[64]; /* LIGHT, DARK, or EMPTY */
int piece[64]; /* PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING, or EMPTY */
</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>
int piece[64] = {
ROOK, KNIGHT,BISHOP,QUEEN, KING, BISHOP,KNIGHT,ROOK,
PAWN, PAWN, PAWN, PAWN, PAWN, PAWN, PAWN, PAWN,
EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
PAWN, PAWN, PAWN, PAWN, PAWN, PAWN, PAWN, PAWN,
ROOK, KNIGHT,BISHOP,QUEEN, KING, BISHOP,KNIGHT,ROOK
};
 
int color[64] = {
BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK,
BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK,
EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE,
WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE
};
</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>
std::vector<Piece> pieces;
</pre>
 
The vector is initialized <ref>https://github.com/nguyenpham/Banksia/blob/master/src/chess/chess.cpp Banksia - chess.cpp</ref>:
<pre>
Piece empty(PieceType::empty, Side::none);
for(int i = 0; i < 64; i++) {
pieces.push_back(empty);
}
</pre>
=Alternatives=
As a lone board representation, the 8x8 board has some efficiency issues with [[Move Generation|move generation]] related to off the board test. Therefore more common are approaches dealing with that, that is [[10x12 Board|10x12 board]] with surrounding ranks and files, and [[Vector Attacks]] with its cheap test and unique square difference property with respect to [[Distance|distance]] and [[Direction|direction]] <ref>[[Fritz Reul]] ('''2009'''). ''New Architectures in Computer Chess''. Ph.D. Thesis, ''2 Non-Bitboard Architectures''</ref>. In ''Games Playing with Computers'', 1972 <ref>[http://www.chilton-computing.org.uk/acl/literature/books/gamesplaying/p003.htm Chapter 3: Board Games - 3.1 CHESS] from [[Alex Bell]] ('''1972'''). ''[http://www.chilton-computing.org.uk/acl/literature/books/gamesplaying/overview.htm Games Playing with Computers]''. [https://en.wikipedia.org/wiki/Allen_%26_Unwin Allen & Unwin], ISBN-13: 978-0080212227</ref> , [[Alex Bell]] introduced an array of 65 squares, where the purpose of square 65 (always empty) is to detect pawns capturing outside the board by a [[Table-driven Move Generation|table driven move generator]].
=See also=
* [[Bitboards]]
: [[Square Mapping Considerations]]
* [[Table-driven Move Generation]]
* [[Vector Attacks]]
: [[0x88]]
* [https://www.stmintz.com/ccc/index.php?id=178465 Fastest Conversion from 0x88 board to 8x8 board representation] by [[Artem Petakov|Artem Pyatakov]], [[CCC]], July 06, 2001
* [https://www.stmintz.com/ccc/index.php?id=189800 Re: Ferret/Gerbil question] by [[Bruce Moreland]], [[CCC]], September 21, 2001 » [[Ferret]], [[Gerbil]], [[0x88]]
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=76817 C++ code for <nowiki>board[8][8]</nowiki> representation] by [[Yves De Billoëz]], [[CCC]], March 08, 2021
: [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=76817&start=4 Re: C++ code for <nowiki>board[8][8]</nowiki> representation] by [[Rein Halbersma]], [[CCC]], March 08, 2021 » [[Cpp|C++]]
=External Links=

Navigation menu