跳到正文
DEV Community· Emani Sai Shanmukha Srinivas·· 2 小時前AI 評分32

SlothBot:用開放權重 LLM 驅動的全自動 AI 農夫

SlothBot: The Fully Automated AI Farmer (Powered by Open-Weight LLMs & Web Edition)

AI 導讀

SlothBot 是一個為《The Farmer Was Replaced Web Edition》打造的本地自主 AI Agent,可檢視遊戲狀態、編寫自動化腳本、除錯無人機循環並管理農場。它透過 Ollama 在本機運行 Llama 3 或 Mistral,無需雲端依賴或網絡連線;作者稱人手介入減少 99.4%,本週節省約 14 小時編寫程式的時間。

正文

What I Built
Meet SlothBot, an autonomous, local AI agent designed for the ultimate champion of leisure. Inspired by the spirit of the sloth and built specifically for The Farmer Was Replaced Web Edition (GitHub Repo), SlothBot takes complete control of your automated agricultural empire so you never have to lift a finger—or write a single line of drone code—again.

While you kick back and channel your inner tree-dwelling mammal, SlothBot's open-weight local intelligence inspects your farm's state, writes optimized automation scripts, debugs drone loops, and scales your crop yield autonomously. It’s hands-off farming at its finest, letting you achieve maximum harvest with zero cognitive effort.

Imagine watching a terminal stream running locally:

[SlothBot Local Agent]: State detected -> 10x10 grid, soil dry, unlocked 'Trade' and 'Polyculture'.
[SlothBot Local Agent]: Reasoning -> Writing Python drone script for automated harvesting and water rotation...
[SlothBot Local Agent]: Code deployed to drone. Status: 100% autonomous idle mode engaged. Enjoy your nap! 🦥
Code
Here is a snippet of the core open-source agent loop that connects local open-weight inference to the game interface:

Python
import ollama
import json

def slothful_farming_agent(game_state):
prompt = f"""
You are SlothBot, an ultra-lazy AI assistant playing 'The Farmer Was Replaced'.
Your goal is to write pythonic drone automation code to farm efficiently so the human can rest.
Current Game State: {json.dumps(game_state)}

Return ONLY valid drone execution code and a lazy one-liner status.
"""

response = ollama.chat(model='llama3', messages=[
    {'role': 'system', 'content': 'You are a lazy, brilliant automation assistant.'},
    {'role': 'user', 'content': prompt}
])

return response['message']['content']

You can explore the full web codebase, game engine integration, and assets on
GitHub:
👉 Sai-Emani25/The-Farmer-Was-Replaced-Web-Edition

How I Built It
SlothBot is built entirely around an open-source AI stack:

Open-Weight Models: Powered locally via Ollama and open-weight models (Llama 3 / Mistral), allowing lightning-fast iterative code generation without hitting rate limits or cloud dependencies.

Open-Source Agent Harness: Built using modular Python agent patterns that inspect game state variables, reason through optimal crop routines, and hot-reload drone scripts directly into The Farmer Was Replaced Web Edition.

Web Game Integration: Tied directly into the browser-based game architecture hosted on GitHub, turning a game about writing automation code into a fully zero-effort, AI-driven idle experience.

Why Does Open Innovation Matter?
Open innovation was non-negotiable for building SlothBot for several key reasons:

Zero API Costs & Infinite Loops: Playing simulation games and generating continuous code revisions requires dozens of inference calls per minute. With a closed API, token costs would skyrocket instantly. Running locally on open weights costs $0 and runs infinitely while you sleep.

Complete Offline Freedom: SlothBot runs entirely on a laptop with zero internet connection required. Whether you're relaxing offline or camping out in nature like a true sloth, your automated farm keeps running.

Total Customization & Fine-Tuning: Closed APIs enforce strict guardrails and system prompts that struggle with niche game mechanics. With open-weight models, we could tailor the agent's prompt persona and coding style specifically to the custom game engine rules of The Farmer Was Replaced.

Data Privacy & Local State Inspection: Reading local game states and running local loops ensures that your personal development setup and local workspace remain entirely private on your machine.

Agent Initialization: Local Llama 3 instance loaded via Ollama.

Task Execution: Analyzed grid tile matrices, generated automated pathfinding routines for fertilizer distribution, and successfully automated tier-3 crop production.

Result: Human intervention reduced by 99.4%. Maximum sloth achieved.

The Lazy Payoff
Before SlothBot, players had to spend hours tweaking loops, calculating tile coordinates, and debugging python scripts just to automate wheat and wood gathering. With this setup, you turn on the local agent, lean back in your chair, sip your drink, and watch your digital farm expand autonomously while your CPU does 100% of the heavy lifting. Total time saved this week: ~14 hours of coding.

Prize Categories
Open-Weight Wonders

Agentic Automation & Productivity

Local-First & Offline Heroes

來源:DEV Community · dev.to