
I got tired of writing scripts for every edge case, so I built an AI agent that reads the full game state every 60 seconds and decides what to do next — buy programs, deploy hacks, commit crimes, manage sleeves, join factions. It runs on a local Ollama instance (Llama 3.1 8B on a Jetson in my case, but any Ollama host works).
What it actually does:
The AI receives your complete game state as structured JSON — hack level, money, server fleet, gang info, bladeburner status, augmentations, faction rep, running scripts — and returns 1-5 action commands per cycle. Each action maps to a real NS Singularity call. It doesn't just suggest — it executes.
The safety rails are the interesting part.
Every action the AI proposes passes through a validator before execution. It can't install augmentations with fewer than 5 pending (wasteful reset). It can't spend more than 90% of your cash in one cycle. It can't soft reset without a confirmation file. It can't kill scripts or delete files. Blocked actions are logged with the reason. The AI also gets its previous action results fed back each cycle, so it learns from failures — if the safety rail blocks an upgrade_server three times in a row because of cash reserve, it eventually pivots to something else.
You can see it working in the screenshots — the AI kept trying to upgrade a server to 8 TB but the cash reserve safety rail blocked it every time (SKIP: upgrade_server would violate cash reserve). That's the system working as intended.
The stack:
scb.js is the master orchestrator — one script to run everything. It handles scanning, rooting, parallel backdooring, TOR/program auto-purchasing, incremental server upgrades, and companion script launching. The Ollama player is a spawned child process that handles strategy while scb.js handles infrastructure.
There's also a watchdog (scb-watchdog.js) that monitors the Ollama connection, auto-reconnects when it drops, and can hot-reload scb.js when you save changes through bitburner-filesync.
Flip any flag to disable a feature. The Ollama player has its own config for backend (ollama or claude), host, model, poll interval, and safety limits.
What I'm not claiming:
This won't optimally speedrun a BitNode. A well-tuned autopilot.js with hardcoded heuristics will outperform it on pure efficiency. What this does is make the game playable while you're AFK without writing a specific script for every situation. The AI adapts to whatever state it finds — early game, mid game, post-aug, new BitNode.
Repo: github.com/Subzero121800/BitBurner-AI
MIT licensed. PRs welcome. If you have a local Ollama instance running, you can be up in under 5 minutes.