Toy maze solver (stateless) for https://store.steampowered.com/app/2060160/The_Farmer_Was_Replaced/
Last active
December 1, 2025 07:16
-
-
Save andrew-raphael-lukasik/ad3b7eb048bb9135734feb76a96f9f9f to your computer and use it in GitHub Desktop.
"The Farmer Was Replaced" maze solver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def create_maze(): | |
| clear() | |
| for i in range(get_world_size()): | |
| plant(Entities.Bush) | |
| while get_water()<0.9: | |
| use_item(Items.Water) | |
| move(North) | |
| for i in range(get_world_size()): | |
| while can_harvest()==False: | |
| pass | |
| while get_entity_type()==Entities.Bush: | |
| if num_items(Items.Fertilizer)==0: | |
| trade(Items.Fertilizer) | |
| #if num_items(Items.Fertilizer)==0: | |
| #main() | |
| use_item(Items.Fertilizer) | |
| treasure_hunt() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def treasure_hunt(): | |
| dir = West | |
| x = get_pos_x() | |
| y = get_pos_y() | |
| while True: | |
| move(dir) | |
| x2 = get_pos_x() | |
| y2 = get_pos_y() | |
| if x==x2 and y==y2: | |
| if dir==West: | |
| dir = North | |
| elif dir==North: | |
| dir = East | |
| elif dir==East: | |
| dir = South | |
| elif dir==South: | |
| dir = West | |
| else: | |
| x = get_pos_x() | |
| y = get_pos_y() | |
| if dir==West: | |
| dir = South | |
| elif dir==North: | |
| dir = West | |
| elif dir==East: | |
| dir = North | |
| elif dir==South: | |
| dir = East | |
| if get_entity_type()==Entities.Treasure: | |
| harvest() | |
| create_maze() |
Shortest working simple code for me is that.
def createLab(): # taken directly from in game advice
plant(Entities.Bush)
substance = get_world_size() * 2**(num_unlocked(Unlocks.Mazes) - 1)
use_item(Items.Weird_Substance, substance)
def findLeftTreasure(): # This code will work like our drone have left hand on the wall while trying to find treasure
rightOf={North:East, East:South, South:West, West:North}
leftOf={North:West, West:South, South:East, East:North}
dir=North
while True:
if can_move(dir):
move(dir)
dir=leftOf[dir]
else:
dir=rightOf[dir]
if get_entity_type()==Entities.Treasure:
harvest()
return 1
def TreasureUp(Target):
while num_items(Items.Gold)<Target: # Code will continue till target ammount of gold is met
createLab()
findLeftTreasure()
return 1
Target=100000
TreasureUp(Target)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

One of the things I would add to the code would be with the Strategy 3 stuff.
That is updating the for d checks for this:
I also do try to 'priortize' moves that would lead closer to the chest's X/Y coordinates, but that doesn't always work faster.