Go to file
angelvalentin80 6e22f37716 updating README for public 2025-12-14 12:57:37 -05:00
RLBridge adding replay system. just a json file lol 2025-08-08 10:00:22 -04:00
ai adding final updates 2025-09-02 16:41:13 -04:00
.gitignore Have a successful pipe communication between AI and balatro with some intial iteration going 2025-07-19 17:02:15 -04:00
CLAUDE.md used debugger to iron out all the bugs step by step. things are looking way smoother 2025-08-06 20:50:02 -04:00
LICENSE Add MIT License to the project 2025-12-14 12:21:06 -05:00
README.md updating README for public 2025-12-14 12:57:37 -05:00
replays.json adding final updates 2025-09-02 16:41:13 -04:00

README.md

Balatro RL

A reinforcement learning agent that plays Balatro using a custom mod and Python training environment.

Overview

This project combines a Balatro mod (RLBridge) with a Python reinforcement learning environment to train an AI agent to play Balatro. The mod extracts game state information and executes actions from the RL agent via a dual-pipe communication system.

Features

  • Game State Extraction: Reads hand cards, chips, available hands/discards, and other game state data
  • Action Execution: AI can play hands, discard cards, select hands
  • Dual-pipe Communication: Request/response system using named pipes for real-time communication
  • Replay System: Automatically saves winning games with top 10 highest chip score
  • Custom Reward Function: Rewards efficient play, complex hands, and winning rounds
  • Automated Training: Runs automatically start new games after wins/losses

Installation

Prerequisites

  • Balatro (Steam version)
  • Lovely Injector for mod injection
  • Python 3.8+ with dependencies (requirements.txt)

Setup

  1. Install Lovely Injector following their instructions
  2. Install Python dependencies: pip install -r requirements.txt
  3. Launch Balatro with Lovely Injector enabled (more details in lovely-injector docs)
  4. Run the Python training script: python -m ai.train_balatro

Architecture

  • RLBridge Mod: Lua mod using Lovely's patching system to hook into game state
  • Named Pipes: Dual-pipe system (/tmp/balatro_request, /tmp/balatro_response) for communication.
  • Python Environment: Custom Gym environment for RL training
  • Replay System: JSON-based storage of winning game sequences

Future Work

  • Explore training parallelization (possibly via Docker/multiple instances)

Development Notes (Personal)

Symlink for development (Arch Linux with Proton):

ln -s ~/dev/balatro-rl/RLBridge /mnt/gamerlinuxssd/SteamLibrary/steamapps/compatdata/2379780/pfx/drive_c/users/steamuser/AppData/Roaming/Balatro/Mods/RLBridge