Raiders of the long dark

how to use hero.command(peasant,“buildXY”, peasant.pos) ,it can not work

You’re doing it wrong. It needs an X and Y. Do hero.command(peasant,"buildXY","[Build type],X,Y

example: hero.command(peasant,“buildXY”,“palisade”,17,35) Is it right?

Yeah, I think that’ll work

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 enemy:
if hero.distanceTo(peasant) > 15:
return “advance”
return “fight”
return “advance”

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:

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 hero.isPathClear(peasant.pos, {“x”:peasant.pos.x,“y”:peasant.pos.y + 10}):
return “build-above”
elif hero.isPathClear(peasant.pos, {“x”:peasant.pos.x,“y”:peasant.pos.y - 10}):
return “build-below”
return “follow”

def peasantAdvance():
# Keep the peasant behind Arryn and her soldiers.
hero.command(peasant, “move”, {“x”:arryn.pos.x -5, “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":

it can not work. why? help me.

Please learn to post your code correctly. The way it is now, we can’t see the structure. Help us help you. It’s very easy to do and just takes a tiny bit of effort. Please read this topic and format your code again correctly