The Farmer Was Replaced готовые коды — скрипты для копирования
Вставьте первый скрипт ниже, чтобы начать сбор. Дальше — деревья, морковь и полив. Отдельный гайд по моркови: страница кода моркови
Пример 1: базовый автосбор
Простейший скрипт автоматизации, который непрерывно собирает зрелую траву.
# Basic Auto Harvest - The simplest automation script
# This continuously checks and harvests mature crops
while True:
if can_harvest():
harvest()
# The game will automatically pause between iterations
📊 Code Analysis
Пример 2: автообход фермы 3×3
Автоматически обходите все клетки и собирайте урожай.
# 3x3 Farm Auto Traversal - Systematic farming pattern
# This script moves in a grid pattern to cover the entire farm
while True:
# Always check for harvestable crops first
if can_harvest():
harvest()
# Move to the next tile (East direction)
move(East)
# When reaching the end of a row, move to the next row (North)
# get_world_size() returns the size of your farm (usually 3x3 or 5x5)
if get_pos_x() == get_world_size() - 1:
move(North)
Пример 3: Многокультурная автоматизация (трава + куст + морковь)
Высаживайте различные культуры в зависимости от положения колонны.
# Multi-Crop Automation - Different crops per column
# Demonstrates conditional logic and resource management
while True:
# Always harvest what's ready first
if can_harvest():
harvest()
# Get current position (x-coordinate)
x = get_pos_x()
# Column-based planting strategy:
if x == 0:
# Column 0: Let grass grow naturally (free resource)
pass # No action needed
elif x == 1:
# Column 1: Plant bushes for wood
plant(Entities.Bush)
elif x == 2:
# Column 2: Plant carrots (requires soil preparation)
# Check if ground is soil, if not, till it
if get_ground_type() != Grounds.Soil:
till()
# plant() spends hay+wood automatically (1.0; seed shop removed)
plant(Entities.Carrot)
# Move to next column
move(East)
# When reaching end of row, move to next row
if x == get_world_size() - 1:
move(North) Пример 4: Посадка древесной шахматной доски
Деревьям нужна шахматная посадка, чтобы не стоять рядом. Отдельный гайд: Код дерева
# Checkerboard Planting Pattern - Space-efficient farming
# Trees cannot be planted adjacent to each other, so use checkerboard pattern
while True:
# Harvest any mature crops
if can_harvest():
harvest()
# Get current coordinates
x = get_pos_x() # Current column (0, 1, 2, etc.)
y = get_pos_y() # Current row (0, 1, 2, etc.)
# Checkerboard logic: Plant trees on "black squares", bushes on "white squares"
# This ensures no two trees are adjacent (trees need space to grow)
if (x % 2 == 0 and y % 2 == 0) or (x % 2 == 1 and y % 2 == 1):
# "Black squares" - plant trees
plant(Entities.Tree)
else:
# "White squares" - plant bushes
plant(Entities.Bush)
# Move to next tile
move(East)
# Wrap to next row when reaching end of current row
if x == get_world_size() - 1:
move(North) Пример 5. Управление приоритетами ресурсов
Интеллектуальное управление ресурсами, приоритет сбора дефицитных ресурсов.
# Resource Priority Management - Smart resource allocation
# Automatically adjusts farming strategy based on current inventory levels
while True:
# Always harvest first - this is our primary action
if can_harvest():
harvest()
# Get current position for planting decisions
x = get_pos_x()
# Resource-based planting strategy with priorities:
# PRIORITY 1: Ensure hay supply (needed for planting carrots and unlocks)
if num_items(Items.Hay) < 500:
# Don't plant anything - let grass grow naturally for free hay
pass # No action needed
# PRIORITY 2: Maintain wood supply (needed for various upgrades)
elif num_items(Items.Wood) < 300:
# Plant bushes to generate wood
plant(Entities.Bush)
# PRIORITY 3: Build carrot reserves (for unlocks that cost carrots)
elif num_items(Items.Carrot) < 200:
# Plant carrots (requires soil preparation)
if get_ground_type() != Grounds.Soil:
till() # Prepare soil if needed
plant(Entities.Carrot)
# Move to next tile in systematic pattern
move(East)
if x == get_world_size() - 1:
move(North) Пример 6: Автоматическая система полива
Автоматизированная система полива, ускоряет рост урожая до 5 раз.
# Auto Watering System - Advanced crop acceleration
# Uses Items.Water and accelerates crop growth up to 5x speed
while True:
# WATER: Items.Water accrues automatically (no trade)
# Water accrues every 10s; use_item(Items.Water) speeds growth
# WATER APPLICATION: Use water when crops need it
# get_water() returns hydration level (0.0 to 1.0)
# 0.75 means crops are 75% hydrated - water when below this
if get_water() < 0.75:
use_item(Items.Water) # 1.0 watering API
# HARVEST: Always check for mature crops first
if can_harvest():
harvest()
# PLANTING: Maintain carrot crop cycle
# Prepare soil if needed (carrots require tilled soil)
if get_ground_type() != Grounds.Soil:
till() # Convert turf/grass to soil
# Planting spends hay+wood from inventory
plant(Entities.Carrot) # Plant carrot (costs hay+wood)
# MOVEMENT: Continue systematic traversal
move(East)
if get_pos_x() == get_world_size() - 1:
move(North) Пример 7: Инкапсуляция функций
Используйте функции, чтобы сделать код более четким и читаемым.
# Function Encapsulation - Code organization and reusability
# Break down complex logic into reusable functions
# FUNCTION: Handle movement to next tile in grid pattern
def move_to_next():
"""Move to the next tile, wrapping to next row when reaching end"""
x = get_pos_x()
move(East) # Always try to move east first
# If we reached the end of current row, move north to next row
if x == get_world_size() - 1:
move(North)
# FUNCTION: Handle carrot planting with all necessary preparations
def plant_carrot():
"""Plant a carrot with soil preparation and seed management"""
# Ensure we have proper soil for carrots
if get_ground_type() != Grounds.Soil:
till() # Prepare soil if needed
# Ensure we have carrot seeds
# Plant the carrot
plant(Entities.Carrot)
# MAIN PROGRAM: Clean, readable logic using our functions
while True:
# Harvest any mature crops (always do this first)
if can_harvest():
harvest()
# Maintain carrot production if inventory is low
if num_items(Items.Carrot) < 100:
plant_carrot() # Use our function for clean code
# Move to next position using our movement function
move_to_next() # Clean, reusable movement logic Пример 8: Оптимизация энергии подсолнечника
Собирайте только цветок с наибольшим количеством лепестков. Затем отсканируйте еще раз. Полное объяснение: страница кода подсолнуха
def go_to(x, y):
while get_pos_x() != x:
if get_pos_x() < x:
move(East)
else:
move(West)
while get_pos_y() != y:
if get_pos_y() < y:
move(North)
else:
move(South)
size = get_world_size()
best = 0
bx = 0
by = 0
found = False
for y in range(size):
for x in range(size):
go_to(x, y)
if get_entity_type() == Entities.Sunflower and can_harvest():
petals = measure()
if (not found) or petals > best:
best = petals
bx = x
by = y
found = True
if found:
go_to(bx, by)
harvest() Далее: код поликультуры
Как только трава, древесина и морковь станут стабильными, разблокируйте поликультуру. `get_companion()` возвращает сопутствующий урожай и плитку, необходимые для получения большого бонуса урожая. Гайд по коду поликультуры
Другие гайды из этого раздела
- Код дерева — полный скрипт древесины шахматной доски.
- Код тыквы — мертвые плитки, выход слияния и проверка размера measure().
- Ферма странных веществ — складировать перед запуском лабиринта.
- Несколько дронов — Узоры Megafarm spawn_drone.
- Мобильные / Android / Online — где можно поиграть.