From 6a855ca675c21c8ef1460ec0ed54a26c93291141 Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 4 Jan 2026 01:46:59 -0500 Subject: [PATCH] abstracted the plant function to plant_grid --- f2.py | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/f2.py b/f2.py index 1c47639..74e13f3 100644 --- a/f2.py +++ b/f2.py @@ -63,7 +63,9 @@ def runColumn(col, worldSize): else: bushes_and_trees(worldSize) -def plant_pumpkin(width, height): +def plant_grid(width, height, plantWith, waterBelow, requireSoil): + tracker = 0 + others = {East:West, West:East} sideDir = East @@ -75,11 +77,16 @@ def plant_pumpkin(width, height): for col in range(width): if can_harvest(): harvest() - if get_ground_type() != Grounds.Soil: - till() - if get_water() < 0.75: + if requireSoil: + if get_ground_type() != Grounds.Soil: + till() + + if get_water() < waterBelow: use_item(Items.Water) - plant(Entities.Pumpkin) + + index = tracker % len(plantWith) + tracker += 1 + plant(plantWith[index]) # if it's not the last pass, then move if col < width - 1: @@ -90,6 +97,15 @@ def plant_pumpkin(width, height): sideDir = others[sideDir] move(North) +def plant_pumpkin(width, height): + plant_grid(width, height, [Entities.Pumpkin], 0.75, True) + +def plant_carrots(width, height): + plant_grid(width, height, [Entities.Carrot], 0.75, True) + +def plant_alternating(width, height, plantWith): + plant_grid(width, height, plantWith, 0.75, False) + # verify_pumpkin will verify that a pumpkin is planted in all tiles of a quadrant, and it will check that # the pumpkin isn't dead. if it's dead it will replant it. Returns whether any dead pumpkins were found. def verify_pumpkin(width, height): @@ -123,8 +139,16 @@ while True: worldSize = get_world_size() move_to(0, 0) - plant_pumpkin(worldSize, worldSize) + plant_pumpkin(worldSize / 2, worldSize / 2) move_to(0, 0) - while verify_pumpkin(worldSize, worldSize): + while verify_pumpkin(worldSize / 2, worldSize / 2): move_to(0, 0) - harvest() + + move_to(worldSize / 2, 0) + plant_carrots(worldSize / 2, worldSize / 2) + + move_to(0, worldSize / 2) + plant_alternating(worldSize / 2, worldSize / 2, [ Entities.Tree, Entities.Bush ]) + + move_to(worldSize / 2, worldSize / 2) + plant_grid(worldSize / 2, worldSize / 2, [ Entities.Grass ], 0.00, False) \ No newline at end of file