hexe-rs / Hexe

[WIP] A pure Rust chess engine
https://docs.rs/hexe
Apache License 2.0
28 stars 0 forks source link

Smaller Ray Attack Table #1

Closed nvzqz closed 6 years ago

nvzqz commented 6 years ago

Currently this project uses a massive table for sliding piece attack generation. The size should be able to be optimized down while maintaining performance.

Topics of interest here:

nvzqz commented 6 years ago

@niklasf You manage to get an attack table of size 88772 in shakmaty. What techniques did you use for finding magics that allow for the smaller size? This is a difference of 18876 bitboards, which is more than 2KB.

I see you also use fixed shift magics. Have you noticed better performance with them?

niklasf commented 6 years ago

Hi, I am using magics found by Volker Annuss and published here: http://www.talkchess.com/forum/viewtopic.php?topic_view=threads&p=727500&t=64790. He first generates candidates with a varying range of properties and then uses an annealing algorithm to create a single compact attack table with overlaps. Using overlaps allows him to achieve this table size even with fixed shift magics. (And doing only constant shifts leads to another considerable performance gain.)

I also tested the black magics he published in that thread, which are even more compact, but they perform slightly worse (even my slightly improved version).

Meanwhile I am working on project that may help improve the table size even further, or alternatively at least disprove the existence of magics with certain properties: http://www.talkchess.com/forum/viewtopic.php?start=0&t=65187&topic_view=flat

nvzqz commented 6 years ago

Just updated the magics to those by Volker and I already see a speed improvement 😄

Changes are in 1082fd8506eda974fde2dcdb94eabf8074e2b2d2