mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 00:14:00 +00:00
feat(*): Log live goal rate to TensorBoard during training
This commit is contained in:
@@ -107,6 +107,15 @@ var ball: RigidBody3D
|
||||
var opponent: Ship
|
||||
var attack_goal_position: Vector3
|
||||
|
||||
# Set directly by TrainingMode (_on_goal_scored / the timeout branch in
|
||||
# _physics_process) at the same time as `done = true`. Deliberately NOT
|
||||
# cleared in reset(): TrainingMode's _reset_episode() (which calls reset())
|
||||
# runs synchronously, immediately after done is set, before the Sync node
|
||||
# ever reads get_info()/get_done() for that terminal tick — clearing it here
|
||||
# would wipe the value that read needs. Both call sites always overwrite
|
||||
# (true on goal, false on timeout) rather than toggle, so no reset is needed.
|
||||
var goal_scored_this_episode := false
|
||||
|
||||
var _ticks_since_ball_touch := 1 << 30 # large so the first touch always pays
|
||||
|
||||
|
||||
@@ -135,6 +144,14 @@ func get_reward() -> float:
|
||||
return reward
|
||||
|
||||
|
||||
# Symmetric across both self-play agents: reports whether this episode ended
|
||||
# in a goal at all, not which team scored — a clean "goal rate" signal
|
||||
# distinct from rollout/ep_rew_mean, which mixes this with dense shaping
|
||||
# (ball chasing/touching). See train.py's GoalRateCallback.
|
||||
func get_info() -> Dictionary:
|
||||
return {"goal_scored": goal_scored_this_episode}
|
||||
|
||||
|
||||
func get_action_space() -> Dictionary:
|
||||
return {
|
||||
"thrust": {"size": 3, "action_type": "continuous"},
|
||||
|
||||
Reference in New Issue
Block a user