Sunflower Code: Only Harvest the Highest Petal Count
Sunflowers drop Power. The bonus comes from harvesting the flower that currently has the most petals. If you harvest a smaller one first, the rest of the field can be destroyed.
How sunflowers actually work
- Plant on soil. Check `get_ground_type() != Grounds.Soil` then `till()`. Current game strings call the default ground Grassland; older notes said Turf. Either way, till until it is Soil.
- `measure()` on a grown sunflower returns its petal count (commonly 7 to 15).
- Harvest only the current maximum. Then measure again — the next max may be a different tile.
- Do not harvest every ready flower in a simple loop. That is the mistake most copy-paste scripts make.
Working sunflower script
Plant the field, scan every tile, harvest only the best flower, repeat until the field is empty, then replant.
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 If this script does nothing
- Unlock sunflowers and wait until they finish growing before the first harvest.
- Need more Power? Keep the field full so the max-petal bonus keeps triggering.