feat(training): add generation 5 curriculum

This commit is contained in:
Josh Creek
2026-08-08 14:56:17 +01:00
parent 33952b3cd0
commit 341a67f6da
10 changed files with 832 additions and 19 deletions
+22
View File
@@ -34,6 +34,11 @@ var _policy: PolicyNetwork
var _action := ShipAction.new()
var _ticks_until_decision := 0
# League mode revisits a small model pool every episode. Policies are
# immutable after load, so share parsed networks by path instead of reading
# and flattening the same 100KB+ JSON on every reset for every frozen ship.
static var _policy_cache: Dictionary = {}
var _ship: Ship
var _teammates: Array[Ship] = []
var _opponents: Array[Ship] = []
@@ -44,7 +49,24 @@ var _scene_refs_ready := false
func _ready():
if not model_path.is_empty():
load_policy(model_path)
# League training swaps a frozen opponent's policy between episodes without
# despawning the ship. Reset the held action/decision cadence with the model
# so no command from the previous opponent leaks into the next episode.
func load_policy(path: String) -> void:
model_path = path
if model_path.is_empty():
_policy = null
elif _policy_cache.has(model_path):
_policy = _policy_cache[model_path]
else:
_policy = PolicyNetwork.load_from_file(model_path)
if _policy != null:
_policy_cache[model_path] = _policy
_action = ShipAction.new()
_ticks_until_decision = 0
func get_action() -> ShipAction: