The Farmer Was Replaced Guide: Coding Basics, Automation Scripts, and Achievements

Official The Farmer Was Replaced screenshot showing a farm grid and code editor

The Farmer Was Replaced is a programming game disguised as a farm. The early minutes ask you to harvest grass and plant bushes, but the real challenge is learning how to turn a small drone into a reliable worker: one that can cross the whole field, react to resources, sort crops, manage several drones, solve mazes, and eventually reset the entire tech tree on a leaderboard run.

This guide is written for players who want a practical route from “my first loop” to achievement cleanup. It does not republish full community scripts. Instead, it explains the mechanics behind those scripts, the unlock order that makes them useful, the common mistakes that waste hours, and the achievement groups you should clean up before chasing leaderboards.

Official The Farmer Was Replaced screenshot showing a farm grid and code editor
The main loop is simple: read the tile, do the safest useful action, move, repeat. The hard part is making that loop survive every crop, unlock, and drone race condition.

Best Article Route: Beginner Guide Plus Achievement Cleanup

The Farmer Was Replaced is not a level-by-level walkthrough. Steam and the official press kit describe a continuous progression game where farming earns resources, resources unlock technology, and better code opens harder optimization problems. That means the best guide shape is a beginner-to-completion guide: learn stable script patterns first, then use those patterns for crop grinds, special mechanics, and the 59 Steam achievements.

Phase Main Goal Code Habit To Build Achievements You Usually Touch
First field Harvest grass, plant bushes, expand the farm. Use one infinite loop with a predictable movement pattern. Hello World, Infinite Loop, It Grew, Bushes, Hay Farmer, Wood Farmer.
Soil crops Unlock tilling, carrots, trees, pumpkins, water, and basic sensing. Check ground type before planting and inventory before trading. Carrots, Trees, Pumpkins, Carrot Farmer, Pumpkin Farmer, Mud Farm.
Midgame wall Handle cactus sorting, sunflower power, fertilizer, mazes, and weird substance. Write small helper functions and test them on one row before scaling. Cacti, Cactus Farmer, Sunflowers, Power Farmer, Maze, Treasure Hunter, Gold Farmer.
Late game Use multiple drones, hats, polyculture, dinosaur routes, and full-field builds. Coordinate workers, avoid shared-inventory races, and keep exit conditions in timed scripts. Megafarm, Swarm, Dinosaurs, Bone Farmer, Giant Pumpkin, Long Dinosaur, Wrong Order.
Cleanup Farm the big totals, timed master targets, unlock everything, and submit leaderboard runs. Separate “safe completion” scripts from leaderboard scripts so you can debug each one cleanly. Big Farmer achievements, Master achievements, What now?, Competitive Farming, Full Automation.

The Core Mental Model

Every strong script in The Farmer Was Replaced starts with three decisions:

  1. What is on this tile? Read the entity, the ground type, water level, and any special measurement before acting.
  2. What is the safest useful action? Harvest if ready, repair the tile if it is wrong, plant only if you have the right ground and seed cost, then water or fertilize only when it helps.
  3. Where should the drone go next? Use a repeatable traversal pattern so every tile is seen often and bugs are easy to reproduce.

A reliable early-game loop is not fancy. It is intentionally boring:

while True:
    if can_harvest():
        harvest()

    fix_or_plant_the_current_tile()
    move_to_the_next_tile()

Do not rush to paste giant scripts before you understand this loop. Most broken farms are not broken because the player lacks a 500-line solution; they are broken because one small assumption is wrong, such as “this tile is soil”, “this crop is ready”, “measure() always returns a number”, or “both drones can use the last water tank”.

First Hour: Stable Automation Basics

Your first working script should do one job: cross the whole farm forever without getting confused. The farm wraps around at the edges, so moving East from the final column returns you to the first column. A common pattern is row-major movement: move East until the row wraps, then move North once. When the world grows, the same idea still works if you base it on get_world_size() instead of hard-coded coordinates.

Early Habit Why It Matters Common Mistake
Use get_world_size() Your script keeps working after farm expansions. Writing a 3×3 loop, expanding, then wondering why half the field is ignored.
Check can_harvest() before harvest() It avoids wasting cycles and avoids ending mazes accidentally later. Calling harvest on every tile without understanding the special cases.
Check ground before planting Carrots, pumpkins, cacti, and sunflowers need soil. Calling plant(Entities.Sunflower) on grassland and assuming the game is bugged.
Keep debugging small Early print() tools are limited until you unlock more helpers. Changing movement, planting, trading, and watering in one run, then losing the bug.
Back up important code Long scripts are easier to manage in an external editor. Keeping every serious solution only in one in-game code window.

Resource And Crop Progression

Progression is cost-driven. If you are stuck, open the tech tree, look at the next unlock cost, and work backward to the crop that supplies the bottleneck. Once the relevant helper exists, get_cost() can make that planning programmatic, but even before then the mental process is the same: farm the expensive input first, then automate the upgrade that makes the next resource faster.

Resource Or System What To Automate Important Rule Cleanup Target
Hay Let grass regrow and harvest whenever ready. Grass can remain as an entity after harvest. Do not treat every harvested grass tile as empty. Hay Farmer, Big Hay Farmer, Hay Master.
Wood Start with bushes, then switch to trees where spacing allows it. Trees dislike adjacency; checkerboard layouts are safer than filling every tile with trees. Wood Farmer, Big Wood Farmer, Wood Master.
Carrots Till grassland to soil, trade for seeds when needed, then replant after harvest. Always check seed inventory before planting or trading loops can stall. Carrot Farmer, Big Carrot Farmer, Carrot Master.
Pumpkins Plant uniform blocks, repair dead pumpkins, and harvest only when the connected block is ready. A single dead, empty, or unripe tile can break the expected group harvest. Pumpkin Farmer, Giant Pumpkin, Big Pumpkin Farmer, Pumpkin Master.
Cacti Plant full rows or columns, measure values, swap until the field is sorted. Cactus harvests only pay properly when values are ordered. For Wrong Order, invert the sort. Cactus Farmer, Wrong Order, Big Cactus Farmer, Cactus Master.
Sunflowers and power Measure petal values, harvest high-value flowers first, and keep power stockpiled. Power applies automatically as a speed boost while you have it; you do not activate it manually. Power Farmer, Big Power Farmer, Sunflower Master.
Mazes and gold Create mazes from bushes using weird substance, find treasure, harvest only on treasure. Harvesting the wrong maze tile ends the maze, so detect treasure before collecting. Maze, Treasure Hunter, Gold Farmer, Recycling, Big Gold Farmer, Maze Master.
Dinosaurs and bones Use the dinosaur hat, eat apples, grow a tail, and harvest bones from the tail route. Older dinosaur scripts may not match current mechanics. Recheck the in-game dinosaur docs before relying on old code. Dinosaurs, Bone Farmer, Long Dinosaur, Size Matters, Big Bone Farmer, Dino Master.
Official The Farmer Was Replaced screenshot showing a drone near farm tiles and code windows
Good scripts are usually staged: first make one crop reliable, then add water, fertilizer, measurement, workers, and cleanup conditions.

Python-Like Does Not Mean Full Python

The in-game language is close enough to Python that real Python habits help, but it is still a game-specific language. This is where many experienced programmers lose time. Before blaming your algorithm, check whether the syntax exists in the game.

Usually Safe Be Careful With Or Avoid Why It Matters
if, elif, else, while, for with range(). Fancy one-line conditional expressions. Write plain branches. The extra lines are worth the reliability.
Functions with def, short helper names, and basic globals. Deeply nested helpers that are hard to debug in the in-game editor. Small helpers make it easier to test one system at a time.
Lists, dictionaries, tuples, and imports after they are unlocked. List comprehensions, standard-library imports, generators, or full Python exception handling. Community guides repeatedly warn that full Python snippets often fail in this DSL.
Explicit checks like if value != None:. Assuming measure() returns a number on every tile. On empty or unsuitable tiles, a measurement can be None.
Clear loop exits for timed or leaderboard scripts. while True inside a leaderboard script with no target condition. Leaderboard simulations need your program to terminate after the target is reached.

If you ask an AI assistant or copy a generic Python solution, audit it before pasting. The biggest red flags are lambdas, f-strings, list comprehensions, try/except, standard-library imports, and code that assumes the drone can see the whole world without moving or measuring.

Script Patterns That Keep Working

1. A Tile Scanner You Trust

Write one movement helper and use it everywhere. A readable pattern beats a clever one because every later system depends on traversal. If the drone skips tiles, every crop script becomes suspect.

def next_tile():
    old_x = get_pos_x()
    move(East)
    if old_x == get_world_size() - 1:
        move(North)

That example is intentionally small. On a torus farm, movement wraps, so the helper is less about “not falling off” and more about making your visit order predictable. Once you add multi-drone workers, let each worker own a row, column, or fixed region so you can tell which worker caused a bad tile.

2. Guard Every Planting Action

Most crop scripts need the same checks in a different order: do I need soil, do I have seeds or inputs, is the current entity already correct, and should I wait for harvest instead of replacing it?

def prepare_soil_crop(entity, seed_item):
    if get_ground_type() != Grounds.Soil:
        till()
    if num_items(seed_item) == 0:
        trade(seed_item)
    if get_entity_type() != entity:
        plant(entity)

For pumpkins and cacti, do not treat this as a final script. Pumpkins need group-health checks before harvest, and cacti need sorting. The helper is just the safe planting base.

3. Treat Measurements As Context-Specific

measure() is powerful because it changes meaning by system. On sunflowers it reports the petal value, on cacti it reports the cactus value, in mazes it can help identify treasure position, and in dinosaur play it can be tied to apple positioning. That flexibility is also dangerous. Write guards before arithmetic:

value = measure()
if value != None:
    use_the_value(value)

This one habit prevents a large family of “operator cannot be used with None” errors.

4. Make Multi-Drone Code Defensive

All drones share inventory. If two drones both see one water tank and both try to use it, one action can fail. Late-game scripts should leave a buffer: check for more than one item before use, let one manager drone trade, or assign workers to actions that do not compete for the same item on the same tick.

Official The Farmer Was Replaced screenshot showing a farm grid with trees and a drone
Multi-drone farming is the point where correctness matters more than raw ambition. A simple row worker you can debug is better than 32 drones racing over the same tile.

How To Beat The Midgame Wall

The first real wall is not usually a resource count. It is a change in what the game asks of you. Early crops reward repetition. Cacti, sunflowers, mazes, and dinosaurs ask for algorithms.

When that shift hits, stop trying to make one master script. Split the problem into testable systems:

  1. One tile proof: Can you plant, measure, and harvest one instance correctly?
  2. One row proof: Can you run the rule across a row without losing position?
  3. Full field proof: Can the loop cover the whole farm and return to a known state?
  4. Worker proof: Can two drones run without stepping on each other’s inventory or region?
  5. Timed proof: Can the script stop when the goal is reached instead of running forever?

This progression is slower for the first hour and much faster for the next ten. It also makes community code easier to learn from: instead of copying the whole script, identify which subsystem it solved and compare that subsystem to your own.

Pumpkins: From Basic Blocks To Giant Pumpkin

Pumpkins are the first crop that punishes “plant everything and harvest whenever possible”. A full pumpkin field can behave like a connected block, and one bad tile can stop the clean harvest you expected. For normal pumpkin farming, a safe route is:

  1. Clear or normalize the area you want to use.
  2. Till every tile in that area.
  3. Plant pumpkins uniformly.
  4. During growth, revisit every tile and repair dead or missing pumpkins.
  5. Harvest only after the connected block is ready.

For Giant Pumpkin, the Steam achievement asks for a 32×32 pumpkin harvest. Do not attempt this while your farm, planting script, seed supply, or repair logic is still unreliable. Use a smaller block first, prove that it can mature as one group, then scale. A field that looks almost finished but contains one bad pumpkin is not finished.

Cactus Sorting And Wrong Order

Cacti are the classic “this stopped being farming” moment. The important rule is ordering: cactus values must be sorted so the field satisfies the required comparison in both axes. Readable community references describe the normal direction as smaller or equal values toward the south and west, and larger or equal values toward the north and east. If you get a zero-yield harvest, assume your sort did not converge.

A beginner-friendly cactus route:

  1. Plant a complete field of cacti on soil.
  2. Measure neighboring tiles.
  3. Swap neighbors when the local order is wrong.
  4. Repeat row and column passes until a full pass makes no swaps.
  5. Harvest only after convergence.

The Wrong Order achievement uses the same concept with the comparison inverted. Do not write a second cactus solver from scratch. Parameterize the comparison: normal order for farming, reversed order for the achievement.

Sunflowers And Power

Sunflowers introduce value-based harvesting. You are not only farming a crop; you are choosing which flower is worth taking first. The public references consistently point to measuring sunflower values, harvesting the best values first, and using the resulting power to accelerate later farms.

Power is especially important for the timed master achievements. The simplest plan is:

  1. Build a sunflower script that plants the whole field on soil.
  2. Measure all flowers and record their values.
  3. Harvest the highest-value flowers first.
  4. Replant and repeat until you have a comfortable power stockpile.
  5. Run the target crop script while power is available.

For Sunflower Master, naive “harvest whatever is ready” logic is rarely enough. Treat it as a measurement and ordering challenge, not a normal crop grind.

Mazes, Gold, Treasure, And Recycling

Mazes are where your movement code becomes a pathfinding problem. The readable maze reference describes the maze as loop-free and recommends a left-wall style solver as a straightforward first approach. That is not the fastest solution, but it is a good learning solution because it uses only local wall checks and keeps the drone moving until it finds treasure.

The important safety rule: do not harvest unless you are on treasure. Harvesting the wrong maze tile can end the maze, which destroys your gold run. The safest structure is:

while get_entity_type() != Entities.Treasure:
    choose_a_safe_maze_move()

harvest()

For Treasure Hunter, solve a maze that fills the whole farm. For Recycling, reuse the same maze 300 times instead of constantly spawning a fresh one. For Maze Master, the public Steam achievement target is 2 million gold in 1 minute, so a slow single-drone wall follower becomes a learning tool rather than the final answer. Expect to move toward parallel maze management when you chase the timed version.

Dinosaurs And Bone Farming

The dinosaur system is easy to misunderstand because older guides may describe older behavior. The current public achievement list points to three major goals: equip the dinosaur hat, grow a dinosaur that fills the whole farm, and reach length 1000. Community references also warn that dinosaur mechanics have changed over time, so the safest route is to read the current in-game dinosaur documentation before using older snake-style code.

For completion, think in systems:

  1. Confirm the dinosaur hat is unlocked and equip it.
  2. Write movement that can chase apples without trapping the tail.
  3. Keep a predictable path so the tail can grow safely.
  4. Harvest bones from the tail route once the mechanic allows it.
  5. Only then scale toward Long Dinosaur, Size Matters, Big Bone Farmer, and Dino Master.

Do not debug dinosaur code inside your full farm script. It has different movement pressure than crops and mazes. Give it its own file or code window, prove the pathing, then integrate it into cleanup planning.

Official The Farmer Was Replaced screenshot showing drones and automated farm activity
Late-game goals often need separate scripts: one for crop throughput, one for maze gold, one for dinosaur bones, and one for reset or leaderboard attempts.

Achievement Cleanup Guide

Steam currently lists 59 achievements for The Farmer Was Replaced. None of the readable sources indicated a story-style permanent missable. Cleanup is mostly gated by unlocks, resources, code reliability, and whether the script still matches the current mechanics. The main practical risk is wasting time on outdated code or letting an infinite script run with no stop condition.

Fast And Joke Achievements

Achievement Steam Requirement Cleanup Note
Hello World Run your first program. Any valid script works.
Infinite Loop Create an infinite loop. A plain while True: loop is the natural route.
Error Cause a runtime error. Do this intentionally in a throwaway window, not inside your real farm script.
Acrobat / Master Acrobat Do a flip / do 1000 flips. Use do_a_flip(); loop it for the master version.
Feels Good Pet the piggy. Use the piggy function when it is available.
Higher-Order Programming Pass a function as an argument to a function. Good time to learn worker callbacks for drone scripts.
Stack Overflow / Circular Import Cause a stack overflow / create an import cycle. Use disposable files. Do not mix these with your saved utility modules.
Chaos Have 20 code windows open. Easy cleanup, but close them afterward so the editor stays manageable.

Planting, Unlock, And Utility Achievements

Achievement Steam Requirement Cleanup Note
It Grew / Big Farm Expand the farm / reach the maximum farm size. Keep your traversal based on world size before expanding heavily.
Bushes, Carrots, Trees, Pumpkins, Sunflowers, Cacti Plant each listed crop. Most non-grass crops need soil; trees need spacing; cacti need sorting before serious harvests.
Maze Spawn a maze. Use weird substance on a bush once the maze system is unlocked.
Dinosaurs Equip the dinosaur hat. Do this before testing any dinosaur pathing script.
Fashionable / Fashion Show Equip a new hat / equip 5 different hats on 5 drones. Fashion Show pairs naturally with learning spawn_drone() and worker callbacks.
Megafarm / Swarm Use multiple drones / use 32 drones at once. Spawn simple idle or row-worker tasks first. Then add real farming logic.
What now? Unlock everything. Save this for after the big resource grinds; it is a tech-tree completion gate.
Competitive Farming / Full Automation Get on a leaderboard / get on the full reset leaderboard. Use a script with a clear exit condition. Full Automation is a separate reset-route challenge, not a normal farm loop.

Resource Count Achievements

Resource Basic Target Big Target Practical Advice
Hay Hay Farmer: 1000 hay. Big Hay Farmer: 1 billion hay. Grass is simple, but the big target still wants multi-drone and polyculture-era speed.
Wood Wood Farmer: 1000 wood. Big Wood Farmer: 1 billion wood. Move from bushes to spaced trees once tree logic is reliable.
Carrots Carrot Farmer: 1000 carrots. Big Carrot Farmer: 1 billion carrots. Make seed trading and soil preparation automatic before scaling.
Pumpkins Pumpkin Farmer: 1000 pumpkins. Big Pumpkin Farmer: 100 million pumpkins. Uniform blocks and dead-pumpkin repair matter more than raw movement speed.
Cacti Cactus Farmer: 1000 cacti. Big Cactus Farmer: 100 million cacti. Prove the sort on a small field before spending time on a full farm.
Power Power Farmer: 1000 power. Big Power Farmer: 100000 power. Measure sunflower values and prioritize better harvests.
Gold Gold Farmer: 1000 gold. Big Gold Farmer: 100 million gold. Maze generation, treasure detection, and reuse logic are the whole problem.
Bones Bone Farmer: 1000 bones. Big Bone Farmer: 100 million bones. Use current dinosaur mechanics, not old pre-rework assumptions.

Special Mechanics Achievements

Achievement Steam Requirement What To Prepare
Mud Farm Water the entire farm above water level 0.5. A full-field traversal that checks water on every tile.
Treasure Hunter Solve a maze that fills the whole farm. A maze solver that never harvests until it confirms treasure.
Healer Cure an infected plant. Read the current in-game description for the exact cure mechanic, because fertilizer behavior has changed across versions.
Giant Pumpkin Harvest a 32×32 pumpkin. Maximum farm size, full-field pumpkin repair, and patient readiness checks.
Long Dinosaur Have a dinosaur that fills the entire farm. Tail-safe pathing and current dinosaur-hat behavior.
Size Matters Get a dinosaur to length 1000. A long-running dinosaur script that does not trap itself.
Wrong Order Sort a full field of cacti the wrong way round. Your cactus solver with the comparison inverted.
Recycling Reuse the same maze 300 times. Maze reuse logic rather than fresh maze spawning every cycle.

Timed Master Achievements

The master achievements are throughput checks. Do not treat them like normal “leave it running overnight” grinds. Stockpile power, use multiple drones when allowed, keep the script focused on one target, and terminate as soon as the goal is reached.

Achievement Steam Target Route Hint
Hay Master Farm 200 million hay in 1 minute. Use a mature high-throughput hay setup, not a beginner grass loop.
Wood Master Farm 1 billion wood in 1 minute. Tree or polyculture-based wood throughput is the likely cleanup route.
Carrot Master Farm 200 million carrots in 1 minute. Seed supply, soil prep, and worker coordination must be automatic.
Pumpkin Master Farm 20 million pumpkins in 1 minute. Full block readiness and repair logic matter more than button mashing.
Cactus Master Farm 20 million cacti in 1 minute. Use a fast sorting pass; unfinished cacti produce poor or zero returns.
Sunflower Master Farm 12000 power in 1 minute. Measure and harvest high-value flowers first.
Dino Master Farm 1 million bones in 1 minute. Use current dinosaur mechanics and a dedicated bone script.
Maze Master Farm 2 million gold in 1 minute. Parallel maze management is usually the real challenge.

Full Automation And Leaderboards

Full Automation is not just “my farm runs by itself”. The achievement asks you to get on the full reset leaderboard. That means a bootstrap route that starts from the leaderboard’s fixed conditions, unlocks what it needs, farms the required resources, and terminates in a form the leaderboard run accepts.

For any leaderboard script:

  • Use a target-based outer loop, such as “while the item count is below the target”, not an endless while True.
  • Put the submitted farming code in the named file or window that leaderboard_run() calls.
  • Test the same script outside the leaderboard with smaller targets first.
  • Expect public scripts to be educational, not top-rank miracles. The top leaderboard times usually come from many rounds of profiling and private optimization.

If your first leaderboard submission is only rank 200, that is still a success for Competitive Farming. Treat rank chasing as a separate hobby after completion, not as the measure of whether you “beat” the game.

Common Errors And Fixes

Symptom Likely Cause Fix
Planting silently fails. Wrong ground type, missing seed/input, or crop already on the tile. Check ground, inventory, and entity before calling plant().
A comparison crashes with None. measure() returned no value on that tile. Guard with if value != None: before comparing.
Cacti harvest but pay nothing. The field is not fully sorted. Keep swapping until a full row and column pass makes no changes.
Pumpkin block never becomes harvestable. One tile is dead, missing, unripe, or outside the connected group. Scan and repair the full block before harvesting.
Maze run ends early. The drone harvested a non-treasure tile or failed to verify treasure. Only call harvest() after confirming Entities.Treasure.
Multi-drone script produces warnings. Drones are racing for shared inventory or the same tile. Assign regions and leave inventory buffers, especially for water, fertilizer, seeds, and weird substance.
Leaderboard simulation never ends. The script has no exit condition. Replace endless loops with target-based loops and return when finished.
Old maze or dinosaur code behaves wrong. Mechanics changed after the guide was written. Check current in-game docs, patch notes, and recent community references before adapting old scripts.
Official The Farmer Was Replaced screenshot showing a dense automated field with code windows
The late game is less about finding one perfect script and more about maintaining a library of small, proven systems.

Practical Completion Checklist

  1. Back up your current working code outside the game.
  2. Write one reliable full-field traversal helper and use it across crop scripts.
  3. Finish the basic plant and 1000-resource achievements while unlocking senses, functions, lists, water, fertilizer, and drone tools.
  4. Build separate scripts for pumpkins, cacti, sunflowers, mazes, and dinosaurs. Do not combine them until each works alone.
  5. Clear one-off achievements: pet the piggy, flips, hats, code windows, stack overflow, circular import, mud farm, giant pumpkin, wrong-order cactus, long dinosaur, and recycling.
  6. Stockpile power before timed master attempts.
  7. Use multi-drone and polyculture-era scripts for Big Farmer and Master achievements.
  8. Unlock everything for What now?.
  9. Submit an easy leaderboard run for Competitive Farming, then treat Full Automation as the final reset-route project.

The best way to enjoy The Farmer Was Replaced is to resist the urge to paste the biggest script you can find. Read scripts like worked examples. Pull out the movement idea, the measurement idea, or the worker coordination idea, then rebuild it in your own smaller version. The moment you understand why a drone does the work, the game changes from a grind into a very satisfying optimization puzzle.

Sources And Credits

Official metadata and screenshots were checked against the Steam store, Steam appdetails, and the Metaroot press kit for The Farmer Was Replaced. Mechanics and cleanup structure were cross-checked against the public wiki, the provided code/reference pages, Steam global achievement data, and readable Steam Community guides. Community code was used only as verification context; this article does not republish full scripts.