Search found 84 matches

by leanchess
Sun May 24, 2020 10:27 am
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: PGN standard
Replies: 45
Views: 17932

Re: PGN standard

Years ago Tord Romstad suggested to create a PGN replacement format in https://www.reddit.com/r/chess/comments/47fexz/towards_a_replacement_for_the_pgn_format/ Does anyone know was it evolved to something concrete? Interesting. That proposal (and most comments) align nicely with what I've been fidd...
by leanchess
Sat May 23, 2020 6:02 pm
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: PGN standard
Replies: 45
Views: 17932

Re: PGN standard

I'd suggest replacing PGN with a JSON/YAML-based format. As it happens, I've been recently fiddling with the following position serialisation: { "players": [ { "pieces": [ "Ke1", "Ra1", "Rh1", "Bc1", "Bf1", "Nb1", "Ng1", "Qd1", "Pa2", "Pb2", "Pc2", "Pd2", "Pe2", "Pf2", "Pg2", "Ph2" ], "castlingFiles...
by leanchess
Mon Apr 27, 2020 4:27 pm
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: Dirty hashing trick
Replies: 15
Views: 2806

Re: Dirty hashing trick

The idea is to substitute lookup with addition/subtraction. I tried implementing this in double push, but there seems to be a bug somewhere in my logic.
by leanchess
Mon Apr 27, 2020 1:47 pm
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: Dirty hashing trick
Replies: 15
Views: 2806

Re: Dirty hashing trick

hgm wrote:
Sun Apr 26, 2020 3:09 pm
Micro-Max doesn't bother to hash the castling rights.
How does that work?

Edit: I messed up the timings. I should have made sure -DNDEBUG wasn't commented out :oops:
by leanchess
Mon Apr 27, 2020 1:03 pm
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: Dirty hashing trick
Replies: 15
Views: 2806

Re: Dirty hashing trick

uint32 pieceKey[NPIECES]; uint32 squareKey[BOARDSIZE]; #define KEY(piece,square) (pieceKey[piece] * (unit64) squareKey[square]) How about the following? uint64_t piece_key[NPIECES]; uint64_t row_key[NPIECES]; uint64_t col_key[NPIECES]; #define KEY(piece, square) (piece_key[piece] + row_key[piece] *...
by leanchess
Mon Apr 27, 2020 8:49 am
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: Dirty hashing trick
Replies: 15
Views: 2806

Re: Dirty hashing trick

I use the Polyglot hash values for my TT. It saves some space since I don't need another dedicated array for the hash values and the current position's TT hash value can be used directly when looking up openings from a Polyglot book. I maintain castling rights as 4 bits (low order in a byte), setti...
by leanchess
Mon Apr 27, 2020 5:04 am
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: Dirty hashing trick
Replies: 15
Views: 2806

Re: Dirty hashing trick

The following works: static uint64_t get_key_ep_square(register const int8_t ep_square) { return (ep_square >= 0) + (ep_square & 7); } provided that the negative ep_square is divisible by 8. However, that seems to actually slow things down, so I'll stick with the ternary. Using 128 as the negative v...
by leanchess
Sun Apr 26, 2020 4:01 pm
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: Dirty hashing trick
Replies: 15
Views: 2806

Re: Dirty hashing trick

OK, I think I got it right this time around: static uint64_t get_key_ep_square(register const int8_t ep_square) { return ep_square < 0 ? 0 : ((ep_square & 7) ^ 8); } static uint64_t rotll(uint64_t n, uint8_t c) { return (n << c) | (n >> (64 - c)); } static uint64_t get_key_castling(register const ui...
by leanchess
Sun Apr 26, 2020 2:56 pm
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: Dirty hashing trick
Replies: 15
Views: 2806

Re: Dirty hashing trick

Scratch that. The code is incorrect, no performance gain with corrected code.
by leanchess
Sun Apr 26, 2020 1:42 pm
Forum: Computer Chess Club: Programming and Technical Discussions
Topic: Dirty hashing trick
Replies: 15
Views: 2806

Re: Dirty hashing trick

With the same idea applied to e.p. square: static uint64_t get_key_ep_square(register const int8_t ep_square) { return ep_square < 0 ? 0 : ((ep_square & 7) + 8); } static uint64_t get_key_castling(register const uint64_t dirty) { return ((dirty & dirty_masks[SIDE_WHITE]) | ((dirty << 56) & dirty_mas...