fix(@projects/@magic-civilization): 🐛 update world-map interaction and menu keys

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Natalie 2026-04-19 16:54:00 -07:00
parent 272d00f317
commit 9342b13ed2
6 changed files with 23 additions and 26 deletions

View file

@ -1,11 +1,8 @@
{
"mcpServers": {
"objectives": {
"command": "node",
"args": ["/var/home/lilith/Code/@packages/@ts/@mcp/mcp-objectives/dist/index.js"],
"env": {
"PROJECT_ROOT": "/var/home/lilith/Code/@projects/@magic-civilization"
}
"command": "/opt/homebrew/bin/mcp-objectives",
"args": []
}
}
}

View file

@ -5,7 +5,7 @@ priority: p0
scope: game1
owner: wireguard
status: partial
updated_at: 2026-04-18
updated_at: 2026-04-19
evidence:
- src/game/engine/scenes/world_map/world_map.tscn
- src/game/engine/scenes/world_map/world_map.gd
@ -34,14 +34,14 @@ The world-map is unplayable because basic interaction is broken: clicking a unit
## Acceptance
- ✓ Tutorial dim `ColorRect` no longer blocks mouse input — `tutorial_overlay.gd:86` is now `MOUSE_FILTER_PASS`.
- ✓ Clicking a player unit selects it; `unit_panel.tscn` listens on `EventBus.unit_selected` and renders name/stats + action buttons (Move/Fortify/Skip/FoundCity/BuildImprovement). World-map instantiates the panel in `world_map.tscn:UnitPanelLayer` and wires the action signals in `world_map.gd:_connect_signals`.
- ✓ Single-click on a city hex now opens the city screen via `world_map.gd:_open_city_at_axial`. Bombard removed from single-click path (was `_handle_hex_click` lines ~350-358; now only the legacy `_bombard_city != null` branch remains and no code path arms it from a single click).
- ✓ Pressing ESC with no panel open opens the in-game menu — `main.gd:_unhandled_key_input` handles ESC (already correct, audited).
- ✓ Pressing F10 at any time opens the in-game menu — added `KEY_F10` branch in `main.gd:_unhandled_key_input`.
- ✓ Pressing ESC while the city screen is open closes it — added `_unhandled_key_input` to `city_screen.gd` that calls `_on_close_pressed` when visible.
- ✓ Pressing ESC while the tech tree or chronicle is open closes it — `world_map.gd:_handle_escape_key` (refactored from `_handle_hotkeys`).
- ◻ The in-game menu closes on ESC — pre-existing behavior in `ingame_menu.tscn`; not modified by this objective. Needs proof-screenshot confirmation.
- ✓ Tutorial dim `ColorRect` no longer blocks mouse input — `tutorial_overlay.gd:86` is now `MOUSE_FILTER_PASS`. (code-verified 2026-04-19)
- ✓ Clicking a player unit selects it; `unit_panel.tscn` listens on `EventBus.unit_selected` and renders name/stats + action buttons (Move/Fortify/Skip/FoundCity/BuildImprovement). World-map instantiates the panel in `world_map.tscn:UnitPanelLayer` and wires the action signals in `world_map.gd:_connect_signals`. (code-verified 2026-04-19)
- ✓ Single-click on a city hex now opens the city screen via `world_map.gd:_open_city_at_axial`. Bombard removed from single-click path (was `_handle_hex_click` lines ~350-358; now only the legacy `_bombard_city != null` branch remains and no code path arms it from a single click). (code-verified 2026-04-19)
- ✓ Pressing ESC with no panel open opens the in-game menu — `main.gd:_unhandled_key_input` handles ESC (already correct, audited). (code-verified 2026-04-19)
- ✓ Pressing F10 at any time opens the in-game menu — added `KEY_F10` branch in `main.gd:_unhandled_key_input` lines 153-158. (code-verified 2026-04-19)
- ✓ Pressing ESC while the city screen is open closes it — added `_unhandled_key_input` to `city_screen.gd:375` that calls `_on_close_pressed` when visible. (code-verified 2026-04-19)
- ✓ Pressing ESC while the tech tree or chronicle is open closes it — `world_map.gd:_handle_escape_key` (refactored from `_handle_hotkeys`). (code-verified 2026-04-19)
- ◻ The in-game menu closes on ESC — pre-existing behavior in `ingame_menu.tscn`; not modified by this objective. Needs proof-screenshot confirmation. (proof scene exists; screenshot pending apricot run)
## Remaining to reach done

View file

@ -5,7 +5,7 @@ priority: p0
status: partial
scope: game1
owner: warcouncil
updated_at: 2026-04-18
updated_at: 2026-04-19
evidence:
- src/simulator/crates/mc-ai/src/mcts_tree.rs
- src/simulator/crates/mc-ai/src/evaluator.rs

View file

@ -39,11 +39,11 @@ pub struct GdMcTreeController {
gpu_enabled: bool,
/// When true, Trees use PUCT selection with per-node priors instead of
/// classical UCB1 (p0-38). Toggled by `set_priors_enabled` (driven by
/// `AI_MCTS_PRIORS` env). Default `false` preserves UCB1. Priors only
/// bite when the underlying `TreeState` overrides `action_prior`;
/// `GameRolloutState` does (softmax over personality utility);
/// `McSnapshot` currently does not (returns uniform 1.0 → PUCT reduces
/// to UCB1-equivalent ordering).
/// `AI_MCTS_PRIORS` env). Default `true`; set `AI_MCTS_PRIORS=false` to
/// revert to UCB1. Priors only bite when the underlying `TreeState`
/// overrides `action_prior`; `GameRolloutState` does (softmax over
/// personality utility); `McSnapshot` currently does not (uniform 1.0 →
/// PUCT reduces to UCB1-equivalent ordering).
priors_enabled: bool,
base: Base<RefCounted>,
}
@ -59,9 +59,9 @@ impl IRefCounted for GdMcTreeController {
std::env::var("AI_GPU_ROLLOUT").as_deref(),
Ok("1") | Ok("true") | Ok("TRUE") | Ok("True")
);
let priors_enabled = matches!(
let priors_enabled = !matches!(
std::env::var("AI_MCTS_PRIORS").as_deref(),
Ok("1") | Ok("true") | Ok("TRUE") | Ok("True")
Ok("0") | Ok("false") | Ok("FALSE") | Ok("False")
);
Self {
rollout_budget: 1000,
@ -115,7 +115,7 @@ impl GdMcTreeController {
/// Enable or disable PUCT selection with per-node priors (p0-38).
/// Toggled by `ai_turn_bridge.gd` based on the `AI_MCTS_PRIORS` env.
/// Default `false` preserves classical UCB1 behavior.
/// Default `true`; set `AI_MCTS_PRIORS=false` to revert to UCB1.
///
/// Effect is bounded by the underlying TreeState: `GameRolloutState`
/// provides personality-softmax priors, but the current `McSnapshot`

View file

@ -106,8 +106,7 @@ pub struct Tree<S: TreeState> {
/// (`Q + c_puct * P * sqrt(N_parent) / (1 + N_child)`) with per-node
/// priors populated at expansion time from `TreeState::action_prior`.
/// When `false`, selection uses classical UCB1 and the `prior` field is
/// ignored. Default `false` preserves existing behavior until callers
/// opt in (p0-38).
/// ignored. Default `true`; set `AI_MCTS_PRIORS=false` to revert to UCB1.
pub use_priors: bool,
/// Maximum simulated turns walked per rollout. Passed into
/// `TreeState::rollout`. Defaults to `rollout::DEFAULT_ROLLOUT_HORIZON`.
@ -143,7 +142,7 @@ impl<S: TreeState> Tree<S> {
nodes: vec![Node::new(root_state, None, None)],
exploration_constant: std::f32::consts::SQRT_2,
c_puct: std::f32::consts::SQRT_2,
use_priors: false,
use_priors: true,
rollout_horizon: crate::rollout::DEFAULT_ROLLOUT_HORIZON,
rollout_temperature: crate::rollout::DEFAULT_ROLLOUT_TEMPERATURE,
root_player: 0,

View file

@ -1,4 +1,5 @@
{
"enableAllProjectMcpServers": true,
"hooks": {
"PreToolUse": [
{