Skip to content

Commit d15f087

Browse files
committed
feat: add --no-screenshot flag to balatrollm
1 parent 9681cf5 commit d15f087

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

src/balatrollm/bot.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pathlib import Path
88
from typing import Any
99

10+
from balatrobot.enums import State
1011
from openai import (
1112
APIConnectionError,
1213
APIStatusError,
@@ -18,7 +19,6 @@
1819
from openai.types.chat import ChatCompletion
1920

2021
from balatrobot import BalatroClient, BalatroError
21-
from balatrobot.enums import State
2222

2323
from .config import Config, load_model_config
2424
from .data_collection import ChatCompletionError, ChatCompletionResponse, StatsCollector
@@ -227,9 +227,10 @@ async def _make_llm_request_with_retries(
227227
request_id = str(time.time_ns() // 1_000_000)
228228
response = await self.llm_client.chat.completions.create(**request_data)
229229
self.responses.append(response)
230-
self.balatro_client.screenshot(
231-
self.data_collector.screenshot_dir / f"{custom_id}.png"
232-
)
230+
if self.config.take_screenshots:
231+
self.balatro_client.screenshot(
232+
self.data_collector.screenshot_dir / f"{custom_id}.png"
233+
)
233234
self.data_collector.write_response(
234235
id=str(time.time_ns() // 1_000_000),
235236
custom_id=custom_id,
@@ -399,7 +400,7 @@ async def _init_game(self, base_dir: Path = Path.cwd()) -> dict[str, Any]:
399400
"stake": self.config.stake,
400401
"seed": self.config.seed,
401402
"challenge": self.config.challenge,
402-
"log_path": self.data_collector.run_dir / "gamestates.jsonl",
403+
# "log_path": self.data_collector.run_dir / "gamestates.jsonl",
403404
}
404405

405406
return self.balatro_client.send_message("start_run", start_run_args)

src/balatrollm/cli.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ async def cmd_balatrollm(args) -> None:
5555
config = Config(
5656
model=args.model,
5757
strategy=args.strategy,
58+
take_screenshots=args.take_screenshots,
5859
)
5960

6061
# Parse seeds
@@ -149,6 +150,7 @@ async def _port_worker(
149150
model=config.model,
150151
strategy=config.strategy,
151152
seed=seed,
153+
take_screenshots=config.take_screenshots,
152154
)
153155

154156
# Create bot for this run
@@ -284,6 +286,12 @@ def _create_argument_parser() -> argparse.ArgumentParser:
284286
action="append",
285287
help="Port for BalatroBot client connection (can specify multiple, default: 12346)",
286288
)
289+
parser.add_argument(
290+
"--no-screenshot",
291+
action="store_false",
292+
dest="take_screenshots",
293+
help="Disable taking screenshots during gameplay",
294+
)
287295

288296
# Benchmark subcommand
289297
benchmark_parser = subparsers.add_parser(

src/balatrollm/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class Config:
7676
stake: Difficulty stake level (default: 1).
7777
seed: Game seed for reproducible runs (default: 'OOOO155').
7878
challenge: Optional challenge mode identifier.
79+
take_screenshots: Whether to take screenshots during gameplay (default: True).
7980
version: Software version string.
8081
name: Human-readable configuration name.
8182
description: Configuration description.
@@ -89,6 +90,7 @@ class Config:
8990
stake: int = 1
9091
seed: str = "OOOO155"
9192
challenge: str | None = None
93+
take_screenshots: bool = True
9294
version: str = __version__
9395
name: str = "Unknown Name"
9496
description: str = "Unknown Description"
@@ -109,6 +111,7 @@ def from_defaults(cls) -> "Config":
109111
stake=1,
110112
seed="OOOO155",
111113
challenge=None,
114+
take_screenshots=True,
112115
version="",
113116
name="Unknown Name",
114117
description="Unknown Description",

0 commit comments

Comments
 (0)