Skip to content

Commit 60363e3

Browse files
committed
docs: improve docs and fix inconsistencies
Closes #62
1 parent ca44aef commit 60363e3

3 files changed

Lines changed: 99 additions & 37 deletions

File tree

docs/cli.md

Lines changed: 82 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,66 @@ This means CLI flags override config file values, which override environment var
2828

2929
```bash
3030
export BALATROLLM_CONFIG="config/example.yaml"
31-
balatrollm --model openai/gpt-5
31+
balatrollm
3232
```
3333

3434
This is the **only** `BALATROLLM_*` environment variable that does not have a corresponding CLI flag — the user can simply provide the config file path as a positional argument instead.
3535

3636
**Precedence:** If both the `CONFIG` argument and `BALATROLLM_CONFIG` are provided, the CLI argument takes precedence and `BALATROLLM_CONFIG` is ignored.
3737

38+
## Configuration file (YAML)
39+
40+
The YAML configuration file uses the same field names as the CLI flags (minus the `--`), for example:
41+
42+
- CLI `--model` → YAML `model`
43+
- CLI `--base-url` → YAML `base_url`
44+
45+
For a full annotated example, see [`config/example.yaml`](https://github.com/coder/balatrollm/blob/main/config/example.yaml).
46+
47+
### `model` (required)
48+
49+
`model` is required, but it can come from **any** config source (YAML config, env var, or CLI flag). If you set `model:` in your YAML file, you do not need to also pass `--model`.
50+
51+
```yaml
52+
model:
53+
- openai/gpt-4o
54+
```
55+
56+
### `model_config` (advanced)
57+
58+
The YAML file also supports an optional `model_config` mapping for advanced provider/model request knobs. BalatroLLM deep-merges your `model_config` into built-in defaults (including nested fields like `extra_headers` and `extra_body`) and then passes the result directly to the OpenAI-compatible chat completions request.
59+
60+
Common examples include `temperature`, `max_tokens`, `seed`, `parallel_tool_calls`, `tool_choice`, plus provider-specific settings via `extra_body` (e.g., OpenRouter).
61+
62+
```yaml
63+
model_config:
64+
temperature: 0.2
65+
max_tokens: 2048
66+
extra_body:
67+
reasoning:
68+
effort: medium
69+
```
70+
3871
## Options
3972

40-
| CLI Flag | Environment Variable | Default | Description |
41-
| --------------------- | --------------------- | ------------------------------ | ---------------------------- |
42-
| `--model MODEL` | `BALATROLLM_MODEL` | *(required)* | LLM model(s) to use |
43-
| `--seed SEED` | `BALATROLLM_SEED` | `AAAAAAA` | Game seed(s) |
44-
| `--deck DECK` | `BALATROLLM_DECK` | `RED` | Deck code(s) |
45-
| `--stake STAKE` | `BALATROLLM_STAKE` | `WHITE` | Stake code(s) |
46-
| `--strategy STRATEGY` | `BALATROLLM_STRATEGY` | `default` | Strategy name(s) |
47-
| `--parallel N` | `BALATROLLM_PARALLEL` | `1` | Concurrent game instances |
48-
| `--host HOST` | `BALATROLLM_HOST` | `127.0.0.1` | BalatroBot host |
49-
| `--port PORT` | `BALATROLLM_PORT` | `12346` | Starting port |
50-
| `--base-url URL` | `BALATROLLM_BASE_URL` | `https://openrouter.ai/api/v1` | LLM API base URL |
51-
| `--api-key KEY` | `BALATROLLM_API_KEY` | *None* | LLM API key |
52-
| `--views` | `BALATROLLM_VIEWS` | `False` | Enable views HTTP server |
53-
| `--dry-run` | - | `False` | Show tasks without executing |
73+
| CLI Flag | Environment Variable | Default | Description |
74+
| --------------------- | --------------------- | ------------------------------ | --------------------------------------------------- |
75+
| `--model MODEL` | `BALATROLLM_MODEL` | *(required)* | LLM model(s) to use (or set `model:` in YAML) |
76+
| `--seed SEED` | `BALATROLLM_SEED` | `AAAAAAA` | Game seed(s) |
77+
| `--deck DECK` | `BALATROLLM_DECK` | `RED` | Deck code(s) |
78+
| `--stake STAKE` | `BALATROLLM_STAKE` | `WHITE` | Stake code(s) |
79+
| `--strategy STRATEGY` | `BALATROLLM_STRATEGY` | `default` | Strategy name(s) |
80+
| `--parallel N` | `BALATROLLM_PARALLEL` | `1` | Concurrent game instances |
81+
| `--host HOST` | `BALATROLLM_HOST` | `127.0.0.1` | BalatroBot host |
82+
| `--port PORT` | `BALATROLLM_PORT` | `12346` | Starting port |
83+
| `--base-url URL` | `BALATROLLM_BASE_URL` | `https://openrouter.ai/api/v1` | LLM API base URL |
84+
| `--api-key KEY` | `BALATROLLM_API_KEY` | *None* | LLM API key |
85+
| `--views` | `BALATROLLM_VIEWS` | `False` | Enable views HTTP server (set `BALATROLLM_VIEWS=1`) |
86+
| `--dry-run` | - | `False` | Show tasks without executing |
87+
88+
!!! note "How Balatro instances are started"
89+
90+
`balatrollm` starts/stops Balatro instances automatically via `balatrobot`. With `--parallel N`, it spawns instances on ports `--port` through `--port + N - 1` (`port..port+parallel-1`).
5491

5592
!!! note "Multiple Values"
5693

@@ -74,7 +111,7 @@ balatrollm config/example.yaml
74111
75112
# Run with configuration file via environment variable
76113
export BALATROLLM_CONFIG="config/example.yaml"
77-
balatrollm --model openai/gpt-5
114+
balatrollm
78115
79116
# Run with config file and override specific options
80117
balatrollm config/example.yaml --model openai/gpt-5 --seed BBBBBBB
@@ -97,6 +134,9 @@ balatrollm --model openai/gpt-4o --strategy my_custom_strategy
97134
98135
# Enable views overlay on port 12345
99136
balatrollm --model openai/gpt-4o --views
137+
138+
# Enable views overlay via environment variable (0/1)
139+
BALATROLLM_VIEWS=1 balatrollm --model openai/gpt-4o
100140
# Access views at:
101141
# http://localhost:12345/views/task.html
102142
# http://localhost:12345/views/responses.html
@@ -108,6 +148,32 @@ balatrollm --model openai/gpt-4o --views
108148

109149
For more information about strategies, see the [Strategies documentation](strategies.md).
110150

151+
## Run artifacts / outputs
152+
153+
`balatrollm` writes run artifacts to `./runs/` (relative to your current working directory).
154+
155+
```text
156+
runs/
157+
latest.json
158+
vX.Y.Z/<strategy>/<vendor>/<model>/<timestamp>_<deck>_<stake>_<seed>/
159+
task.json
160+
strategy.json
161+
run.log
162+
requests.jsonl
163+
responses.jsonl
164+
gamestates.jsonl
165+
stats.json
166+
screenshots/
167+
```
168+
169+
- `task.json` / `strategy.json`: resolved task metadata and the strategy manifest used for the run.
170+
- `requests.jsonl` / `responses.jsonl`: LLM requests and responses (JSONL, one object per line).
171+
- `gamestates.jsonl`: game state snapshots after each action.
172+
- `stats.json`: aggregated statistics for the run.
173+
- `screenshots/`: screenshots captured during the run.
174+
- `run.log`: logs captured during the run.
175+
- `runs/latest.json`: updated each run; used by the `--views` overlays to locate the latest `task.json` and `responses.jsonl`.
176+
111177
## BalatroBot Configuration
112178

113179
BalatroBot instances spawned by BalatroLLM can be configured through `BALATROBOT_*` environment variables. These settings control how Balatro runs during automated gameplay.

docs/contributing.md

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,15 @@ We use [direnv](https://direnv.net/) to automatically manage environment variabl
1919

2020
The `.envrc` file may contain API keys. **Never commit this file**.
2121

22-
**Example `.envrc` configuration:**
22+
Start from the versioned template:
2323

2424
```bash
25-
# Load the virtual environment
26-
source .venv/bin/activate
27-
28-
# Python-specific variables
29-
export PYTHONUNBUFFERED="1"
30-
export PYTHONPATH="${PWD}/src:${PYTHONPATH}"
31-
export PYTHONPATH="${PWD}/tests:${PYTHONPATH}"
32-
33-
# BALATROBOT env vars
34-
export BALATROBOT_FAST=1
35-
export BALATROBOT_DEBUG=1
36-
export BALATROBOT_RENDER_ON_API=0
37-
export BALATROBOT_HEADLESS=0
38-
39-
# BALATROLLM env vars
40-
export BALATROLLM_API_KEY="sk-..."
41-
export BALATROLLM_BASE_URL="https://openrouter.ai/api/v1"
25+
cp .envrc.example .envrc
26+
direnv allow
4227
```
4328

29+
Then edit `.envrc` and set at minimum `BALATROLLM_API_KEY` (and `BALATROLLM_MODEL` if you aren't providing a YAML config or `--model`).
30+
4431
## Development Setup
4532

4633
### 1. Clone the Repository

docs/strategies.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ Defines the function calls available to the LLM during different game phases. Th
188188

189189
### Available Game States
190190

191-
Tools are organized by game state. The `TOOLS.json` file maps each state to its available tools:
191+
Tools are organized by game state. The `TOOLS.json` file maps each state to its available tools.
192192

193193
| Game State | Description | Available Tools |
194194
| ---------------------- | --------------------- | --------------------------------------------------------- |
@@ -197,6 +197,15 @@ Tools are organized by game state. The `TOOLS.json` file maps each state to its
197197
| `BLIND_SELECT` | Blind selection phase | `select`, `skip` |
198198
| `SMODS_BOOSTER_OPENED` | Pack opening phase | `pack` (select cards or skip) |
199199

200+
!!! note "BLIND_SELECT and ROUND_EVAL Behavior"
201+
202+
The current `balatrollm` bot loop does not delegate `BLIND_SELECT` or `ROUND_EVAL` to the LLM (see `src/balatrollm/bot.py`).
203+
204+
- `ROUND_EVAL` always calls `cash_out`
205+
- `BLIND_SELECT` always calls `select` (never `skip`) because Tags are not supported yet by `balatrobot`; skipping blinds would collect Tags the bot can't use
206+
207+
This "always play the blind" policy is a reasonable baseline for `RED` deck on `WHITE` stake.
208+
200209
### Common Tools
201210

202211
**SELECTING_HAND phase:**
@@ -219,7 +228,7 @@ Tools are organized by game state. The `TOOLS.json` file maps each state to its
219228
**BLIND_SELECT phase:**
220229

221230
- `select`: Select a blind to play
222-
- `skip`: Skip the current blind (if allowed)
231+
- `skip`: Skip the current blind (if allowed). *(Currently not used by `balatrollm`; Tag handling isn’t supported yet.)*
223232

224233
## Strategy Validation
225234

@@ -281,7 +290,7 @@ Common issues:
281290
1. Fork the BalatroLLM repository
282291
2. Create a feature branch: `git checkout -b feat/add-strategy-your_strategy_name`
283292
3. Add your strategy directory with all required files
284-
4. Commit following conventional commits: `feat: add [strategy_name] strategy`
293+
4. Commit following conventional commits: `feat(strategy): add [strategy_name] strategy`
285294
5. Open a pull request with:
286295
- Clear title describing your strategy
287296
- Brief description of the strategy's approach

0 commit comments

Comments
 (0)