Feat: done except full reset, maze, dino
This commit is contained in:
111
pumpkin.py
111
pumpkin.py
@@ -1,38 +1,115 @@
|
||||
import utils
|
||||
import solve
|
||||
|
||||
def grow(xl, yl, n):
|
||||
def init():
|
||||
for x in range(xl, xl+n):
|
||||
l, r, d = yl, yl+n, 1
|
||||
if x%2 == 1:
|
||||
l, r, d = yl+n-1, yl-1, -1
|
||||
for y in range(l, r, d):
|
||||
utils.mv(x, y)
|
||||
utils.soil()
|
||||
def fillx(x):
|
||||
def ret():
|
||||
for y in range(yl, yl+n):
|
||||
utils.mv(x, y)
|
||||
utils.soil()
|
||||
return ret
|
||||
|
||||
drowns = list()
|
||||
for x in range(xl+1, xl+n):
|
||||
drown = None
|
||||
while drown == None:
|
||||
drown = spawn_drone(fillx(x))
|
||||
drowns.append(drown)
|
||||
fillx(xl)()
|
||||
for drown in drowns:
|
||||
wait_for(drown)
|
||||
|
||||
def run():
|
||||
check = list()
|
||||
for x in range(xl, xl+n):
|
||||
l, r, d = yl, yl+n, 1
|
||||
if x%2 == 1:
|
||||
l, r, d = yl+n-1, yl-1, -1
|
||||
for y in range(l, r, d):
|
||||
utils.mv(x, y)
|
||||
utils.water()
|
||||
utils.replant(Entities.Pumpkin)
|
||||
for y in range(yl, yl+n):
|
||||
check.append((x, y))
|
||||
|
||||
def fillx(x):
|
||||
def ret():
|
||||
for y in range(yl, yl+n):
|
||||
utils.mv(x, y)
|
||||
utils.water()
|
||||
utils.replant(Entities.Pumpkin)
|
||||
return ret
|
||||
|
||||
drowns = list()
|
||||
for x in range(xl+1, xl+n):
|
||||
drown = None
|
||||
while drown == None:
|
||||
drown = spawn_drone(fillx(x))
|
||||
drowns.append(drown)
|
||||
fillx(xl)()
|
||||
for drown in drowns:
|
||||
wait_for(drown)
|
||||
|
||||
while len(check):
|
||||
nxt = list()
|
||||
for x, y in check[::-1]:
|
||||
for x, y in check[::-1]:
|
||||
utils.mv(x, y)
|
||||
if not can_harvest():
|
||||
nxt.append((x, y))
|
||||
if get_entity_type() == Entities.Dead_Pumpkin:
|
||||
plant(Entities.Pumpkin)
|
||||
while not can_harvest():
|
||||
plant(Entities.Pumpkin)
|
||||
if not use_item(Items.Fertilizer):
|
||||
nxt.append((x, y))
|
||||
break
|
||||
else:
|
||||
nxt.append((x, y))
|
||||
check = nxt
|
||||
|
||||
utils.mv(xl, yl)
|
||||
utils.harv()
|
||||
|
||||
return (init, run)
|
||||
|
||||
def grow_parallel(xl, xm, xr, yl, yr):
|
||||
def ret():
|
||||
|
||||
def init(check, xl, xr, yl, yr):
|
||||
for x in range(xl, xr):
|
||||
for y in range(yl, yr):
|
||||
utils.mv(x, y)
|
||||
utils.soil()
|
||||
utils.water()
|
||||
plant(Entities.Pumpkin)
|
||||
check.append((x, y))
|
||||
|
||||
def replant(xl, xr, yl, yr):
|
||||
def ret():
|
||||
check = list()
|
||||
init(check, xl, xr, yl, yr)
|
||||
|
||||
while len(check):
|
||||
nxt = list()
|
||||
for x, y in check[::-1]:
|
||||
utils.mv(x, y)
|
||||
utils.water()
|
||||
if not can_harvest():
|
||||
if get_entity_type() == Entities.Dead_Pumpkin:
|
||||
plant(Entities.Pumpkin)
|
||||
nxt.append((x, y))
|
||||
check = nxt
|
||||
|
||||
return ret
|
||||
|
||||
while True:
|
||||
drown = spawn_drone(replant(xl, xm, yl, yr))
|
||||
replant(xm, xr, yl, yr)()
|
||||
wait_for(drown)
|
||||
utils.harv()
|
||||
|
||||
return ret
|
||||
|
||||
if __name__ == '__main__':
|
||||
set_world_size(32)
|
||||
clear()
|
||||
|
||||
jobs = list()
|
||||
for x in range(0, 4):
|
||||
for y in range(0, 4):
|
||||
jobs.append(grow_parallel(x*8, x*8+4, x*8+7, y*8, y*8+7))
|
||||
for job in jobs[:-1]:
|
||||
spawn_drone(job)
|
||||
jobs[-1]()
|
||||
|
||||
Reference in New Issue
Block a user