Hi everyone, I don’t really know what is wrong with my code and if there’s a lot of errors, it’s because my coding isn’t very good. This is my code:
# Our sleepwalking peasants are returning.
# But sleeping yetis are also coming.
# DON'T WAKE THEM UP!
# Build fences to let peasants through and stop yetis.
# Senick's prepared the grid map how to build fences.
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 i in range(len(fenceMap)):
for j in range(len(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.moveXY(30, 18)