AI Player

by ob_105

Adds an autonomous AI player that uses LM Studio/Open ai to play Factorio. The AI can build, mine, craft, fight, and interact with the world.

Utilities
a month ago
2.0
593
Logistics Combat Character Enemies Logistic network Manufacturing
Owner:
ob_105
Source:
N/A
Homepage:
https://mods.factorio.com/mod/ai-player
License:
MIT
Created:
a month ago
Latest Version:
0.1.2 (a month ago)
Factorio version:
2.0
Downloaded by:
593 users

Warning I will not continue working on this mod as I have realized how much of a challenge it is and I am not ready for that It is still functional but it's not great. Multiplayer does not work and I never have plans to make it work

Quick Start Guide - AI Player Mod

Setup (5 minutes)

Step 1: Install LM Studio

  1. Download LM Studio from https://lmstudio.ai/
  2. Install and launch LM Studio
  3. In LM Studio, download the Qwen3-VL-4B model
  4. Click "Start Server" (usually on port 1234)
  5. Load the Qwen3-VL-4B model in the server

Step 2: Start the Bridge

Run the Start_bridge.VBS. This will create and install the necessary files.
Or you can run it manually As shown below.

Windows (PowerShell):

python -m pip install requests factorio-rcon
python lm_studio_bridge.py

macOS/Linux:

python3 -m pip install requests factorio-rcon
python3 lm_studio_bridge.py

Keep the terminal window open — it bridges Factorio to LM Studio via RCON. You should see "Bridge is running. Waiting for requests...".

Step 3: Launch Factorio

  1. Start Factorio
  2. Enable the "AI Player" mod if not already enabled
  3. Start or load a game (single-player or multiplayer with RCON enabled)

Step 4: Spawn the AI

  1. Open console with ~ key (tilde)
  2. Type: /spawn-ai-player
  3. Press Enter

What to Expect

The AI player will:
- Appear as a separate character in your world
- Start exploring and gathering resources
- Mine trees, rocks, and ore deposits
- Build basic structures
- Defend itself from enemies
- Occasionally chat about its status

Console Commands

Command Description
/spawn-ai-player Create/reset the AI player
/remove-ai-player Remove the AI player
/goto-ai-player Teleport to the AI's location

Troubleshooting

AI isn't moving:
- Check the bridge script is running
- Verify LM Studio server is active (green indicator)
- Check console for error messages

Bridge shows errors:
- Ensure LM Studio is running on port 1234
- Check the model is loaded in LM Studio
- Verify Python and requests library are installed

AI keeps dying:
- Enable auto-respawn in mod settings
- Give the AI some starting defenses
- Clear enemies near spawn point

Performance issues:
- Increase tick interval in mod settings (Settings → Mod Settings → Map)
- Reduce vision radius
- Lower LM Studio's token limit

Advanced Configuration

Edit mod settings in-game:
1. Settings → Mod Settings → Map
2. Find "AI Player" section
3. Adjust:
- Tick interval (higher = slower but less lag)
- Vision radius (lower = less data, faster)
- Enable/disable chat
- Auto-respawn setting

Tips

  1. Watch the AI learn: Use /goto-ai-player to follow it around
  2. Help the AI: Drop resources near it to speed up progress
  3. Team play: The AI is friendly with players by default
  4. Multiple AIs: You can spawn multiple instances (edit global.ai_player table)

Next Steps

  • Customize the AI's goals by editing the system prompt in scripts/ai_brain.lua
  • Add new actions in scripts/ai_actions.lua
  • Modify starting items in scripts/ai_character.lua
  • Adjust perception detail in scripts/ai_perception.lua

Need Help?

  • Check README.md for detailed documentation
  • Review Factorio log file for errors
  • Ensure all files are in the correct mod directory
  • Verify Factorio version compatibility (2.0+)

Enjoy watching your AI player build a factory!