mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-13 16:52:04 +00:00
feat(training): support N-vs-M matches with persistent per-ship spawn IDs
Extends ShipObservations beyond the old self+1-opponent layout to padded teammate/opponent arrays (MAX_TEAMMATES=4, MAX_OPPONENTS=5, SIZE=83), zero-filling slots past the real roster size the same way the old single- opponent slot was zero-filled when absent. Slot stability across ticks requires a persistent identity: Ship gains spawn_index (set once by GameMode.spawn_ship, never reassigned — there's no despawn path anywhere in this codebase, so a roster is fixed for the whole episode/match). ai_ship_controller.gd's opponent discovery is rewritten from "first non-self ship" to classify every other ship by team and sort by spawn_index; training_mode.gd/ship_ai_controller.gd carry the equivalent sorted lists through the training path so both agree on slot assignment for the same roster. training_mode.gd and match_mode.gd both gain a team_size export (default 1, so every existing curriculum script and match keeps today's 1v1 behaviour unchanged). This is plumbing only: no 2v2+ curriculum or reward design, and no match-mode UI to pick team size, has been done yet. The two checkpoints in Game/bots/promoted/ are fitted to the old 35-float layout and are not migrated — expected to go stale until the next training run.
This commit is contained in:
@@ -58,6 +58,13 @@ var team: int = 0:
|
||||
team = value
|
||||
_apply_team_color()
|
||||
|
||||
# This ship's index within its team's roster (0, 1, 2, ...), set once by
|
||||
# GameMode.spawn_ship and never changed afterward. The stable identity
|
||||
# AIShipController/ShipAIController sort teammates/opponents by, so both
|
||||
# training and in-game inference assign the same ship to the same
|
||||
# observation-vector slot for the whole match (see ShipObservations).
|
||||
var spawn_index: int = -1
|
||||
|
||||
# Shared per-team accent material, built once per team and reused by every
|
||||
# ship — avoids allocating a fresh StandardMaterial3D from both _ready and
|
||||
# the team setter (previously ran at least twice per ship).
|
||||
|
||||
Reference in New Issue
Block a user