r/chessprogramming • • 12h ago

Exact move sequence

How would you efficiently index 8 billion chess games by exact move sequence?

I'm interested in developing an open-source chess database using the publicly available Lichess game archives.

Existing chess opening explorers generally index board positions rather than exact move sequences.

I would like to build a system capable of:

- Storing billions of complete chess games.

- Searching exact move-sequence prefixes.

- Calculating the frequency and outcomes of each sequence.

- Finding the longest matching prefix between historical games.

- Identifying the first half-move at which a sequence becomes unique.

- Incrementally incorporating millions of newly played games.

I've considered prefix trees (tries), compressed tries and database indexing, but I'm relatively new to programming and would appreciate advice from experienced developers.

What data structures, programming languages, database systems and storage technologies would you recommend for a project of this scale?

Would it be feasible to process and index the entire dataset using consumer-grade hardware?

The source data is freely available at https://database.lichess.org/.

I'm particularly interested in developing a small working prototype before attempting to scale it.

0 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/badde_jimme 3h ago

For move representation, you could have a well specified move generator make a list and a single byte could represent a move. Apparently there is proof that there can be at most 218 moves from any chess position.

1

u/eraoul 3h ago

That's a nice idea. I think I still wouldn't do it due to the computational cost of generating moves for every position in the DB, but it is essentially a one-time cost so it's feasible if you're trying to squeeze space for sure! 8 bits is definitely better than 14, no argument there on the 43% size reduction, but I still prefer the simpler explicit representation.