Skip to content

LLM Player (Draft)#340

Draft
bcollazo wants to merge 3 commits intomasterfrom
claude/document-player-api-01CvXBkBtDpYtXyxT2KaqiH4
Draft

LLM Player (Draft)#340
bcollazo wants to merge 3 commits intomasterfrom
claude/document-player-api-01CvXBkBtDpYtXyxT2KaqiH4

Conversation

@bcollazo
Copy link
Copy Markdown
Owner

@bcollazo bcollazo commented Dec 2, 2025

No description provided.

Implement a new player type that uses Large Language Models via Ollama to make game decisions:

- LLMPlayer class: Makes network calls to local Ollama instance for each decision
- Prompt template: Markdown template with simplified game state and numbered actions
- LangChain integration: Uses langchain for prompt templating and Ollama integration
- Robust parsing: Best-effort extraction of action numbers from LLM responses with fallbacks
- Documentation: Comprehensive README with setup instructions and troubleshooting
- Example: Complete working example showing usage with different configurations

Features:
- Configurable model selection (llama3.2, mistral, etc.)
- Simplified state representation optimized for LLM context
- Safe fallback behavior if LLM returns invalid responses
- Temperature control for decision-making style

Dependencies: langchain, langchain-ollama (optional, only needed for LLMPlayer)
Clarify that opponent stats show only public information:
- Changed "total resources" to "resource cards" for clarity
- Added separate count for development cards (also public)
- Added comment noting this is public information only
- Opponents' specific resource breakdown remains hidden

This matches actual Catan rules where you can see opponents' hand sizes
but not which specific resources they hold.
Improve the LLM prompt clarity and usefulness:

Hand representation:
- Show resources as list: ['WOOD', 'WOOD', 'BRICK']
- Show unused dev cards as list: ['KNIGHT', 'YEAR_OF_PLENTY']
- Show used dev cards as list: ['KNIGHT']
- More intuitive than separate counts

Building locations:
- Add helper function to describe nodes by adjacent tiles
- Each building shown with tile description: "Settlement at 3 WHEAT - 5 ORE - 6 BRICK"
- Helps LLM understand board position and production potential
- Uses board.map.adjacent_tiles to get tile info (number + resource)

Prompt template:
- Reorganize into clear sections: Hand & Cards, Buildings, Bonuses
- Remove redundant individual resource counts
- Add "Buildings Available to Build" section
- More readable and easier for LLM to parse

This gives the LLM better spatial awareness and clearer state representation
for making informed strategic decisions.
@netlify
Copy link
Copy Markdown

netlify bot commented Dec 2, 2025

Deploy Preview for catanatron-staging canceled.

Name Link
🔨 Latest commit c947443
🔍 Latest deploy log https://app.netlify.com/projects/catanatron-staging/deploys/692eb39fca4de3000803c62c

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