What would you do on a chessboard? (position position)

You would create 3 lists (coordinates) for

  • empty position
  • black position
  • white position

or just iterate over the array as needed and reproduce the result every time?

what would be better? (speed)

+3
source share
3 answers

Two main options: speed and clarity of code.

If speed is your priority, you should use a 64-bit data type for each set of pieces on the board (for example, white pawns, black farms, en passant pawns). You can then use your own bitwise operations when generating moves and testing that move legitimacy.

, , . , , , , .

, Crafty (C) SharpChess (#).

( )

+7

, , . Chess Programming Wiki ( , ), Wikipedia .

- ( ) - , / , ( O (1) O (n) ). , "" , (bitboards , ). AI ( 4 5 ) .

+2

64 , :

byte [64] Squares;

, , .

, , . , , ? , .

, 8 . , 63, 8, 7.875, 7. 3, 8, 0,375, 0. # , :

Row = (int)(position / 8)

, , 8. , 24 - 0. 15 8 7,

Column = position % 8

Armed with these two concepts, we can transform any position on our 64-square board into a column and a row.

If you want to know more about creating your own chess engine, see http://www.chessbin.com

0
source

Source: https://habr.com/ru/post/1707759/


All Articles