From 5b18a3224bbb1b098b9577dcd14276c4b23847e6 Mon Sep 17 00:00:00 2001 From: Steve Dudenhoeffer Date: Fri, 23 Jan 2026 21:25:22 -0500 Subject: [PATCH] Add optional callback for grid planting and integrate maze utilities --- main.py | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index 111623b..ebbcd15 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,6 @@ import cactus import utils +import maze import pumpkins import sunflowers from __builtins__ import * @@ -12,8 +13,8 @@ def plant_carrots(width, height): 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) +def plant_alternating(width, height, plantWith, fn = None): + utils.plant_grid(width, height, plantWith, 0.75, False, fn) # Entire grid utils: # These are utilities to plant & harvest the entire grid with specific plants. @@ -38,6 +39,16 @@ def entire_grid_trees_and_grass(): utils.move_to(0, 0) plant_alternating(world_size, world_size, [ Entities.Tree, Entities.Grass ]) +def entire_grid_trees_and_grass_fertilizer(): + world_size = get_world_size() + utils.move_to(0, 0) + + def on_plant(x, y): + use_item(Items.Fertilizer) + + plant_alternating(world_size, world_size, [ Entities.Tree, Entities.Grass ], on_plant) + + def entire_grid_cactus(): world_size = get_world_size() utils.move_to(0, 0) @@ -76,12 +87,21 @@ if __name__ == "__main__": while num_items(Items.Pumpkin) < 500000: entire_grid_pumpkins() - for i in range(10): - entire_grid_trees_and_grass() + utils.move_to(0, 0) - entire_grid_carrots() - entire_grid_carrots() - entire_grid_pumpkins() + maze.place(utils.world_size) + maze.solve(utils.world_size) + + + # entire_grid_trees_and_grass_fertilizer() + # utils.harvest_grid(get_world_size(), get_world_size()) + + # for i in range(10): + # entire_grid_trees_and_grass() + + # entire_grid_carrots() + # entire_grid_carrots() + # entire_grid_pumpkins() while True: worldSize = get_world_size()