From bef9d6a1c17b7520d6c924d78f8dd49956cd2400 Mon Sep 17 00:00:00 2001 From: Josh Creek <8179928+jcreek@users.noreply.github.com> Date: Tue, 23 Dec 2025 15:11:32 +0000 Subject: [PATCH] feat(*): Add pumpkins --- pumpkins.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 pumpkins.py diff --git a/pumpkins.py b/pumpkins.py new file mode 100644 index 0000000..966f31f --- /dev/null +++ b/pumpkins.py @@ -0,0 +1,50 @@ +import helpers + +# Pumpkins grow like carrots on tilled soil. Planting them costs carrots. + +# When all the pumpkins in a square are fully grown, they will grow together to form a giant pumpkin. Unfortunately, pumpkins have a 20% chance of dying once they are fully grown, so you will need to replant the dead ones if you want them to merge. + +# When a pumpkin dies, it leaves behind a dead pumpkin that won't drop anything when harvested. Planting a new plant in its place automatically removes the dead pumpkin, so there is no need to harvest it. can_harvest() always returns False on dead pumpkins. + +# The yield of a giant pumpkin depends on the size of the pumpkin. + +# A 1x1 pumpkin yields 1*1*1 = 1 pumpkins. +# A 2x2 pumpkin yields 2*2*2 = 8 pumpkins instead of 4. +# A 3x3 pumpkin yields 3*3*3 = 27 pumpkins instead of 9. +# A 4x4 pumpkin yields 4*4*4 = 64 pumpkins instead of 16. +# A 5x5 pumpkin yields 5*5*5 = 125 pumpkins instead of 25. +# A nxn pumpkin yields n*n*6 pumpkins for n >= 6. + +# It's a good idea to get at least 6x6 size pumpkins to get the full multiplier. + +# This means that even if you plant a pumpkin on every tile in a square, one of the pumpkins may die and prevent the mega pumpkin from growing. + +def till_and_plant(): + if get_ground_type() != Grounds.Soil: + till() + if get_entity_type() == Entities.Pumpkin: + helpers.harvest_if_possible() + plant(Entities.Pumpkin) + else: + helpers.harvest_if_possible() + plant(Entities.Pumpkin) + +def clear_bad_pumpkins(): + for x in range(get_world_size()): + for y in range(get_world_size()): + if get_entity_type() == Entities.Dead_Pumpkin: + # Planting a new plant in its place automatically removes the dead pumpkin, so there is no need to harvest it. + plant(Entities.Pumpkin) + move(North) + move(East) + +def harvest_pumpkins(): + for x in range(get_world_size()): + for y in range(get_world_size()): + till_and_plant() + move(North) + move(East) + + for i in range(5): + # 5 because the decay rate is 20% so 5 passes should usually clear all bad pumpkinks to maximise harvest + clear_bad_pumpkins() \ No newline at end of file