refactor: adjust planting logic to use grid sections and add grass planting

This commit is contained in:
2026-01-04 18:36:26 -05:00
parent 95d8540116
commit cb702bed32
2 changed files with 44 additions and 17 deletions

50
f2.py
View File

@@ -1,12 +1,21 @@
import utils
from __builtins__ import Entities
def plant_pumpkin(width, height):
x = get_pos_x()
y = get_pos_y()
utils.plant_grid(width, height, [Entities.Pumpkin], 0.75, True)
utils.move_to(x, y)
while verify_pumpkin(sectionSize, sectionSize):
utils.move_to(x, y)
def plant_carrots(width, height):
utils.plant_grid(width, height, [Entities.Carrot], 0.75, True)
def plant_grass(width, height):
utils.plant_grid(width, height, [Entities.Grass], 0.75, False)
def plant_alternating(width, height, plantWith):
utils.plant_grid(width, height, plantWith, 0.75, False)
@@ -42,24 +51,31 @@ def verify_pumpkin(width, height):
while True:
worldSize = get_world_size()
sectionSize = worldSize // 3
utils.move_to(0, 0)
plant_pumpkin(worldSize / 2, worldSize / 2)
utils.move_to(0, 0)
while verify_pumpkin(worldSize / 2, worldSize / 2):
utils.move_to(0, 0)
plant_pumpkin(sectionSize, sectionSize)
utils.move_to(worldSize / 2, 0)
plant_carrots(worldSize / 2, worldSize / 2)
utils.move_to(sectionSize+1, 0)
plant_carrots(sectionSize, sectionSize)
utils.move_to(0, worldSize / 2)
plant_alternating(worldSize / 2, worldSize / 2, [ Entities.Tree, Entities.Bush ])
utils.move_to(sectionSize*2+1, 0)
plant_grass(sectionSize, sectionSize)
utils.move_to(worldSize / 2, worldSize / 2)
# the top right quadrant is 50% of the time pumpkin, 50% of the time carrots
if random() < 0.5:
plant_carrots(worldSize / 2, worldSize / 2)
else:
plant_pumpkin(worldSize / 2, worldSize / 2)
utils.move_to(worldSize / 2, worldSize / 2)
while verify_pumpkin(worldSize / 2, worldSize / 2):
utils.move_to(worldSize / 2, worldSize / 2)
utils.move_to(0, sectionSize+1)
plant_alternating(sectionSize, sectionSize, [ Entities.Tree, Entities.Bush ])
utils.move_to(sectionSize+1, sectionSize+1)
plant_pumpkin(sectionSize, sectionSize)
utils.move_to(sectionSize*2+1, sectionSize+1)
plant_carrots(sectionSize, sectionSize)
utils.move_to(0, sectionSize*2+1)
plant_alternating(sectionSize, sectionSize, [ Entities.Tree, Entities.Bush ])
utils.move_to(sectionSize+1, sectionSize*2+1)
plant_alternating(sectionSize, sectionSize, [ Entities.Tree, Entities.Bush ])
utils.move_to(sectionSize*2+1, sectionSize*2+1)
plant_pumpkin(sectionSize, sectionSize)