Draft
Add utility-based strategic AI (ai_utility.js + ai_strategic.js)#6
Conversation
Co-authored-by: chrisraff <22504698+chrisraff@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add AI strategy for scoring board states by utility
Add utility-based strategic AI (ai_utility.js + ai_strategic.js)
Mar 14, 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.
Implements a new AI strategy that scores board states by utility and selects attacks by expected value, plus a reusable
BoardUtilitylibrary for graph/board analysis.ai_utility.js— shared library (BoardUtility)WIN_PROB[a][d]precomputed at load time. Correctly models that the attacker rollsattack_dice − 1dice.board_score(game, arm, dice, pn): four-factor utility:+3.0 × my_largest_connected_region— drives dice income−2.0 × max_opponent_connected_region— their income threat+0.4 × frontier_dice— dice that can actually attack (locked interior dice contribute 0)−0.5 × exposed_opponent_strong_dice— opponent armies ≥5 dice bordering meget_largest_component(game, arm, pn)and BFS helpers operate on detachedarm/dicearrays so simulated states never touch the live game object.ai_strategic.js— the AIEach turn, for every legal attack:
income_bonus = max(0, my_conn/opp_conn_max − 1) × 0.3: when my connected region significantly outpaces opponents', marginally negative-EV attacks become worth taking because dice income means faster recovery.EV > baseline_score; return0(end turn) otherwise.Integration
index.html: loadsai_utility.js→ai_strategic.jsbeforegame.jsgame.js: player slot 4 switched fromai_defaulttoai_strategic✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.