feat(monte-carlo): wire greedy/random AI strategies into harness with CLI flags and CI guardrail#429
Merged
SorraTheOrc merged 2 commits intomainfrom Mar 13, 2026
Conversation
…rt and CI guardrail - Add 'greedy' and 'random' to MonteCarloStrategy type in MainStreetMonteCarlo.ts - Wire GreedyStrategy/RandomStrategy from MainStreetAiStrategy.ts via createAiPlayerForStrategy() - Update runSeed() to use MainStreetAiPlayer for AI strategies (preserving legacy path) - Add --seeds/--maxTurns CLI aliases in scripts/monte-carlo.ts; update defaults - Update package.json monte-carlo script to use --strategy greedy - Add CI guardrail test (20-80% win rate for greedy strategy) - Add monte-carlo CI job with JSON/CSV artifact upload to deploy.yml Co-authored-by: SorraTheOrc <250240+SorraTheOrc@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Extend Main Street Monte Carlo harness for AI strategies
feat(monte-carlo): wire greedy/random AI strategies into harness with CLI flags and CI guardrail
Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Monte Carlo harness only supported internal legacy strategies (
market-greedy,demo-greedy) and lacked the--seeds/--maxTurnsCLI flags, making it impossible to evaluate theGreedyStrategy/RandomStrategyAI implementations at scale or gate CI on win-rate balance.Harness (
MainStreetMonteCarlo.ts)MonteCarloStrategytype:'market-greedy' | 'demo-greedy' | 'greedy' | 'random'createAiPlayerForStrategy(): maps strategy name →MainStreetAiPlayerbound to a deterministic RNG derived fromseedToNumber(${seed}-ai). Returnsnullfor legacy strategies (preserves existing behaviour)runSeed()now branches: AI strategies use achooseAction()loop; legacy strategies retain the upfront-plan pathCLI (
scripts/monte-carlo.ts)--seeds(alias for--runs) and--maxTurns(alias for--max-turns)greedyandrandomas valid--strategyvaluesgreedy, maxTurns →25npm script (
package.json)Updated
monte-carloto use new flag names and thegreedydefault:CI guardrail (
tests/main-street/monte-carlo-greedy-guardrail.test.ts)New Vitest suite — fails build when
greedywin rate falls outside 20–80% over 100 deterministic seeds on Medium difficulty. Also smoke-testsrandomstrategy for valid output range.CI workflow (
.github/workflows/deploy.yml)Adds a
monte-carlojob that runs the harness and uploadsresults/(JSON + CSV) as a 30-day artifact.build-and-deploynow depends on this job.Original prompt
This section details on the original issue you should resolve
<issue_title>Main Street M3: Monte Carlo Harness Extension for AI Strategies</issue_title>
<issue_description>
Problem statement
Extend the Main Street Monte Carlo harness so it can run and evaluate the project AI strategies (greedy + random) at scale, produce JSON and CSV metrics, and gate CI with a configurable win‑rate guardrail. This will let designers and engineers validate economy and difficulty balance deterministically across many seeded runs.
Users
User stories
npm run monte-carlo -- --strategy <name> --seeds <n> --maxTurns <n>locally or in CI and have the pipeline fail if win rate falls outside the guardrail.Success criteria
--strategy(defaultgreedy),--seeds(default 200), and--maxTurns(default 25).MonteCarloMetricsand a CSV export of runs; both written to the--outpath when provided.greedyandrandomstrategies are discoverable and selectable by name by the harness.Constraints
Existing state
example-games/main-street/MainStreetMonteCarlo.tsimplements runMonteCarlo and CSV exporter;scripts/monte-carlo.tsis a thin runner.tests/main-street/monte-carlo-balance.test.tsand related integration tests exist and exercise the harness.ideaandin-progress.Desired change
RunMonteCarloOptions/MonteCarloStrategyto include strategy names forgreedyandrandom(if not already present).scripts/monte-carlo.tsand npm scriptmonte-carloto accept--strategy,--seeds,--maxTurns, and--out.Related work
Potentially related docs
Potentially related work items
Notes / decisions captured from intake
greedy.Open questions
ci/workflow or a new workflow)? Suggested default: add to existing main CI workflow as a separate job that runs the harness and uploads artifacts.📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.