Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: hashing in QS

Author: Dieter Buerssner

Date: 11:20:05 10/21/04

Go up one level in this thread


On October 21, 2004 at 07:55:33, Uri Blass wrote:

>On October 21, 2004 at 07:15:12, Vincent Diepeveen wrote:
>
>>it's useless to use 14 bits as that's an extra expensive 'if then else'.

Not necessary. Assume you have (for example) N=2, B=3, R=4, Q=5.


move = from*64 + to + (promoted_piece-2)*64*64.

No branches.

>I showed a simple way to compress to 14 bits.
>You need special tables to compress to less than 14 bits.

I can suggest a method to compress to 9 bits. Enumerate the pieces, for example
from a1-h8. 16 pieces max, so with 4 bits you can "adress" each piece. Maximum
numbers of moves per piece is 27 -> 5 bits. It would need a few tables, but no
move generator. The piece adress gives the from square. The to square could be
something like: to = to_table[board[from]][move>>4].

For all "normal" positions 8 bit is also possible. For example when we assume,
that there are less than 3 queens and less than 5 rooks + queens, ... of one
color. Now enumerate the pieces first by vale (K, Q, R, B, N, P) and then by
square (Qa1 comes before Qa2). The move will be a byte. value 0-7 means the K
move. From 8 to (8+26) the 2nd piece (for example a Q), etc.

8 + 3*27 + 2*15 + 2*14 + 8*12 = 243.

I used 12 possible moves for pawns and knights here (a pawn can have 12 moves, a
knight of course not). A bit more tweaking, and it will be enough for 4 or 5
queens, and will probably be able to store all mvoes in all seriously played
games. For a database (where one also wants to store some constructed games with
many promotions), for example move number 255 could mean an "escape", (in case
of 9 queens, etc.) and the next 2 bytes store the move in a more conventional
way.

Regards,
Dieter



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.