6.0 KiB
Deep CFR v0 Gap vs Legacy coolrl
This document compares the current coolrl-lost-cities Deep CFR v0
implementation with the legacy Lost Cities Deep CFR implementation in
../coolrl.
The current implementation proves that Cython traversal primitives, PyTorch networks, memory collection, and a one-iteration smoke run can work together. It is not yet equivalent to the legacy implementation.
Current v0
Implemented:
- Cython traversal primitives:
random_rollout_valueroot_action_values- direct
GameStateC API use for legal actions and push/pop restoration
- Recursive Python Deep CFR traverser:
traverse(state, traverser, iteration, depth)logic- terminal values
- traverser vs opponent node behavior
- sampled action recursion
- sampled action value and node value calculation
- instantaneous regret collection at traverser nodes
- strategy-memory collection
- depth and node-budget cutoffs
- Advantage-network-driven traversal policies:
- information-state encoding
- advantage network forward pass
- regret matching over legal actions
- sampled action recursion
- Minimal Cython information-state encoding.
- Small PyTorch MLP.
- Simple in-memory sample storage with legal masks.
- Legal-mask-aware advantage loss and masked strategy loss.
- Smoke tests for traversal restoration and trainer execution.
This is now a real single-process Deep CFR v0, but it is still not equivalent to the legacy implementation.
Major Algorithm Gaps
Outcome Sampling Controls
Legacy coolrl supports:
outcome_sampling_epsilon- sampled action probability correction
- optional sampled value clipping
- unsampled regret modes:
negative_node_valuezero
Current v0 has none of these.
Cutoff Values
Legacy traversal supports:
- score-diff cutoff values
- random rollout cutoff values
- safe-heuristic rollout cutoff values
- rollout max-step timeouts
- cutoff stats
Current v0 uses score-diff cutoff values for depth and node-budget cutoffs, but does not support rollout-based cutoff values.
Training and Memory Gaps
Reservoir Memory
Legacy implementation has separate AdvantageMemory and StrategyMemory with:
- capacity limits
- reservoir sampling
- batch sampling
- sample merging from traversal workers
Current v0 stores TrainingSample objects with legal masks, but still uses
list-like storage rather than true reservoir sampling.
Config System
Legacy config is split into:
- rules config
- network config
- encoding config
- traversal config
- optimization config
- memory config
- evaluation config
- checkpoint config
- run config
It also supports YAML loading and experiment-level overrides.
Current v0 has only DeepCFRConfig.
Runtime and Operations Gaps
Checkpointing
Legacy checkpoints include:
- config
- Lost Cities rules config
- iteration
- input/action dimensions
- advantage networks
- strategy network
- optimizer states
- self-play league snapshots
- latest and per-iteration checkpoint files
Current v0 has no checkpoint save/load.
Evaluation Integration
Legacy implementation can load a strategy checkpoint as a bot and evaluate it against supported opponents.
Supported legacy eval flow includes:
- random opponent
- safe heuristic opponent
- passive discard opponent
- noisy/safe variants through the evaluation layer
- many detailed gameplay metrics
Current v0 does not evaluate during training and does not expose a strategy-net bot adapter.
CLI
Legacy implementation has command-line tools for:
- training
- evaluation
- evaluation suites
- status/progress
- plotting and visualization
- traversal benchmarking
- imitation/pretraining experiments
- policy-gradient fine-tuning experiments
Current v0 has no CLI.
Multiprocessing Workers
Legacy traversal can run through multiprocessing worker batches:
- worker count resolution, including
auto - traversal chunking
- frozen network state dict transfer
- worker-local traversal
- result merging
- progress logging
- hotspot profiling
Current v0 runs in-process only.
Metrics and Logging
Legacy training writes:
metrics.jsonlruntime_progress.jsontrain.log- traversal nodes/sec
- cutoff rates
- endpoint depth buckets
- advantage and strategy losses
- evaluation metrics
- hotspot timing metrics
Current v0 returns a small IterationMetrics object.
Encoding Gaps
Legacy encoding is much richer. It includes:
- phase one-hot
- current-player indicator
- player id
- hand slots with card-type one-hot and empty-slot flag
- both players' expedition card counts
- expedition lengths
- last numeric rank per expedition
- discard pile card counts
- discard pile length
- discard pile top card
- public card counts
- deck ratio
- turn-count ratio
- pending-discard one-hot
- optional derived playability features
- optional slot-aware playability features
Current v0 includes only a minimal subset:
- phase flags
- current player
- encoded player
- deck ratio
- player hand slot features
- legal action mask
The current encoding should be expanded before serious training runs.
Self-play League Gap
Legacy implementation supports self-play league opponent selection:
- current networks
- recent snapshots
- older snapshots
- safe-heuristic anchor
- snapshot interval
- maximum snapshot count
Current v0 has no league or checkpoint-snapshot opponent sampling.
Practical Priority
Recommended implementation order:
- Add outcome-sampling controls.
- Add rollout-based cutoff values.
- Replace list-like memory with reservoir memory.
- Expand encoding to include public board, discard, and score features.
- Add checkpoint save/load.
- Add strategy-net bot adapter and evaluation integration.
- Add CLI for train/eval/smoke.
- Add traversal stats and benchmark reporting.
- Add multiprocessing workers only after the single-process algorithm is correct.
The first four items are algorithm-critical. The rest are operationally useful but should not block improving the learning loop.