How jaasssoooonnnnn/firstlight_cr works
FirstLight CR is an offline Clash Royale environment and agent-training system. Its main loop reconstructs replay behavior in the native engine, turns observations and actions into training examples, learns recurrent policies through imitation learning and PPO self-play, then evaluates or runs those policies in matches. The graph also preserves the card-semantics and distributed-worker branches. Several links reflect README-level capabilities because their implementation was not sampled; edges cite only the README or source-index references that support them.
Main entry points: battle_env.py Battle environment · async_cluster_self_play.py Self-play collection · cr_native_env.py Native match host · model.py Recurrent actor-critic
Components 24
Native battle runtime
- Native engine probe
native_runner/probe/cr_replay_probe.cpp - Native match host
native_runner/cr_native_env.py - Battle environment
native_runner/battle_env.py - Versioned contracts
native_runner/contracts.py - Match configuration
native_runner/match_factory.py
Replay and game data
- Card specifications
native_runner/card_specs.py - Static card logic
native_runner/resource_compiler/card_logic.py - Card and mechanics catalog
native_runner/resource_compiler/catalog.py - Replay reconstruction
native_runner/royaleapi_replay.py - Replay archive
native_runner/training/replay_archive.py
Training and policy
- Training cache
native_runner/training/v4/cache_builder.py - Imitation learning
native_runner/training/v4/imitation.py - Observation tensorization
native_runner/training/v4/tensorizer.py - Recurrent actor-critic
native_runner/training/v4/model.py - PPO optimization
native_runner/training/v4/ppo.py - Self-play collection
native_runner/training/v4/async_cluster_self_play.py - Remote worker transport
native_runner/training/v4/remote_worker_transport.py
Play and operations
- Policy inference session
native_runner/training/v4/policy_session.py - Match evaluation
native_runner/training/v4/evaluate.py - Replay and match viewer
native_runner/training/replay_viewer.py - Policy service
native_runner/training/v4/serve_policy.py
Other components
- Trainer / researcher
- Offline player
- Replay dataset
Connections 29
- Replay dataset → Replay reconstruction: supplies replays
README.md - Replay reconstruction → Native match host: reconstructs matches
README.md - Replay reconstruction → Replay archive: adapts episodes
native_runner/royaleapi_replay.py - Replay archive → Training cache: feeds cache
- Training cache → Imitation learning: provides examples
- Imitation learning → Recurrent actor-critic: trains policy
README.md - Self-play collection → Battle environment: collects matches
README.md - Self-play collection → PPO optimization: collects PPO data
native_runner/training/v4/async_cluster_self_play.py - PPO optimization → Recurrent actor-critic: updates policy
README.md - Self-play collection → Remote worker transport: uses worker transport
native_runner/training/v4/async_cluster_self_play.py - Battle environment → Native match host: binds engine
native_runner/battle_env.py - Native match host → Native engine probe: controls native engine
README.md - Match configuration → Native match host: configures matches
native_runner/cr_native_env.py - Battle environment → Versioned contracts: uses wire contracts
native_runner/battle_env.py - Battle environment → Card specifications: uses card specs
native_runner/battle_env.py - Card specifications → Static card logic: resolves card logic
- Card and mechanics catalog → Static card logic: compiles logic
native_runner/resource_compiler/catalog.py - Battle environment → Observation tensorization: supplies observations
- Observation tensorization → Recurrent actor-critic: encodes model input
native_runner/training/v4/policy_session.py - Recurrent actor-critic → Policy inference session: runs inference
native_runner/training/v4/policy_session.py - Policy inference session → Battle environment: selects actions
native_runner/training/v4/policy_session.py - Trainer / researcher → Replay dataset: chooses data
README.md - Trainer / researcher → Self-play collection: starts training
README.md - Trainer / researcher → Match evaluation: compares policies
README.md - Match evaluation → Battle environment: runs matches
- Offline player → Replay and match viewer: opens offline match
README.md - Replay and match viewer → Policy inference session: uses policy
native_runner/training/replay_viewer.py - Offline player → Policy service: requests actions
README.md - Policy service → Policy inference session: serves inference