Add file-IPC automation harness for autonomous game testing
Launching Godot with --automation=<dir> activates an AutomationHarness
node that polls <dir>/inbox/ for JSON command files, executes them via
a thin facade over existing public surfaces (GameSim, InputMapper,
EventAnimator, ControlBar, PieceStockPanel), and writes results plus
screenshots back to disk. The black-box simulation boundary is not
crossed — every command routes through the same signals/methods a real
player would trigger.
A stdlib-only Python helper (tools/automation/harness.py) wraps the
protocol for test scripts and interactive REPLs. Smoke test passes
end-to-end: load mission, place a piece, step 10 turns, capture 14
1280x720 PNGs, handle rejections, quit cleanly. Existing 102 engine
unit tests still green.
2026-04-16 22:34:56 +02:00
|
|
|
using System;
|
|
|
|
|
using Chessistics.Engine.Simulation;
|
|
|
|
|
using Chessistics.Scripts.Input;
|
|
|
|
|
using Chessistics.Scripts.Presentation;
|
|
|
|
|
using Chessistics.Scripts.UI;
|
|
|
|
|
|
|
|
|
|
namespace Chessistics.Scripts.Automation;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Thin pass-through from the automation harness to the runtime objects it needs.
|
|
|
|
|
/// The harness never talks to Main directly — only through this facade — so the
|
|
|
|
|
/// surface to audit stays tiny.
|
|
|
|
|
/// </summary>
|
|
|
|
|
internal class AutomationFacade
|
|
|
|
|
{
|
|
|
|
|
public Func<GameSim?> Sim { get; }
|
|
|
|
|
public InputMapper Input { get; }
|
|
|
|
|
public EventAnimator Animator { get; }
|
|
|
|
|
public PieceStockPanel Stock { get; }
|
|
|
|
|
public ControlBar ControlBar { get; }
|
|
|
|
|
|
|
|
|
|
public Action<string, int> LoadMission { get; }
|
|
|
|
|
public Action Play { get; }
|
|
|
|
|
public Action Pause { get; }
|
|
|
|
|
public Action Step { get; }
|
|
|
|
|
public Action TogglePlayPause { get; }
|
|
|
|
|
public Action BackToMenu { get; }
|
|
|
|
|
public Action<float> SetSpeed { get; }
|
|
|
|
|
public Action Quit { get; }
|
Add QuickSave/QuickLoad with full state restore and visual rebuild
BoardState.CaptureSave/RestoreFromSave deep-copy every mutable field
(grid, pieces, demands, transformers, buffers, stock, campaign progress)
into a WorldSave slot. GameSim.QuickSave/QuickLoad expose slotted saves
and emit StateSavedEvent / StateRestoredEvent — the latter carries a
fresh BoardSnapshot so the presentation can rebuild board, pieces,
trajectories, objectives, stock, camera, and control bar in one pass.
F5/F9 trigger it in Main; harness gains quick_save/quick_load commands so
UI tests can checkpoint a scenario and resume without replaying from
scratch. Seven xUnit tests cover the roundtrip (including independence
from post-save mutations, campaign state, and multi-slot isolation).
2026-04-17 22:10:06 +02:00
|
|
|
public Action QuickSave { get; }
|
|
|
|
|
public Action QuickLoad { get; }
|
2026-04-17 22:14:06 +02:00
|
|
|
public Action Undo { get; }
|
2026-04-17 22:23:38 +02:00
|
|
|
public Action DeleteSelected { get; }
|
Add file-IPC automation harness for autonomous game testing
Launching Godot with --automation=<dir> activates an AutomationHarness
node that polls <dir>/inbox/ for JSON command files, executes them via
a thin facade over existing public surfaces (GameSim, InputMapper,
EventAnimator, ControlBar, PieceStockPanel), and writes results plus
screenshots back to disk. The black-box simulation boundary is not
crossed — every command routes through the same signals/methods a real
player would trigger.
A stdlib-only Python helper (tools/automation/harness.py) wraps the
protocol for test scripts and interactive REPLs. Smoke test passes
end-to-end: load mission, place a piece, step 10 turns, capture 14
1280x720 PNGs, handle rejections, quit cleanly. Existing 102 engine
unit tests still green.
2026-04-16 22:34:56 +02:00
|
|
|
|
|
|
|
|
public AutomationFacade(
|
|
|
|
|
Func<GameSim?> sim,
|
|
|
|
|
InputMapper input,
|
|
|
|
|
EventAnimator animator,
|
|
|
|
|
PieceStockPanel stock,
|
|
|
|
|
ControlBar controlBar,
|
|
|
|
|
Action<string, int> loadMission,
|
|
|
|
|
Action play,
|
|
|
|
|
Action pause,
|
|
|
|
|
Action step,
|
|
|
|
|
Action togglePlayPause,
|
|
|
|
|
Action backToMenu,
|
|
|
|
|
Action<float> setSpeed,
|
Add QuickSave/QuickLoad with full state restore and visual rebuild
BoardState.CaptureSave/RestoreFromSave deep-copy every mutable field
(grid, pieces, demands, transformers, buffers, stock, campaign progress)
into a WorldSave slot. GameSim.QuickSave/QuickLoad expose slotted saves
and emit StateSavedEvent / StateRestoredEvent — the latter carries a
fresh BoardSnapshot so the presentation can rebuild board, pieces,
trajectories, objectives, stock, camera, and control bar in one pass.
F5/F9 trigger it in Main; harness gains quick_save/quick_load commands so
UI tests can checkpoint a scenario and resume without replaying from
scratch. Seven xUnit tests cover the roundtrip (including independence
from post-save mutations, campaign state, and multi-slot isolation).
2026-04-17 22:10:06 +02:00
|
|
|
Action quit,
|
|
|
|
|
Action quickSave,
|
2026-04-17 22:14:06 +02:00
|
|
|
Action quickLoad,
|
2026-04-17 22:23:38 +02:00
|
|
|
Action undo,
|
|
|
|
|
Action deleteSelected)
|
Add file-IPC automation harness for autonomous game testing
Launching Godot with --automation=<dir> activates an AutomationHarness
node that polls <dir>/inbox/ for JSON command files, executes them via
a thin facade over existing public surfaces (GameSim, InputMapper,
EventAnimator, ControlBar, PieceStockPanel), and writes results plus
screenshots back to disk. The black-box simulation boundary is not
crossed — every command routes through the same signals/methods a real
player would trigger.
A stdlib-only Python helper (tools/automation/harness.py) wraps the
protocol for test scripts and interactive REPLs. Smoke test passes
end-to-end: load mission, place a piece, step 10 turns, capture 14
1280x720 PNGs, handle rejections, quit cleanly. Existing 102 engine
unit tests still green.
2026-04-16 22:34:56 +02:00
|
|
|
{
|
|
|
|
|
Sim = sim;
|
|
|
|
|
Input = input;
|
|
|
|
|
Animator = animator;
|
|
|
|
|
Stock = stock;
|
|
|
|
|
ControlBar = controlBar;
|
|
|
|
|
LoadMission = loadMission;
|
|
|
|
|
Play = play;
|
|
|
|
|
Pause = pause;
|
|
|
|
|
Step = step;
|
|
|
|
|
TogglePlayPause = togglePlayPause;
|
|
|
|
|
BackToMenu = backToMenu;
|
|
|
|
|
SetSpeed = setSpeed;
|
|
|
|
|
Quit = quit;
|
Add QuickSave/QuickLoad with full state restore and visual rebuild
BoardState.CaptureSave/RestoreFromSave deep-copy every mutable field
(grid, pieces, demands, transformers, buffers, stock, campaign progress)
into a WorldSave slot. GameSim.QuickSave/QuickLoad expose slotted saves
and emit StateSavedEvent / StateRestoredEvent — the latter carries a
fresh BoardSnapshot so the presentation can rebuild board, pieces,
trajectories, objectives, stock, camera, and control bar in one pass.
F5/F9 trigger it in Main; harness gains quick_save/quick_load commands so
UI tests can checkpoint a scenario and resume without replaying from
scratch. Seven xUnit tests cover the roundtrip (including independence
from post-save mutations, campaign state, and multi-slot isolation).
2026-04-17 22:10:06 +02:00
|
|
|
QuickSave = quickSave;
|
|
|
|
|
QuickLoad = quickLoad;
|
2026-04-17 22:14:06 +02:00
|
|
|
Undo = undo;
|
2026-04-17 22:23:38 +02:00
|
|
|
DeleteSelected = deleteSelected;
|
Add file-IPC automation harness for autonomous game testing
Launching Godot with --automation=<dir> activates an AutomationHarness
node that polls <dir>/inbox/ for JSON command files, executes them via
a thin facade over existing public surfaces (GameSim, InputMapper,
EventAnimator, ControlBar, PieceStockPanel), and writes results plus
screenshots back to disk. The black-box simulation boundary is not
crossed — every command routes through the same signals/methods a real
player would trigger.
A stdlib-only Python helper (tools/automation/harness.py) wraps the
protocol for test scripts and interactive REPLs. Smoke test passes
end-to-end: load mission, place a piece, step 10 turns, capture 14
1280x720 PNGs, handle rejections, quit cleanly. Existing 102 engine
unit tests still green.
2026-04-16 22:34:56 +02:00
|
|
|
}
|
|
|
|
|
}
|