Skip to content

Add headless simulation and terminal gameplay - #11627

Draft
rrnewton wants to merge 2 commits into
Card-Forge:masterfrom
rrnewton:rrn-headless-rebased
Draft

Add headless simulation and terminal gameplay#11627
rrnewton wants to merge 2 commits into
Card-Forge:masterfrom
rrnewton:rrn-headless-rebased

Conversation

@rrnewton

@rrnewton rrnewton commented Aug 15, 2026

Copy link
Copy Markdown

Summary

Forge can now run games without starting the desktop or mobile application. A new forge-headless Maven module provides automated AI simulation and interactive terminal gameplay, with a repository-level headless.sh launcher.

./headless.sh --help
./headless.sh sim -d deck1.dck deck2.dck -n 20 -s 42
./headless.sh tui deck1.dck deck2.dck --p1 tui --p2 ai

The launcher provides top-level command discovery, command-specific help, examples, conventional exit codes, and deck paths resolved relative to the caller's working directory.

Capabilities

  • sim runs one or more games between normal Forge AI players.
  • tui lets a person play or observe a game from an interactive terminal.
  • Seeded simulation supports repeatable test and benchmark runs.
  • Per-player AI profiles allow controlled comparisons between AI configurations.
  • A lightweight random controller supports throughput and load testing.
  • Pass and zero-choice controllers support focused automated tests.
  • Relative and absolute .dck paths are accepted.

The random controller deliberately handles only its supported legal-action subset and skips spells that require targets. It is intended for benchmarks, not strategic play. Tournament mode continues to use normal Forge AI; random-controller mode cannot be combined with tournaments or AI profiles.

Compatibility

The existing desktop forge.view.SimulateMatch entry point remains available as a deprecated facade and delegates to the new module. Existing simulation options for seeds, formats, tournaments, timeouts, AI profiles, quiet output, and match size remain available.

Validation

  • mvn -pl forge-headless -am test: 13 tests passed (3 forge-game, 10 forge-headless), 0 failures.
  • mvn -pl forge-headless -am package -DskipTests: passed and produced the assembled launcher JAR.
  • ./headless.sh --help, sim --help, and tui --help: passed against the packaged JAR.
  • Repeated seeded two-game simulations produced identical normalized SHA-256 output.
  • A seeded random-controller simulation completed with a winner.

Extract the desktop simulator into a reusable headless Maven module, retain the desktop compatibility facade, and provide terminal, random, and zero controllers. Preserve current upstream seed and AI-profile options while fixing direct file-path deck loading.

Test Results Summary:
- mvn -pl forge-headless -am test: 11 tests passed (3 forge-game, 8 forge-headless), 0 failed
- packaged headless assembly successfully
- seeded two-game simulation repeated with identical normalized SHA-256 output
- random-controller launcher smoke completed with a winner
Give the headless launcher conventional top-level help, readable simulation options and examples, clean terminal help, caller-relative deck paths, and quiet process replacement without shell timing noise.

Test Results Summary:
- mvn -pl forge-headless -am test: 13 tests passed (3 forge-game, 10 forge-headless), 0 failed
- mvn -pl forge-headless -am package -DskipTests: passed
- ./headless.sh --help, sim --help, and tui --help: passed
@rrnewton
rrnewton force-pushed the rrn-headless-rebased branch from 64051e1 to 642e1f1 Compare August 16, 2026 15:28
@rrnewton rrnewton changed the title Add a reusable headless simulation and terminal module Add headless simulation and terminal gameplay Aug 16, 2026
@tehdiplomat

Copy link
Copy Markdown
Contributor

This is less "Add headless simulation" and more "Move headless simulation into its own package"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants