Skip to content

Commit e78933f

Browse files
S1M0N38claude
andcommitted
feat(bot): add templates and tools configuration
Add Jinja2 templates for game state rendering and OpenAI tools definition for different game states (BLIND_SELECT, SELECTING_HAND, SHOP). Co-Authored-By: Claude <noreply@anthropic.com>
1 parent cffdf87 commit e78933f

3 files changed

Lines changed: 821 additions & 0 deletions

File tree

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# Game State
2+
3+
## Current Situation
4+
- **Game Phase**: {{ state_name }}
5+
{% if game -%}
6+
- **Round**: {{ game.round }}
7+
- **Ante**: Level {{ (game.round + 2) // 3 }}
8+
{% endif %}
9+
10+
{% if consumables and consumables.cards and (consumables.cards | length) > 0 %}
11+
### Consumables ({{ consumables.cards | length }})
12+
{% for c in consumables.cards -%}
13+
- {{ loop.index0 }}: {{ c.label }} ({{ c.config.center_key }}) | Cost: {{ c.cost | default('N/A') }}
14+
{% endfor %}
15+
{% endif %}
16+
17+
{% if game %}
18+
## Resources
19+
- **Money**: ${{ game.dollars }}
20+
- **Chips**: {{ game.chips }}
21+
{% if game.current_round -%}
22+
- **Hands Remaining**: {{ game.current_round.hands_left | default(0) }}
23+
- **Discards Remaining**: {{ game.current_round.discards_left | default(0) }}
24+
{% endif -%}
25+
{% if game.skips > 0 -%}
26+
- **Skips Available**: {{ game.skips }}
27+
{% endif %}
28+
29+
{% if game.blind_on_deck %}
30+
## Current Challenge
31+
- **Blind**: {{ game.blind_on_deck }}
32+
{# Blind target values may not be provided in game_state #}
33+
{% endif %}
34+
35+
## Game Constraints
36+
- **Hands Played This Run**: {{ game.hands_played }}
37+
{% if jokers and jokers.config and jokers.config.card_limit -%}
38+
- **Joker Slots**: {{ jokers.cards | length }}/{{ jokers.config.card_limit }}
39+
{% endif -%}
40+
{% if game.discount_percent > 0 -%}
41+
- **Shop Discount**: {{ game.discount_percent }}%
42+
{% endif -%}
43+
{% if game.bankrupt_at > 0 -%}
44+
- **Bankruptcy Threshold**: ${{ game.bankrupt_at }}
45+
{% endif %}
46+
{% endif %}
47+
48+
## Player Assets
49+
50+
### Hand
51+
{% if hand and hand.cards -%}
52+
{%- set value_map = {
53+
"Ace": "A", "King": "K", "Queen": "Q", "Jack": "J", "10": "T",
54+
"9": "9", "8": "8", "7": "7", "6": "6", "5": "5", "4": "4", "3": "3", "2": "2"
55+
} -%}
56+
{%- set suit_map = {"Spades": "s", "Hearts": "h", "Diamonds": "d", "Clubs": "c"} -%}
57+
Cards:
58+
{% for card in hand.cards -%}
59+
{%- set card_config = card.config.card -%}
60+
{%- set short_value = value_map.get(card_config.value, "?") -%}
61+
{%- set short_suit = suit_map.get(card_config.suit, "?") -%}
62+
{{ loop.index0 }}: {{ short_value }}{{ short_suit }} ({{ card_config.value }} of {{ card_config.suit }})
63+
{% endfor %}
64+
Available Indices: {{ range(hand.cards | length) | list }}
65+
{% else -%}
66+
No cards in hand
67+
{% endif %}
68+
69+
{% if jokers and jokers.cards %}
70+
### Jokers ({{ jokers.cards | length }})
71+
{% for joker in jokers.cards -%}
72+
- **{{ joker.label | default('Joker ' ~ loop.index) }}** (key: {{ joker.config.center_key | default('unknown') }})
73+
- Cost: {{ joker.cost | default('N/A') }} | Debuff: {{ joker.debuff | default(false) }}
74+
{% endfor %}
75+
{% else %}
76+
### Jokers
77+
No jokers
78+
{% endif %}
79+
{% if reasoning_history %}
80+
81+
## Previous Plays
82+
83+
{% for reasoning in reasoning_history[-3:] -%}
84+
{{ loop.index }}. {{ reasoning }}
85+
{% endfor %}
86+
{% elif responses %}
87+
88+
## Previous Plays
89+
90+
{% for response in responses[-3:] -%}
91+
{%- if response.choices and response.choices[0].message.tool_calls -%}
92+
{%- set tool_call = response.choices[0].message.tool_calls[0] -%}
93+
{%- set args_json = tool_call.function.arguments -%}
94+
{%- set args = args_json | from_json -%}
95+
{%- if args.reasoning -%}
96+
{{ loop.index }}. {{ args.reasoning }}
97+
{% endif -%}
98+
{%- endif -%}
99+
{% endfor %}
100+
{% endif %}
101+
102+
## Decision Required
103+
104+
{% if state_name == "BLIND_SELECT" -%}
105+
You need to decide whether to **select** or **skip** the current blind.
106+
107+
### Available Actions:
108+
109+
- **select**: Play against this blind to earn chips and money
110+
- **skip**: Skip this blind to get a tag reward but no chips
111+
112+
### Strategy:
113+
114+
- Consider your current hand strength and jokers
115+
- Evaluate if you can beat the blind's chip requirement
116+
- Skipping gives you a tag but no progress toward winning
117+
{% elif state_name == "SELECTING_HAND" -%}
118+
You need to decide whether to **play cards** to form a poker hand or **discard cards** to try for better combinations.
119+
120+
### Available Actions:
121+
122+
- **play_hand**: Play selected cards as a poker hand to score chips
123+
- **discard**: Discard selected cards to draw new ones (uses a discard)
124+
125+
### Strategy:
126+
127+
- Look for the strongest poker hand you can make
128+
- Consider remaining hands and discards
129+
- Balance between playing weak hands vs. using discards to improve
130+
- Remember: higher poker hands score more points
131+
132+
### Card Selection:
133+
134+
- Use 0-based indices from the "Available indices" list above
135+
- You can select 1-5 cards for either action
136+
- Example: [0, 2, 4] selects the 1st, 3rd, and 5th cards
137+
{% elif state_name == "SHOP" -%}
138+
You are in the shop and need to decide what to do.
139+
140+
### Available Actions:
141+
142+
- **next_round**: End shopping and proceed to next blind
143+
- **reroll**: Spend money to refresh shop items
144+
- **buy_card (index)**: Purchase a card from the shop_jokers area by 0-based index
145+
- **redeem_voucher (index)**: Redeem a voucher from the shop_vouchers area by 0-based index
146+
147+
### Strategy:
148+
149+
- Consider your current money and what you need
150+
- Jokers can provide powerful ongoing effects
151+
- Vouchers give permanent upgrades
152+
- Don't overspend - you need money for future rounds
153+
154+
### Shop Items
155+
156+
{% if shop_jokers and shop_jokers.cards and (shop_jokers.cards | length) > 0 -%}
157+
Jokers / Cards:
158+
{% for card in shop_jokers.cards -%}
159+
- {{ loop.index0 }}: {{ card.label }} ({{ card.ability.set }}) — ${{ card.cost }}
160+
{% endfor %}
161+
{% endif -%}
162+
163+
{% if shop_vouchers and shop_vouchers.cards and (shop_vouchers.cards | length) > 0 -%}
164+
Vouchers:
165+
{% for card in shop_vouchers.cards -%}
166+
- {{ loop.index0 }}: {{ card.label }} — ${{ card.cost }}
167+
{% endfor %}
168+
{% endif -%}
169+
{% endif %}

0 commit comments

Comments
 (0)