How minuskelvin/cold-clear-2 works
Cold Clear 2 is a Tetris-versus bot that speaks the Tetris Bot Protocol (TBP) to a frontend. The main workflow receives game events, builds or updates bot state, searches for placements, and returns suggestions; a worker performs ongoing search while the protocol loop handles requests. Search combines move generation, freestyle evaluation, and a transposition-aware DAG with known-piece and speculative layers. The README documents bitboard representation and multithreaded search. Some implementation files were not sampled, so links to internal search components reflect only supported wiring.
Main entry points: lib.rs Protocol loop · sync.rs Bot synchronizer · bot.rs Bot search control · main.rs Command-line adapter
Components 17
TBP interaction
- Protocol loop
src/lib.rs - TBP messages
src/tbp.rs - Move suggestions
src/tbp.rs - Command-line adapter
src/main.rs
Bot lifecycle
- Bot synchronizer
src/sync.rs - Bot search control
src/bot.rs - Freestyle strategy
src/bot/freestyle.rs - Bot configuration
src/default.json - Search worker
src/sync.rs
Search engine
- Search DAG
src/dag.rs - Known-piece layer
src/dag/known.rs - Speculative layer
src/dag/speculated.rs - Move generation
src/movegen.rs - State map
src/map.rs
Game model
- Game state
src/data.rs - Column bitboard
src/data.rs
Other components
- TBP frontend
Connections 22
- TBP frontend → Command-line adapter: sends lines
- Command-line adapter → TBP messages: decodes JSON
- Command-line adapter → Protocol loop: runs
- Protocol loop → TBP messages: handles messages
- Protocol loop → Bot synchronizer: dispatches events
- Bot synchronizer → Bot search control: updates and queries
- Protocol loop → Bot search control: creates bot
- Protocol loop → Bot configuration: loads defaults
- Search worker → Bot synchronizer: works through
- Bot synchronizer → Bot search control: runs search
- Bot search control → Search DAG: selects and advances
- Bot search control → Freestyle strategy: uses strategy
- Freestyle strategy → Move generation: generates placements
- Freestyle strategy → Game state: evaluates positions
- Search DAG → Known-piece layer: dispatches
- Search DAG → Speculative layer: dispatches
- Known-piece layer → State map: indexes states
- Speculative layer → State map: indexes states
- Protocol loop → Game state: constructs initial state
- Game state → Column bitboard: contains bitboard
- Bot synchronizer → Move suggestions: returns suggestion data
- Protocol loop → TBP frontend: sends responses