Skip to content

feat: strategic placement engines for AI players#37

Merged
njbrake merged 3 commits intomainfrom
feat/strategic-placement-engines
Apr 3, 2026
Merged

feat: strategic placement engines for AI players#37
njbrake merged 3 commits intomainfrom
feat/strategic-placement-engines

Conversation

@njbrake
Copy link
Copy Markdown
Contributor

@njbrake njbrake commented Apr 3, 2026

Description

Enrich setup prompts so LLM players can reason strategically about settlement placement during the setup phase. Previously, AI players received bare vertex coordinates like (0, -2, N) with zero information about adjacent resources, probability, ports, or spatial relationships. Now each legal vertex shows:

  • Adjacent resources with number tokens (e.g. Ore(10), Sheep(2), Wood(9))
  • Total pip count for probability reasoning
  • Expansion potential -- how many adjacent vertices satisfy the distance rule for future settlements
  • Opponent proximity -- other players' buildings on shared production hexes
  • Own buildings -- player's existing settlements (round 2 connectivity context)
  • Port access info (e.g. 2:1 Wheat port)

Example annotation:

  3. (0,-1,S) | Wheat(12), Wheat(11) | pips=4 | expand=2
  7. (2,-2,N) | Wheat(9), Brick(6) | pips=9 | expand=1 | 2:1 Wheat port | near: P1
 12. (-1,0,N) | Wood(9), Ore(8) | pips=9 | expand=3 | your settlements: (0,-2,N)

Also adds per-personality setup strategies injected into the prompt, and fixes the hardcoded round=1 bug in LlamafilePlayer.

Changes:

  • board.rs: Add get_hex(), port_at_vertex(), public pip_count() helpers
  • board_view.rs: Deduplicate probability_dots -> use board::pip_count
  • prompt.rs: Add annotate_vertex() with resource, spatial, and expansion context; enrich setup_settlement_prompt with legend
  • personality.rs: Add optional setup_strategy field + setup_strategy_text() method + built-in strategies for all 5 personalities
  • mod.rs: Add round: u8 to Player::choose_settlement trait
  • orchestrator.rs: Pass actual round number to choose_settlement
  • llamafile_player.rs: Use real round, inject strategy + player names into prompt
  • All other player impls: Accept new _round: u8 parameter
  • diplomat.toml / rusher.toml: Add setup_strategy

Fixes #35

PR Type

  • New Feature
  • Bug Fix
  • Refactor
  • Documentation
  • Infrastructure / CI

Checklist

  • I understand the code I am submitting
  • New and existing tests pass
  • Documentation was updated where necessary

AI Usage

  • No AI was used
  • AI was used for drafting/refactoring
  • This is fully AI-generated

AI Model/Tool used: Claude Opus 4.6 via Claude Code

Any Additional AI Details you'd like to share: Implemented all sub-tasks from the issue plus spatial context enrichment based on research into LLM board game representations (Diplomacy-style per-decision relational context). Added 13 new tests covering all new functionality.

  • I am an AI Agent filling out this form (check box if true)

njbrake and others added 3 commits April 3, 2026 10:20
Enrich setup prompts so LLM players can reason strategically about
settlement placement. Each legal vertex now shows adjacent resources
with number tokens, total pip count, and port access.

- Add board helpers: get_hex(), port_at_vertex(), pip_count()
- Add annotate_vertex() to prompt.rs for rich per-vertex context
- Add setup_strategy field to Personality with per-archetype strategies
- Thread round number through Player::choose_settlement trait
- Fix hardcoded round=1 in LlamafilePlayer, inject setup strategy
- Deduplicate probability_dots: board_view.rs now uses board::pip_count

Fixes #35

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Enrich annotate_vertex with per-decision spatial context so LLMs can
reason about board position, not just resource quality:

- Expansion potential: open adjacent vertices satisfying distance rule
- Opponent proximity: other players' buildings on shared production hexes
- Own buildings: player's existing settlements (useful in round 2)
- Updated legend explaining all annotation fields

Research showed the Diplomacy-style "per-decision relational context"
pattern outperforms raw coordinate dumps for LLM spatial reasoning.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Merge origin/main to pick up refactor: redesign new game screen with
rules config (#41). No conflicts -- that PR only touched UI files.
@njbrake njbrake merged commit 7c48e2f into main Apr 3, 2026
5 checks passed
@njbrake njbrake deleted the feat/strategic-placement-engines branch April 3, 2026 10:48
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.

feat: strategic placement engines for AI players

1 participant