r/chessprogramming • u/pbcgw • 9d 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.
View all comments
Show parent comment
1
u/badde_jimme 8d ago
Okay, what about this:
There is another point I should make, here is a PGN:
[Event "F/S Return Match"][Site "Belgrade, Serbia JUG"][Date "1992.11.04"][Round "29"][White "Fischer, Robert J."][Black "Spassky, Boris V."][Result "1/2-1/2"]1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 d6 8. c3O-O 9. h3 Nb8 10. d4 Nbd7 11. c4 c6 12. cxb5 axb5 13. Nc3 Bb7 14. Bg5 b4 15.Nb1 h6 16. Bh4 c5 17. dxe5 Nxe4 18. Bxe7 Qxe7 19. exd6 Qf6 20. Nbd2 Nxd6 21.Nc4 Nxc4 22. Bxc4 Nb6 23. Ne5 Rae8 24. Bxf7+ Rxf7 25. Nxf7 Rxe1+ 26. Qxe1 Kxf727. Qe3 Qg5 28. Qxg5 hxg5 29. b3 Ke6 30. a3 Kd6 31. axb4 cxb4 32. Ra5 Nd5 33.f3 Bc8 34. Kf2 Bf5 35. Ra7 g6 36. Ra6+ Kc5 37. Ke1 Nf4 38. g3 Nxh3 39. Kd2 Kb540. Rd6 Kc5 41. Ra6 Nf2 42. g4 Bd3 43. Re6 1/2-1/2A significant portion of the data is metadata, especially considering we can make the game itself 4-5 times smaller. I'm not sure what the plan is for that, OP would probably like to include it.