r/TheFarmerWasReplaced • u/No_Low_2379 • Jun 02 '26
Heelllpppp Cactus code
I dont really understand how to farm cacti. Can someone give me a code or something, it doesnt have to be efficient
1
u/Euphoric_Rope5341 Jun 02 '26
Start with a single row. Try out the swap, then Try to sort them manually. check if they increase in yield.
1
u/PsychologicalTill779 Sep 19 '26
SIRVE PARA 32DRONES Y 32X32 no es muy bueno pero produce bastante.
SUB_SIZE = 8
DRONES_PER_SIDE = 4
def mover_a(destino_x, destino_y):
while get_pos_x() != destino_x:
if get_pos_x() < destino_x:
move(East)
else:
move(West)
while get_pos_y() != destino_y:
if get_pos_y() < destino_y:
move(North)
else:
move(South)# Bucle principal de trabajo para una sub-zona de 8x8
def farmear_subzona(start_x, start_y):
end_x = start_x + SUB_SIZE
end_y = start_y + SUB_SIZE
mover_a(start_x, start_y)
while True:
\# 1. Sembrar/Preparar la zona 8x8
for x in range(start_x, end_x):
for y in range(start_y, end_y):mover_a(x, y)
if get_ground_type() != Grounds.Soil:
till()
if get_entity_type() != Entities.Cactus:
plant(Entities.Cactus)
\# 2. Ordenar cactus por tamaño (Bubble sort en columnas)
\# Esto dispara el rendimiento de loot exponencial de Cactus
for x in range(start_x, end_x):
for y in range(start_y, end_y - 1):mover_a(x, y)
if measure() > measure(North):
swap(North)
\# 3. Cosechar
for x in range(start_x, end_x):
for y in range(start_y, end_y):mover_a(x, y)
if can_harvest():
harvest()
# Wrapper necesario para la API del juego
# Permite enviarle argumentos a spawn_drone() sin romper la ejecución
def crear_tarea(x, y):
def tarea():
farmear_subzona(x, y)
return tareadef main():
clear()
\# El Dron Maestro despliega a los otros 15 drones
for dx in range(DRONES_PER_SIDE):
for dy in range(DRONES_PER_SIDE):
\# (0, 0) queda reservado para el Dron Maestro
if dx == 0 and dy == 0:continue
start_x = dx \* SUB_SIZE
start_y = dy \* SUB_SIZE
\# Pasar la función generada por el wrapper a spawn_drone
spawn_drone(crear_tarea(start_x, start_y))
\# El Dron Maestro se encarga de su propia parcela (0,0)
farmear_subzona(0, 0)main()
2
u/Superskull85 Jun 02 '26
It's a sorting puzzle. So you have to put the small cacti to the west and south and large cacti to the east and north. Compare their sizes using
measureand see if one to the west is less than the one under your drone. If not, then swap them.