Raiders of the Long Dark Python

My peasant couldn’t build the palisade… Can you guys heeeeeelllllllllllppppp? Thanks sooooo much :smiling_face_with_three_hearts:

# Your goal is to protect the peasant and move to the right.
# Arryn Stonewall will defend the front, and command the soldiers.
# You need to cover the rear and command the peasant.

Arryn = hero.findByType("raider")[0]
peasant = hero.findByType("peasant")[0]

def chooseHeroStrategy():
    # Return either "fight" or "advance".
    # Try to stay 5m behind the peasant when not fighting.
    # Don't get more than 15m away from the peasant.
    enemy = hero.findNearestEnemy()
    if hero.distanceTo(peasant) > 10:
        return "advance"
    elif enemy and hero.distanceTo(enemy) < 10:
        return "fight"

def heroFight():
    # Stop the ogres from rushing past you to get to the peasant!
    # Hint: try to slow them down if you can
    enemy = hero.findNearestEnemy()
    if enemy:
    elif hero.isReady("bash"):

def heroAdvance():
    # Stay behind the peasant
    hero.moveXY(peasant.pos.x - 5, peasant.pos.y)

def choosePeasantStrategy():
    # Return "follow", "build-above", or "build-below"
    # Hint: use isPathClear() to determine where the hallways are
    if peasant.distanceTo(Arryn) > 5:
        return "follow"
    if hero.isPathClear({'x':peasant.pos.x, 'y':peasant.pos.y}, {'x':peasant.pos.x, 'y':peasant.pos.y + 10}):
        return "build-above"
    if hero.isPathClear({'x':peasant.pos.x, 'y':peasant.pos.y}, {'x':peasant.pos.x, 'y':peasant.pos.y - 10}):
        return "build-below"

def peasantAdvance():
    # Keep the peasant behind Arryn and her soldiers.
    hero.command(peasant, "move", {'x': Arryn.pos.x - 15, 'y': Arryn.pos.y})

def peasantBuild(x,y):
    # Command the peasant to build a palisade.
    hero.command(peasant, "buildXY", "palisade", x, y)

while True:
    heroStrategy = chooseHeroStrategy()
    if heroStrategy == "fight":
    elif heroStrategy == "advance":
    peasantStrategy = choosePeasantStrategy()
    if peasantStrategy == "build-above":
        peasantBuild(peasant.pos.x, peasant.pos.y + 5)
    elif peasantStrategy == "build-below":
        peasantBuild(peasant.pos.x, peasant.pos.y - 5)
    elif peasantStrategy == "follow":

Also, my hero refused to bash

And even though it might be a seed problem, my hero sometimes can’t attack the enemy fast enough so the peasant dies. I want to make sure my code always works. :smiling_face:

Your code is again working fine for me

it succeeds no matter how i submit its maybe ur gear prob

Oh yeah, sorry (20chars)