Skip to content

Commit b3a729b

Browse files
committed
docs: simplify the contributing guide
1 parent 0f6c1e6 commit b3a729b

File tree

1 file changed

+59
-169
lines changed

1 file changed

+59
-169
lines changed

docs/contributing.md

Lines changed: 59 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Before contributing, ensure you have:
3333
2. **Install Dependencies**
3434

3535
```bash
36-
uv sync --all-extras
36+
make install-dev
3737
```
3838

3939
3. **Start Balatro with Mods**
@@ -108,157 +108,90 @@ test(api): add shop booster validation tests
108108
109109
## Development & Testing
110110
111-
### Code Quality Tools
111+
### Makefile Commands
112112
113-
```bash
114-
# Python linting and formatting
115-
ruff check .
116-
ruff check --select I --fix .
117-
ruff format .
118-
119-
# Markdown formatting (docs and specific files)
120-
mdformat .
113+
BalatroBot includes a comprehensive Makefile that provides a convenient interface for all development tasks. Use `make help` to see all available commands:
121114
122-
# Type checking
123-
basedpyright
115+
```bash
116+
# Show all available commands with descriptions
117+
make help
124118
```
125119
126-
### Testing Requirements
127-
128-
!!! warning
129-
130-
All tests require Balatro to be running in the background. Use `./balatro.sh --status` to check if the game is running.
131-
132-
#### Single Instance Testing
120+
#### Installation & Setup
133121
134122
```bash
135-
# Start Balatro with default port (12346)
136-
./balatro.sh -p 12346
137-
138-
# Run all tests
139-
pytest
140-
141-
# Run specific test file
142-
pytest tests/lua/test_api_functions.py
143-
144-
# Run with verbose output and stop on first failure
145-
pytest -vx
146-
147-
# Run tests on specific port
148-
pytest --port 12347 tests/lua/endpoints/test_cash_out.py
123+
make install # Install package dependencies
124+
make install-dev # Install with development dependencies
149125
```
150126
151-
#### Parallel Testing with Multiple Balatro Instances
152-
153-
The test suite supports running tests in parallel across multiple Balatro instances. This dramatically reduces test execution time by distributing tests across multiple game instances.
154-
155-
**Setup for Parallel Testing:**
156-
157-
1. **Check existing instances and start multiple Balatro instances on different ports**:
158-
159-
```bash
160-
# First, check if any instances are already running
161-
./balatro.sh --status
162-
163-
# If you need to kill all existing instances first:
164-
./balatro.sh --kill
165-
```
166-
167-
```bash
168-
# Start two instances with a single command
169-
./balatro.sh -p 12346 -p 12347
170-
171-
# With performance optimizations for faster testing
172-
./balatro.sh --fast -p 12346
173-
174-
# Headless mode for server environments
175-
./balatro.sh --headless -p 12346
176-
177-
# Fast Headless mode on 4 instances (recommended configuration)
178-
./balatro.sh --headless --fast -p 12346 -p 12347 -p 12348 -p 12349
179-
```
180-
181-
2. **Run tests in parallel**:
182-
183-
```bash
184-
# Two workers (faster than single instance)
185-
pytest -n 2 --port 12346 --port 12347
186-
187-
# Four workers (recommended configuration)
188-
pytest -n 4 --port 12346 --port 12347 --port 12348 --port 12349
189-
```
190-
191-
**Benefits:**
127+
#### Code Quality & Formatting
192128
193-
- **Faster test execution**: ~4x speedup with 4 parallel workers
194-
- **Port isolation**: Each worker uses its dedicated Balatro instance
195-
196-
**Notes:**
129+
```bash
130+
make lint # Run ruff linter (check only)
131+
make lint-fix # Run ruff linter with auto-fixes
132+
make format # Run ruff formatter
133+
make format-md # Run markdown formatter
134+
make typecheck # Run type checker
135+
make quality # Run all code quality checks
136+
make dev # Quick development check (format + lint + typecheck, no tests)
137+
```
197138
198-
- Each Balatro instance must be running on a different port before starting tests
199-
- Tests automatically distribute across available workers
200-
- Monitor logs for each instance: `tail -f logs/balatro_12346.log`
201-
- Logs are automatically created in the `logs/` directory with format `balatro_PORT.log`
139+
### Testing Requirements
202140
203-
**balatro.sh Command Options:**
141+
#### Testing with Makefile
204142
205143
```bash
206-
# Usage examples
207-
./balatro.sh -p 12347 # Start single instance on port 12347
208-
./balatro.sh -p 12346 -p 12347 # Start two instances on ports 12346 and 12347
209-
./balatro.sh --headless --fast -p 12346 # Start with headless and fast mode
210-
./balatro.sh --kill # Kill all running Balatro instances
211-
./balatro.sh --status # Show running instances
144+
make test # Run tests with single instance (auto-starts if needed)
145+
make test-parallel # Run tests on 4 instances (auto-starts if needed)
146+
make test-teardown # Kill all Balatro instances
147+
make test-verbose # Run tests with verbose output
148+
make coverage # Generate test coverage reports
149+
150+
# Complete workflow including tests
151+
make all # Run format + lint + typecheck + test
212152
```
213153
214-
**balatro.sh Modes:**
215-
216-
- **`--headless`**: Enable headless mode (sets `BALATROBOT_HEADLESS=1`)
154+
The testing system automatically handles Balatro instance management:
217155
218-
- Minimizes and hides game window
219-
- Completely disables Love2D graphics operations
220-
- Minimal CPU/GPU usage for pure game logic execution
221-
- Ideal for server environments and cloud-based bot training
156+
- **`make test`**: Runs tests with a single instance, auto-starting if needed
157+
- **`make test-parallel`**: Runs tests on 4 instances for ~4x speedup, auto-starting if needed
158+
- **`make test-teardown`**: Cleans up all instances when done
222159
223-
- **`--fast`**: Enable fast mode (sets `BALATROBOT_FAST=1`)
160+
Both test commands keep instances running after completion for faster subsequent runs.
224161
225-
- Unlimited FPS, 10x game speed, 6x faster animations
226-
- Disabled shadows, bloom, CRT effects, VSync
227-
- Complete audio muting
228-
- Optimized for maximum execution speed during bot training
229-
230-
**Test Prerequisites and Workflow:**
162+
**Manual Setup for Advanced Testing:**
231163
232164
```bash
233-
# 1. Check if Balatro instances are already running
234-
./balatro.sh --status
235-
236-
# 2. If instances are running on needed ports, you can proceed with testing
237-
# If you need to kill all running instances and start fresh:
238-
./balatro.sh --kill
165+
# Check/manage Balatro instances
166+
./balatro.sh --status # Show running instances
167+
./balatro.sh --kill # Kill all instances
239168
240-
# 3. Start the required instances
241-
./balatro.sh --headless --fast -p 12346 -p 12347 -p 12348 -p 12349
169+
# Start instances manually
170+
./balatro.sh -p 12346 -p 12347 # Two instances
171+
./balatro.sh --headless --fast -p 12346 -p 12347 -p 12348 -p 12349 # Full setup
242172
243-
# 4. Run parallel tests
173+
# Manual parallel testing
244174
pytest -n 4 --port 12346 --port 12347 --port 12348 --port 12349 tests/lua/
245175
```
246176
247-
**Troubleshooting Test Failures**:
177+
**Performance Modes:**
248178
249-
- **Connection timeouts**: Ensure TCP port 12346 is available
250-
- **Game state errors**: Verify the game is responsive and hasn't crashed
251-
- **Invalid responses**: Check the mod loaded correctly in `balatro.log`
252-
- **Balatro crashes**: Stop testing immediately, investigate crash logs, restart the game before retrying
179+
- **`--headless`**: No graphics, ideal for servers
180+
- **`--fast`**: 10x speed, disabled effects, optimal for testing
253181
254182
### Documentation
255183
256184
```bash
257-
# Serve documentation locally
258-
mkdocs serve
185+
make docs-serve # Serve documentation locally
186+
make docs-build # Build documentation
187+
make docs-clean # Clean built documentation
188+
```
259189
260-
# Build documentation
261-
mkdocs build
190+
### Build & Maintenance
191+
192+
```bash
193+
make build # Build package for distribution
194+
make clean # Clean build artifacts and caches
262195
```
263196
264197
## Technical Guidelines
@@ -277,56 +210,13 @@ mkdocs build
277210
- **Communication**: TCP protocol on port 12346
278211
- **Debugging**: Use DebugPlus mod for enhanced debugging capabilities
279212
280-
### Configuration System
281-
282-
The BalatroBot mod includes a sophisticated configuration system that optimizes Balatro for bot automation:
283-
284-
#### Environment Variables
285-
286-
Configure BalatroBot behavior using these environment variables:
287-
288-
- **`BALATROBOT_HEADLESS`**: Set to `"1"` to enable headless mode (no graphics rendering)
289-
- **`BALATROBOT_FAST`**: Set to `"1"` to enable fast mode (10x game speed, disabled visuals)
290-
- **`BALATROBOT_PORT`**: TCP port for communication (default: "12346")
291-
292-
#### Fast Mode Configuration
293-
294-
Fast mode (`BALATROBOT_FAST=1`) applies aggressive optimizations for bot training:
295-
296-
- **Performance**: Unlimited FPS, 10x game speed, 6x faster animations
297-
- **Graphics**: Disabled shadows, bloom, CRT effects, VSync, texture scaling set to nearest neighbor
298-
- **Audio**: Complete audio muting (volume, music, game sounds)
299-
- **Visual Effects**: Disabled motion blur, screen shake, rumble effects
300-
- **Resource Usage**: Optimized for maximum execution speed
301-
302-
#### Normal Mode Configuration
303-
304-
Normal mode preserves standard game experience while maintaining bot compatibility:
305-
306-
- **Performance**: 60 FPS cap, normal game speed, standard animations
307-
- **Graphics**: Full visual quality with shadows, bloom, and CRT effects enabled
308-
- **Audio**: Standard audio levels (50% main volume, 100% music/sounds)
309-
- **Visual Effects**: Normal motion and screen effects enabled
310-
311-
#### Headless Mode Configuration
312-
313-
Headless mode (`BALATROBOT_HEADLESS=1`) disables all graphics for server environments:
314-
315-
- **Window Management**: Minimizes and hides game window
316-
- **Rendering**: Completely disables Love2D graphics operations
317-
- **Resource Usage**: Minimal CPU/GPU usage for pure game logic execution
318-
- **Server Deployment**: Ideal for cloud-based bot training
319-
320-
#### Implementation Details
321-
322-
The configuration system is implemented in `src/lua/settings.lua` and provides:
213+
### Environment Variables
323214
324-
- **Environment Detection**: Reads environment variables on mod initialization
325-
- **Love2D Patches**: Modifies game engine behavior for performance optimization
326-
- **Balatro Integration**: Configures game-specific settings through global variables
327-
- **Fallback Handling**: Graceful degradation when graphics context is unavailable
215+
Configure BalatroBot behavior with these environment variables:
328216
329-
This configuration system enables BalatroBot to run efficiently in diverse environments, from local development with full graphics to high-performance server deployments with headless operation.
217+
- **`BALATROBOT_HEADLESS=1`**: Disable graphics for server environments
218+
- **`BALATROBOT_FAST=1`**: Enable 10x speed with disabled effects for testing
219+
- **`BALATROBOT_PORT`**: TCP communication port (default: "12346")
330220
331221
## Communication & Community
332222

0 commit comments

Comments
 (0)