Files
farmer/maze.py

81 lines
1.6 KiB
Python

import solve, utils
import pumpkin
d = [North, West, South, East]
def grow(xl, yl, n, repeat=1):
cd = 0
cnt = 0
substance = n * 2**(num_unlocked(Unlocks.Mazes) - 1)
def init():
global cnt
cnt = 0
utils.mv(xl+n/2, yl+n/2)
utils.grass()
plant(Entities.Bush)
def run():
global cd
global cnt
if cnt == 0:
init()
use_item(Items.Weird_Substance, substance)
typ = get_entity_type()
while typ != Entities.Treasure:
if typ != Entities.Hedge:
init()
use_item(Items.Weird_Substance, substance)
if can_move(d[(cd+1)%4]):
cd = (cd+1)%4
if move(d[cd]):
typ = get_entity_type()
continue
else:
cd = (cd+3)%4
cnt += 1
if cnt >= repeat:
harvest()
cnt = 0
else:
use_item(Items.Weird_Substance, substance)
return (init, run)
def grow_full(x, y, replant=False):
substance = 4 * 2**(num_unlocked(Unlocks.Mazes) - 1)
def ret():
utils.mv(x, y)
do_a_flip()
while True:
if get_entity_type() == Entities.Treasure:
harvest()
if replant and get_entity_type() != Entities.Hedge:
plant(Entities.Bush)
use_item(Items.Weird_Substance, substance)
return ret
if __name__ == '__main__':
set_world_size(8)
clear()
jobs = list()
for d in range(2):
for x in range(4):
for y in range(4):
if x == 2 and y == 2:
jobs.append(grow_full(d*4+x, y, True))
else:
jobs.append(grow_full(d*4+x, y))
for job in jobs[:-1]:
spawn_drone(job)
jobs[-1]()