Skip to content

Commit 8e89521

Browse files
committed
perf: send message get_game_state to trigger frame rendering
1 parent 27a8585 commit 8e89521

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/balatrollm/bot.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,15 +426,19 @@ async def _run_game_loop(self, game_state: dict[str, Any]) -> None:
426426
current_state = State(game_state["state"])
427427
logger.info(f"Current state: {current_state}")
428428

429+
# HACK: this is reqired when balatrobot is running with --render-on-api
430+
# Hitting the API endpoint enables the frame to be rendered so we can
431+
# take a screenshot of the actual game state.
432+
await asyncio.sleep(0.5)
433+
_ = self.balatro_client.send_message("get_game_state")
434+
429435
match current_state:
430436
case State.SELECTING_HAND | State.SHOP:
431437
response = await self.get_llm_response(game_state)
432438
game_state = self.process_and_execute_tool_call(response)
433439
case State.ROUND_EVAL:
434-
await asyncio.sleep(0.5)
435440
game_state = self.balatro_client.send_message("cash_out")
436441
case State.BLIND_SELECT:
437-
await asyncio.sleep(0.5)
438442
game_state = self.balatro_client.send_message(
439443
"skip_or_select_blind", arguments={"action": "select"}
440444
)

0 commit comments

Comments
 (0)