feat(ai): add debug logging to ai turn execution

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Natalie 2026-04-18 07:00:30 -07:00
parent 4076a0b531
commit cbae959df4

View file

@ -48,8 +48,11 @@ static func get_last_mcts_stats(turn: int, player_index: int) -> Dictionary:
## Run the strategic MCTS override then the tactical action pass for `player`.
## Returns the count of tactical actions that dispatched successfully.
static func run(player: RefCounted) -> int:
push_error("[DBG] AiTurnBridge.run ENTRY player.index=%d turn=%d" % [player.index, GameState.turn_number])
_apply_mcts_strategic_override(player)
return _apply_tactical_actions(player)
var n: int = _apply_tactical_actions(player)
push_error("[DBG] AiTurnBridge.run EXIT player.index=%d actions_applied=%d" % [player.index, n])
return n
# ── MCTS strategic override ──────────────────────────────────────────────────
@ -164,10 +167,16 @@ static func _apply_tactical_actions(player: RefCounted) -> int:
var index_maps: Dictionary = _build_index_maps()
var state_json: String = JSON.stringify(_build_tactical_state(player))
var action_strs: PackedStringArray = ctrl.decide_actions(state_json, player.index)
push_error("[DBG] decide_actions p=%d%d actions: %s" % [
player.index, action_strs.size(),
str(action_strs).substr(0, 300)
])
var applied: int = 0
for s: String in action_strs:
if _dispatch_action(s, player, index_maps):
applied += 1
else:
push_error("[DBG] dispatch FAILED for p=%d action: %s" % [player.index, s.substr(0, 200)])
return applied
@ -468,6 +477,9 @@ static func _dispatch_found_city(
# target is the movement submodule's job; reject mismatches rather
# than teleporting the settler.
return false
push_error("[DBG] _dispatch_found_city ENTRY player.index=%d settler_id=%d at=%s" % [
player.index, int(fields.get("settler_id", -1)), str(settler.position)
])
var city: RefCounted = CityScript.new()
city.player = player
city.owner = player.index