file文件:
def move_all(func):
def wrapper():
for i in range(get_world_size()):
for j in range(get_world_size()):
func()
move(North)
move(East)
return wrapper
def Plant_all(Plant):
for i in range(get_world_size()):
for j in range(get_world_size()):
if can_harvest():
harvest()
if get_ground_type()!=Grounds.Soil:
till()
plant(Plant)
move(North)
move(East)
def watering():
if get_water()<=0.75:
use_item(Items.Water,(1-get_water())/0.25)
def fertilize():
use_item(Items.Fertilizer)
def plant_template_front(func):
def wrapper():
watering()
if can_harvest():
harvest()
else:
fertilize()
func()
return wrapper
#
网页链接 def plant_template(Plant,func,total=-1):
if total==-1:
while True:
func()
else:
cur_num=num_items(Plant)
while cur_num<total:
cur_num=num_items(Plant)
func()
return True
def move_lenth(vec,lenth):
dict={North:South,South:North,West:East,East:West}
if lenth>0:
for i in range(lenth):
move(vec)
else:
for i in range(abs(lenth)):
move(dict[vec])
def position(total_x,total_y):
cur_x=get_pos_x()
cur_y=get_pos_y()
gap_x=total_x-cur_x
gap_y=total_y-cur_y
move_lenth(East,gap_x)
move_lenth(North,gap_y)
if __name__=='__main__':
dict={(1,1):1,(2,2):2}
for i in dict:
print(dict[i])