向日葵代码:只收瓣数最高的那朵
向日葵产出 Power。奖励来自收割当前瓣数最多的那朵。如果先收了瓣数更少的,整片田可能被毁掉。
向日葵的真实规则
- 种在耕过的土上。判断 `get_ground_type() != Grounds.Soil` 再 `till()`。当前游戏字符串把默认地面叫 Grassland,旧资料写成 Turf。不管叫什么,翻到 Soil 即可。
- 对长成的向日葵调用 `measure()`,得到瓣数(常见是 7 到 15)。
- 只收当前最大值。收完再量一遍,下一朵最高的可能在别的格子。
- 不要用普通循环把所有成熟的花一收而光。很多复制粘贴脚本就错在这里。
能跑的向日葵脚本
先种满,扫一遍格子,只收最好的那朵,重复到田空,再种下一轮。
python
def go_to(x, y):
while get_pos_x() != x:
if get_pos_x() < x:
move(East)
else:
move(West)
while get_pos_y() != y:
if get_pos_y() < y:
move(North)
else:
move(South)
def plant_field():
size = get_world_size()
for y in range(size):
for x in range(size):
go_to(x, y)
if get_ground_type() != Grounds.Soil:
till()
if can_harvest():
harvest()
if get_entity_type() != Entities.Sunflower:
plant(Entities.Sunflower)
def harvest_current_max():
size = get_world_size()
best = 0
bx = -1
by = -1
found = False
for y in range(size):
for x in range(size):
go_to(x, y)
if get_entity_type() == Entities.Sunflower and can_harvest():
petals = measure()
if (not found) or petals > best:
best = petals
bx = x
by = y
found = True
if not found:
return False
go_to(bx, by)
harvest()
return True
clear()
while True:
plant_field()
while harvest_current_max():
pass 如果脚本看起来没反应
- 先解锁向日葵,等花长成再开始收。
- 想多刷 Power,就保持整田都有花,让最高瓣数奖励一直触发。