76 lines
1.9 KiB
Python
76 lines
1.9 KiB
Python
import utils
|
|
import mappings
|
|
import sunflower
|
|
|
|
def drone_plant(start_x, start_y, world_size_x, world_size_y):
|
|
for y in range(world_size_y):
|
|
for x in range(world_size_x):
|
|
utils.go_to_xy(start_x + x, start_y + y)
|
|
|
|
if not utils.is_empty():
|
|
harvest()
|
|
|
|
plant(Entities.Carrot)
|
|
|
|
while (num_items(Items.Water) > 0 and
|
|
get_water() < 0.7):
|
|
use_item(Items.Water)
|
|
|
|
def drone_poly(start_x, start_y, world_size_x, world_size_y):
|
|
for y in range(world_size_y):
|
|
for x in range(world_size_x):
|
|
utils.go_to_xy(start_x + x, start_y + y)
|
|
|
|
entity = get_entity_type()
|
|
|
|
if entity == Entities.Carrot:
|
|
companion = get_companion()
|
|
|
|
if companion != None:
|
|
ecom, (ecx, ecy) = companion
|
|
|
|
utils.go_to_xy(ecx, ecy)
|
|
|
|
if can_harvest():
|
|
harvest()
|
|
|
|
plant(ecom)
|
|
|
|
utils.go_to_xy(start_x + x, start_y + y)
|
|
|
|
harvest()
|
|
else:
|
|
if can_harvest():
|
|
harvest()
|
|
|
|
def farm(needed):
|
|
if num_items(Items.Carrot) >= needed:
|
|
return
|
|
|
|
cost = get_cost(Entities.Carrot)
|
|
|
|
for item in cost:
|
|
mappings.get_farm_function(item)(needed)
|
|
|
|
sunflower.farm(10000)
|
|
|
|
set_world_size(max_drones())
|
|
|
|
utils.clear_field(True)
|
|
|
|
while num_items(Items.Carrot) < needed:
|
|
if num_items(Items.Power) == 0:
|
|
return farm(needed)
|
|
|
|
def task_plant(id):
|
|
drone_plant(id, 0, 1, get_world_size())
|
|
|
|
def task_companion(id):
|
|
drone_poly(id, 0, 1, get_world_size())
|
|
|
|
utils.parallel_run(get_world_size(), task_plant)
|
|
utils.parallel_run(get_world_size(), task_companion)
|
|
|
|
if __name__ == "__main__":
|
|
farm(10000000000)
|