My hero is staying still and I don’t know what’s going on. Anyone know why?

hunter = hero.findNearest(hero.findFriends())
fenceMap = hunter.getMap()
# This function converts grid into XY coordinates.
def convertCoor(row, col):
return {'x': 34 + col * 4, 'y': 26 + row * 4}
# Iterate over fenceMap and build at fence at all 1s.
for j in fenceMap:
for i in fenceMap:
if fenceMap[i] == 1 and fenceMap[j] == 1:
place = convertCoor(i, j)
hero.buildXY("fence", place.x, place.y)
# Move back to the village after building the fences.
hero.say("FOR GLORY")
while True:
hero.shield()

I also tried

for j in fenceMap:
for i in fenceMap:
if fenceMap[i][j] == 1:
place = convertCoor(i, j)
hero.buildXY("fence", place.x, place.y)

for j in range(len(fenceMap)):
for i in range(len(fenceMap)):
if fenceMap[i][j] == 1:
place = convertCoor(i, j)
hero.buildXY("fence", place.x, place.y)

the hero builds fences normally, but the yetis kill the other peasants when they hit a fence, and I think it’s because of my code.

I don’t want to give you the answer because your very close.

[quote=“Needs_lots_help, post:1, topic:20795, full:true”]
My hero is staying still and I don’t know what’s going on. Anyone know why?

hunter = hero.findNearest(hero.findFriends())
fenceMap = hunter.getMap()
# This function converts grid into XY coordinates.
def convertCoor(row, col):
return {'x': 34 + col * 4, 'y': 26 + row * 4}
# Iterate over fenceMap and build at fence at all 1s.
for j in fenceMap:
for i in fenceMap:
if fenceMap[i] == 1 and fenceMap[j] == 1:
place = convertCoor(i, j)
hero.buildXY("fence", place.x, place.y)
# Move back to the village after building the fences.
hero.say("FOR GLORY")
while True:
hero.shield()

I also tried

for j in fenceMap:
for i in fenceMap:
if fenceMap[i][j] == 1:
place = convertCoor(i, j)
hero.buildXY("fence", place.x, place.y)

for j in range(len(fenceMap)):
for i in range(len(fenceMap)):
if fenceMap[i][j] == 1:
place = convertCoor(i, j)
hero.buildXY("fence", place.x, place.y)

Using the new code you posted, re-read the comment on line 16…it doesn’t say anything about shielding or looping…

for j in fenceMap:
for i in fenceMap:
if fenceMap[i][j] == 1: ??? i and j should be swapped because j is your 1st for loop i is 2nd
place = convertCoor(i, j)
hero.buildXY("fence", place.x, place.y)
# Move back to the village after building the fences.
hero.moveXY(starting position)