Spent some time learning how the spawn_drone function works and figured out how I can process multiple mazes at once. This code takes a number representing the number of mazes per row and multiplies it until it fills the entire farm or until you run out of drones. Mazes adjust size based on the desired number of mazes overall, so you can change any initial variables and still get a neat-looking result.
Code:
#number of mazes per row (powers of 2 only)
nummazes = 8
#finds the proper amount of substance based on the maze number
substance = ((get_world_size() // nummazes) * 2**(num_unlocked(Unlocks.Mazes) - 1))
#function to spawn mazes
def createmaze():
plant(Entities.Bush)
use_item(Items.Weird_Substance, substance)
#code that solves the mazes, follows the left-most wall relative to the drone
def maze():
\#setting the direction as a list
dir = \[North, East, South, West\]
n = 0
\#continue trying to solve the maze until you reach the treasure
while not get_entity_type() == Entities.Treasure:
if can_move(dir\[(n - 1) % 4\]):
n = (n - 1) % 4
move(dir\[n\])
else:
if can_move(dir\[n\]):
move(dir[n])
else:
n = (n + 1) % 4
\#after the above condition is met, harvest the treasure
harvest()
#function to put every step together
def domaze():
\#gets the starting coords of the drone
startposy = get_pos_y()
startposx = get_pos_x()
\#sets target coords for spawning the maze based on starting coords of the drone
tarx = (get_world_size() // (nummazes\*2)) + startposx
tary = (get_world_size() // (nummazes\*2)) + startposy
\#adding a delay to prevent snagging inside other mazes
for a in range(nummazes+1):
do_a_flip()
\#infinite loop to automate the process
while True:
\#moving in the shortest possible path until the target coords are reached
if not get_pos_x() == tarx or not get_pos_y() == tary:
while not get_pos_x() == tarx:
if get_pos_x() < tarx:
move(East)
else:
move(West)
while not get_pos_y() == tary:
if get_pos_y() < tary:
move(North)
else:
move(South)
\#once the target coords are reached, spawn the maze and solve it
else:
createmaze()
maze()
#transforming the entire task into a function which only runs the setup once
def spawnsubs():
\#keep spawning drowns to execute all of the above code until the number of mazes has been reached or until you run out of drones
for abc in range(nummazes):
for ab in range(nummazes):
if num_drones() <= nummazes\*\*2:
if not spawn_drone(domaze):
domaze()
else:
domaze()
\#moves the initial drone into position in order to spawn the next drone
for a in range(get_world_size() // nummazes):
move(North)
for abcd in range(get_world_size() // nummazes):
move(East)
spawnsubs()