Skip to content

Instantly share code, notes, and snippets.

@JasonGoemaat
Created December 25, 2025 02:50
Show Gist options
  • Select an option

  • Save JasonGoemaat/a8707d37bb160aad81298b79254a1867 to your computer and use it in GitHub Desktop.

Select an option

Save JasonGoemaat/a8707d37bb160aad81298b79254a1867 to your computer and use it in GitHub Desktop.
map = []
DIRECTIONS = [North, East, South, West]
def get_index(x, y, direction):
if direction == 0:
y = y + 1
if y >= get_world_size():
return None
if direction == 1:
y = y - 1
if y < 0:
return None
if direction == 2:
x = x + 1
if x >= get_world_size():
return None
if direction == 3:
x = x - 1
if x < 0:
return None
return x * get_world_size() + y
def update_map():
global map
index = get_index(get_pos_x(), get_pos_y(), None)
if map[index] != None:
# other drone has handled this
return None
moves = [can_move(North), can_move(East), can_move(South), can_move(West)]
map[index] = moves
return moves
def do_drone(direction):
def handler():
while True:
# start with move, drone spawned on top of other drone and we know we can,
# will keep moving in that direction while able
if not move(DIRECTIONS[direction]):
return # hit a wall
moves = update_map()
if moves == None:
return
# spawn drones to the left and right
left = (direction + 1) % 4
if moves[left]:
spawn_drone(do_drone(left))
right = (direction + 3) % 4
if moves[right]:
spawn_drone(do_drone(right))
return handler
def init_map():
global map
size = get_world_size()
for i in range(size*size):
map.append(None)
moves = update_map()
for i in range(4):
if moves[i]:
spawn_drone(do_drone(i))
while num_drones() > 1:
do_a_flip()
print(map)
def run():
clear()
substance = get_world_size()
# substance = 5 # smaller for testing
substance = substance * 2**(num_unlocked(Unlocks.Mazes) - 1)
print(substance)
plant(Entities.Bush)
use_item(Items.Weird_Substance, substance)
init_map()
print(map)
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment