Efficient storage of a chess position

I read a lot of web hits related to this issue and I still haven't found a definitive answer.

What I would like to do is create a chess database capable of identifying transpositions (usually which pieces are on the squares).

EDIT: It should also be able to identify similar (but not exactly identical) positions.

This discussion was almost 20 years ago (when space was a problem): https://groups.google.com/forum/#!topic/rec.games.chess.computer/wVyS3tftZAA

One participant discusses square matrix coding fragments using 4 x 64 bits plus several bits for additional information (castling, en passant, etc.): there are six parts (Pawn, Rook, Knight, Bishop, Queen, King) plus an empty square that will be 3 bits (2 ^ 3) and another bit for the color of the part.

In total there would be 4 numbers of 64 bits each plus additional information.

Question: is there any other more effective way of storing a chess position?

I should probably mention that this question is focused on the database, and not on the game (i.e. my only interest is to efficiently store and retrieve, and not create any AI or create any moves).

Thanks Adrian

+4
source share
6 answers

32 64 . 6- , 32 192 , 4x64.

, , (, ) . , , , .

, , , - , , , .

Edit:

:

  • , , (64 ).
  • 32
  • 21, 26, 30, 32, 32, 30, 26 21 ( A-H).

, (64 ^ 12 * 32 ^ 4 * 21 ^ 4 * 26 ^ 4 * 30 ^ 4 * 32 ^ 8) -1, 391935874857773690005106949814449284944862535808450559999, 188 . - , (, 1 B1 2 G1, 1 G1 2 at 1).

- , , , , , , . , , , 2 ^ 188, , 187 .

+3

, (3 ), 0y111 . , , :

         All pieces are followed by color bit
0y000c 0 Pawn
0y001c 1 Rook
0y010c 2 Knight
0y011c 3 Bishop
0y100c 4 Queen
0y101c 5 King
0y110 6 Empty space
0y111 7 Repeat next symbol (count is next 6 bits, then symbol)

a1 , , :

12354321      Literal white encoding from a1 to h1    32 bits
7 8 0         repeat white pawn 8 times               13 bits
7 32 6        repeat 32 empty spaces                  12 bits
7 8 8         repeat black pawn 8 times               13 bits
9abcdba9      Literal encoding of black               32 bits
                                                    ---------
                                                     102 bits total

, , , . , , .

+1

- (FEN). . .

FEN :

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1

Fen 6 .

1 . , - .

2 , . (w b)

3 . KQkq , . K = King side white q = queen side black

4 En passant target square . , "-". , "" . , , en passant

5 Halfmove: . , , .

6 Fullmove: . 1 .

+1

, Zobrist. 64- . oneway, , , . , 64 , -, , . 8 . , , , , , , , . Zobrist ( SQLite), , .

0

  • , .
  • (, ).
  • .
  • /.

32 (4 * 64 ) - . 1000 30 . 192 - 24 , 23 . , - , , , . , , , , .

, , . , . , , ( ).

. . 32 (, , ). , , .

. , , . . , , , e4, 9 , 30 , , , . , , ...

, , ( ) . CPU. - .

- , . Piece-centric . - , - . . , , . , , .

0

: , , .

, , RLE, - , . , , , , RLE . , , .

, jlahd , , , , 188 , 168 . , . (32 + 4x64) ^ 16 . 223 = 28 .

, . 6 . . 13 12 , 1348 x 12 ^ 16. en-passant - 17 . 240 .

In conclusion, it looks like you can get 12.5% ​​of the space while maintaining the position of the shapes instead of the contents of each square.

0
source

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


All Articles