abstracted the plant function to plant_grid
This commit is contained in:
36
f2.py
36
f2.py
@@ -63,7 +63,9 @@ def runColumn(col, worldSize):
|
|||||||
else:
|
else:
|
||||||
bushes_and_trees(worldSize)
|
bushes_and_trees(worldSize)
|
||||||
|
|
||||||
def plant_pumpkin(width, height):
|
def plant_grid(width, height, plantWith, waterBelow, requireSoil):
|
||||||
|
tracker = 0
|
||||||
|
|
||||||
others = {East:West, West:East}
|
others = {East:West, West:East}
|
||||||
|
|
||||||
sideDir = East
|
sideDir = East
|
||||||
@@ -75,11 +77,16 @@ def plant_pumpkin(width, height):
|
|||||||
for col in range(width):
|
for col in range(width):
|
||||||
if can_harvest():
|
if can_harvest():
|
||||||
harvest()
|
harvest()
|
||||||
|
if requireSoil:
|
||||||
if get_ground_type() != Grounds.Soil:
|
if get_ground_type() != Grounds.Soil:
|
||||||
till()
|
till()
|
||||||
if get_water() < 0.75:
|
|
||||||
|
if get_water() < waterBelow:
|
||||||
use_item(Items.Water)
|
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 it's not the last pass, then move
|
||||||
if col < width - 1:
|
if col < width - 1:
|
||||||
@@ -90,6 +97,15 @@ def plant_pumpkin(width, height):
|
|||||||
sideDir = others[sideDir]
|
sideDir = others[sideDir]
|
||||||
move(North)
|
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
|
# 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.
|
# 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):
|
def verify_pumpkin(width, height):
|
||||||
@@ -123,8 +139,16 @@ while True:
|
|||||||
worldSize = get_world_size()
|
worldSize = get_world_size()
|
||||||
|
|
||||||
move_to(0, 0)
|
move_to(0, 0)
|
||||||
plant_pumpkin(worldSize, worldSize)
|
plant_pumpkin(worldSize / 2, worldSize / 2)
|
||||||
move_to(0, 0)
|
move_to(0, 0)
|
||||||
while verify_pumpkin(worldSize, worldSize):
|
while verify_pumpkin(worldSize / 2, worldSize / 2):
|
||||||
move_to(0, 0)
|
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)
|
||||||
Reference in New Issue
Block a user