|
8 | 8 | from typing import Any |
9 | 9 |
|
10 | 10 | import httpx |
11 | | -from balatrobot import BalatroClient |
12 | | -from balatrobot.enums import State |
13 | 11 | from jinja2 import Environment, FileSystemLoader |
14 | 12 | from openai import AsyncOpenAI |
15 | 13 | from openai.types.chat import ChatCompletion |
16 | 14 |
|
| 15 | +from balatrobot import BalatroClient |
| 16 | +from balatrobot.enums import State |
| 17 | + |
17 | 18 | logger = logging.getLogger(__name__) |
18 | 19 | logging.basicConfig(level=logging.INFO) |
19 | 20 |
|
@@ -147,6 +148,7 @@ async def get_tool_call(self, game_state: dict): |
147 | 148 | # Extract tool call |
148 | 149 | message = response.choices[0].message |
149 | 150 | if not hasattr(message, "tool_calls") or not message.tool_calls: |
| 151 | + print(response.choices[0].message) |
150 | 152 | raise ValueError("No tool calls in LLM response") |
151 | 153 |
|
152 | 154 | tool_call = message.tool_calls[0] |
@@ -188,26 +190,20 @@ async def play_game(self) -> None: |
188 | 190 |
|
189 | 191 | match current_state: |
190 | 192 | case State.BLIND_SELECT: |
191 | | - # TODO: Enable LLM decision for blind selection |
192 | | - # tool_call = await self.make_decision(game_state) |
193 | | - game_state = self.balatro_client.send_message( |
194 | | - "skip_or_select_blind", {"action": "select"} |
195 | | - ) |
| 193 | + tool_call = await self.get_tool_call(game_state) |
| 194 | + game_state = self.execute_tool_call(tool_call) |
196 | 195 |
|
197 | 196 | case State.SELECTING_HAND: |
198 | 197 | tool_call = await self.get_tool_call(game_state) |
199 | 198 | game_state = self.execute_tool_call(tool_call) |
200 | 199 |
|
201 | 200 | case State.ROUND_EVAL: |
202 | | - logger.info("Cashing out") |
203 | | - game_state = self.balatro_client.send_message("cash_out") |
| 201 | + tool_call = await self.get_tool_call(game_state) |
| 202 | + game_state = self.execute_tool_call(tool_call) |
204 | 203 |
|
205 | 204 | case State.SHOP: |
206 | | - # TODO: Enable LLM decision for shop actions |
207 | | - # tool_call = await self.make_decision(game_state) |
208 | | - game_state = self.balatro_client.send_message( |
209 | | - "shop", {"action": "next_round"} |
210 | | - ) |
| 205 | + tool_call = await self.get_tool_call(game_state) |
| 206 | + game_state = self.execute_tool_call(tool_call) |
211 | 207 |
|
212 | 208 | case State.GAME_OVER: |
213 | 209 | logger.info("Game over!") |
|
0 commit comments