Skip to content

Commit 0d47320

Browse files
committed
feat: add --use-default-paths flag to use balatrobot's default storage paths
1 parent bc0c87c commit 0d47320

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

src/balatrollm/bot.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,12 @@ async def _make_llm_request_with_retries(
228228
response = await self.llm_client.chat.completions.create(**request_data)
229229
self.responses.append(response)
230230
if self.config.take_screenshots:
231-
self.balatro_client.screenshot(
232-
self.data_collector.screenshot_dir / f"{custom_id}.png"
233-
)
231+
if self.config.use_default_paths:
232+
self.balatro_client.screenshot(None)
233+
else:
234+
self.balatro_client.screenshot(
235+
self.data_collector.screenshot_dir / f"{custom_id}.png"
236+
)
234237
self.data_collector.write_response(
235238
id=str(time.time_ns() // 1_000_000),
236239
custom_id=custom_id,
@@ -400,9 +403,14 @@ async def _init_game(self, base_dir: Path = Path.cwd()) -> dict[str, Any]:
400403
"stake": self.config.stake,
401404
"seed": self.config.seed,
402405
"challenge": self.config.challenge,
403-
"log_path": self.data_collector.run_dir / "gamestates.jsonl",
404406
}
405407

408+
# Only include log_path if not using default paths
409+
if not self.config.use_default_paths:
410+
start_run_args["log_path"] = (
411+
self.data_collector.run_dir / "gamestates.jsonl"
412+
)
413+
406414
return self.balatro_client.send_message("start_run", start_run_args)
407415

408416
async def _run_game_loop(self, game_state: dict[str, Any]) -> None:

src/balatrollm/cli.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ async def cmd_balatrollm(args) -> None:
5656
model=args.model,
5757
strategy=args.strategy,
5858
take_screenshots=args.take_screenshots,
59+
use_default_paths=args.use_default_paths,
5960
)
6061

6162
# Parse seeds
@@ -151,6 +152,7 @@ async def _port_worker(
151152
strategy=config.strategy,
152153
seed=seed,
153154
take_screenshots=config.take_screenshots,
155+
use_default_paths=config.use_default_paths,
154156
)
155157

156158
# Create bot for this run
@@ -292,6 +294,11 @@ def _create_argument_parser() -> argparse.ArgumentParser:
292294
dest="take_screenshots",
293295
help="Disable taking screenshots during gameplay",
294296
)
297+
parser.add_argument(
298+
"--use-default-paths",
299+
action="store_true",
300+
help="Use BalatroBot's default storage paths for screenshots and game logs",
301+
)
295302

296303
# Benchmark subcommand
297304
benchmark_parser = subparsers.add_parser(

src/balatrollm/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class Config:
7777
seed: Game seed for reproducible runs (default: 'OOOO155').
7878
challenge: Optional challenge mode identifier.
7979
take_screenshots: Whether to take screenshots during gameplay (default: True).
80+
use_default_paths: Whether to use BalatroBot's default storage paths (default: False).
8081
version: Software version string.
8182
name: Human-readable configuration name.
8283
description: Configuration description.
@@ -91,6 +92,7 @@ class Config:
9192
seed: str = "OOOO155"
9293
challenge: str | None = None
9394
take_screenshots: bool = True
95+
use_default_paths: bool = False
9496
version: str = __version__
9597
name: str = "Unknown Name"
9698
description: str = "Unknown Description"
@@ -112,6 +114,7 @@ def from_defaults(cls) -> "Config":
112114
seed="OOOO155",
113115
challenge=None,
114116
take_screenshots=True,
117+
use_default_paths=False,
115118
version="",
116119
name="Unknown Name",
117120
description="Unknown Description",

0 commit comments

Comments
 (0)