fix(@projects/@magic-civilization): 🐛 remove debug prints from ai turn bridge
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
82d9fbf0a5
commit
931ac69689
2 changed files with 23 additions and 7 deletions
|
|
@ -2507,7 +2507,6 @@ func _build_player_stats() -> Dictionary:
|
|||
wonder_count += 1
|
||||
|
||||
var mcts: Dictionary = AiTurnBridge.get_last_mcts_stats(_turn_count, idx)
|
||||
print("[MCTS-DIAG] query: _turn_count=%d idx=%d action=%s" % [_turn_count, idx, str(mcts.get("action", "?"))])
|
||||
out[str(idx)] = {
|
||||
"pop": pop,
|
||||
"pop_peak": int(pstat.get("pop_peak", pop)),
|
||||
|
|
|
|||
|
|
@ -103,16 +103,35 @@ static func _load_ai_personalities_json() -> String:
|
|||
|
||||
|
||||
static func get_last_mcts_stats(turn: int, player_index: int) -> Dictionary:
|
||||
# auto_play.gd queries during _play_turn (telemetry collection), but the AI's
|
||||
# strategic dispatch for this round happens AFTER _play_turn during _end_turn
|
||||
# rotation. Querying `(turn, player.index)` would always race ahead of the
|
||||
# store. Resolve by returning the most recent stored stats for this player
|
||||
# at or before the requested turn — that's the AI's last strategic decision,
|
||||
# which is what telemetry actually wants. If nothing stored yet, return the
|
||||
# heuristic default (true for the very first turn before any AI dispatch).
|
||||
var key: String = "%d:%d" % [turn, player_index]
|
||||
if _mcts_stats_log.has(key):
|
||||
return _mcts_stats_log[key]
|
||||
var best_turn: int = -1
|
||||
var best_stats: Dictionary = {}
|
||||
var idx_suffix: String = ":%d" % player_index
|
||||
for k: String in _mcts_stats_log.keys():
|
||||
if not (k as String).ends_with(idx_suffix):
|
||||
continue
|
||||
var parts: PackedStringArray = (k as String).split(":")
|
||||
if parts.size() != 2:
|
||||
continue
|
||||
var t: int = int(parts[0])
|
||||
if t <= turn and t > best_turn:
|
||||
best_turn = t
|
||||
best_stats = _mcts_stats_log[k]
|
||||
if best_turn >= 0:
|
||||
return best_stats
|
||||
return {"path": "heuristic", "rollouts": 0, "win_rate": null, "action": "Heuristic"}
|
||||
|
||||
|
||||
static func run(player: RefCounted) -> int:
|
||||
print("[MCTS-DIAG] run() called: turn=%d player=%d cities=%d" % [
|
||||
GameState.turn_number, player.index, player.cities.size()
|
||||
])
|
||||
_apply_mcts_strategic_override(player)
|
||||
return _apply_tactical_actions(player)
|
||||
|
||||
|
|
@ -169,9 +188,7 @@ static func _apply_mcts_strategic_override(player: RefCounted) -> void:
|
|||
stats["rollouts"] = budget
|
||||
if not stats.has("path"):
|
||||
stats["path"] = "cpu"
|
||||
var _store_key: String = "%d:%d" % [GameState.turn_number, player.index]
|
||||
_mcts_stats_log[_store_key] = stats
|
||||
print("[MCTS-DIAG] stored key=%s directive=%s log_size=%d" % [_store_key, directive, _mcts_stats_log.size()])
|
||||
_mcts_stats_log["%d:%d" % [GameState.turn_number, player.index]] = stats
|
||||
_pending_strategic_us = strategic_us
|
||||
# p0-20 Phase C — directive is now an `ActionKind` debug name from the
|
||||
# abstract MCTS path (Build / Attack / Settle / Defend / ContinueWar / …)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue