The Farmer Was Replaced

The Farmer Was Replaced

Not enough ratings
Useful scripts | Dinossaur algorithm (bone farming) | Giant Pumpkin
By HendrickFS
This guide provides scripts to help you progress in the game, and short explanations that show how the automation works and how to use it.
   
Award
Favorite
Favorited
Unfavorite
Introduction
This guide bundles a set of small scripts designed to help you progress in the game by automating repetitive tasks (for example, bone farming). The included scripts are ready to run in the game's scripting environment and are documented so you can understand and adapt them.

More scripts will be added over time, new farming helpers and farming utilities. If you need some specific script, feel free to comment, it would be a pleasure to help you on my free time.

Dinossaur Algorithm (Bone Farming)
Overview
The documentation of dinosaurs and bones can be quite confusing, but in summary:
  • 1. Dinosaurs: Is the drone while using the "Dinosaur" hat (Hats.Dinosaur_Hat). With this hat equipped and empty spaces, Apples will spawn in random locations on the map. Eating them you increase your tail, making your drone use one more space behind it.
  • 2. Apples: You can pick apples when they are under the drone, "eating" them and increasing your tail. So after it, a new apple will spawn somewhere else on the map.
  • 3. Bones: When you stop eating apples (by switching hats, being without space, or by stopping the code), you drop Bones, the number of bones is determined by the length of your tail. The longer your tail, the more bones you drop, receiving n**2 bones (n = tail length).

So its basically the famous snake game, but you want to grow as long as possible to drop more bones.

Algorithm
The main idea of the algorithm is to move the drone in a way that it can pick up apples without colliding with its own tail. To achieve this, the algorithm basically makes the drone follow a predefined path that covers the entire map in a zig-zag pattern. This way, the drone will eventually pass over every possible apple spawn location.

Script
The script is divided into several sections for better organization and readability. Each section is documented with comments to explain its purpose and functionality.

def calculate_pair_steps(world_size): return (world_size - 6) // 2 + 2 def try_move(direction): return move(direction) def go_to_origin(): while get_pos_x() != 0: try_move(West) # Move vertically toward Y=0 while get_pos_y() != 0: try_move(South) def return_and_reset(): change_hat(Hats.Straw_Hat) go_to_origin() change_hat(Hats.Dinosaur_Hat) perform_dino_pattern() def repeat_move(direction, steps): for _ in range(steps): if not try_move(direction): # If a move fails, reset and indicate failure to the caller return_and_reset() return False return True def perform_dino_pattern(): world_size = get_world_size() max_index = world_size - 1 pair_steps = calculate_pair_steps(world_size) while True: # Climb to the top edge (Y = max_index) if not repeat_move(North, max_index): return # Run to the right edge (X = max_index) if not repeat_move(East, max_index): return # Drop one row to start the sweep pairs if not repeat_move(South, 1): return # Perform pair_steps times: sweep left, step down, sweep right, step down for _ in range(pair_steps): # Sweep left across most of the row if not repeat_move(West, max_index - 1): return # Move down a single row if not repeat_move(South, 1): return # Sweep right across most of the next row if not repeat_move(East, max_index - 1): return # Move down a single row to continue the pattern if not repeat_move(South, 1): return # After the pairs, move back to the leftmost edge to finish the loop if not repeat_move(West, max_index): return def farm_bone(): world_size = get_world_size() # If the world size is odd, reduce it by 1 to make it even if world_size % 2 == 1: set_world_size(world_size - 1) world_size -= 1 # Visual preparation and positioning change_hat(Hats.Straw_Hat) go_to_origin() change_hat(Hats.Dinosaur_Hat) # Run the pattern repeatedly until the environment prevents movement while True: perform_dino_pattern()

To use the script, simply copy and paste it into the game's scripting environment and run the farm_bone() function. The drone will start moving in the zig-zag pattern, picking up apples and growing its tail to drop bones.

You can add the script to another file instead of main, and call the farm_bone() function from there to keep your main script clean. Just remember to import the functions of the file.
Example:
from f0 import * clear() while True: farm_bone()

Giant Pumpkin Algorithm
Overview

This script was created with the purpose of unlocking the "Giant Pumpkin" achievement, which requires harvesting a 32x32 Pumpkin (really giant).

The key point to get a 32x32 Pumpkin is to plant pumpkins in a 32x32 area without have any dead Pumpkin. For that, you need to check on every tile to see if there is a dead Pumpkin, and if so, replant it. After have all tiles filled with healthy pumpkins, you can harvest it.

Algorithm

The main idea of the algorithm is spawn 32 drones, each one will be responsible to plant a column of pumpkins. All the drones will be checking if there is any dead pumpkin in their column, and if so, replant it. When all drones finish their job, they update a global variable that will be used to check if all drones are done. When all drones are done, the last drone that finish will harvest the pumpkin.

Script

This script is very unefficient, but simple to understand. The efficiency problem is that the increment of the global variable is not instantaneous, so it will take some seconds for the drones to finish their job. The print command shows the value of the global variable, so you can wait until you see the number 1024 (32*32), and then the last drone will harvest the pumpkin.

pumpkin_count = 0 def giant_pumpkin(): for j in range(32): till() move(North) for j in range(32): plant(Entities.Pumpkin) move(North) while True: cont = 0 on = 1 for j in range(32): if not can_harvest(): if get_entity_type() == Entities.Dead_Pumpkin or get_entity_type() == None: plant(Entities.Pumpkin) else: cont+=1 if cont == 32 and on == 1: global pumpkin_count pumpkin_count += 32 print(pumpkin_count) on = 0 if pumpkin_count == 32*32: harvest() if on == 1: move(North) else: do_a_flip()

To use the script, simply copy and paste it into the game's scripting environment and import the function giant_pumpkin on the main file. After that, you can spawn 32 drones and call the function on each one of them.

while True: if spawn_drone(giant_pumpkin): move(East) else: giant_pumpkin()

Overview

STILL WRITING THIS SECTION

p = 0 clear() def pumpk(): for j in range(32): till() move(North) for j in range(32): plant(Entities.Pumpkin) move(North) while True: cont = 0 on = 1 for j in range(32): if not can_harvest(): if get_entity_type() == Entities.Dead_Pumpkin or get_entity_type() == None: plant(Entities.Pumpkin) else: cont+=1 if cont == 32 and on == 1: global p p += 32 print(p) on = 0 if p == 32*32: harvest() if cont < 32: move(North) else: do_a_flip()

while True: if spawn_drone(pumpk): move(East) else: pumpk()
1 Comments
decimalist 12 Oct @ 6:45pm 
I love this :steamhappy: