Skip to content

Instantly share code, notes, and snippets.

@robostac
robostac / spring_post.md
Last active April 16, 2025 17:01
CG Spring 2025 Postmortem

Basic Description:

Search is done as a BFS. Board is stored as a uint32 with 3 bits per square.

After calculating each move the states for the next depth are stored in a hashmap so equivalent states are merged together with a count for how many times that state has been reached.

Some of my code snippets are from different versions so may not entirely match up with each other. Some code snippets aren't seperate functions anymore (lots of reorganising to reduce loads / stores and reuse data where possible) in my code so it's possible some of the types / function signatures aren't correct. Almost everything is in unsafe blocks due to the use of x64 compiler intrinsics. I haven't included any of the code for generating the lookup tables - nothing complicated there but it's an ugly mess of macros due to restrictions on what is allowed in const rust code (eg no for loops).

Final version uses multiple lookup tables based on the state of up to 4 squares to speed up moves, rotations and final scoring. I make u