i have the gist of it down like I destroy most of the ogres but my code will not kill some of them can you help me please?
# Only build if you see an enemy.
# The function defines THREE parameters.
def maybeBuildSomething(buildType, x, y):
# Move to the position specified by x and y parameters.
hero.moveXY(x, y)
# Find the nearest enemy.
enemy = hero.findNearestEnemy()
# If there is an enemy
if enemy:
# then use buildXY with buildType, x, and y
hero.buildXY("fire-trap", 40, 22)
hero.buildXY("fence", 26, 35)
hero.buildXY("fire-trap", 40, 50)
hero.buildXY("fence", 54, 35)
pass
while True:
# Call maybeBuildSomething with "fire-trap" and the coordinates of the bottom X.
hero.buildXY("fire-trap", 55, 34)
# Call maybeBuildSomething, with "fence" at the left X!
hero.buildXY("fire-trap", 25, 34)
# Call maybeBuildSomething with "fire-trap" at the top X!
hero.buildXY("fire-trap", 40, 49)
# Call maybeBuildSomething with "fence" at the right X!
hero.buildXY("fire-trap", 40, 19)
# Only build if you see an enemy.
# The function defines THREE parameters.
def maybeBuildSomething(buildType, x, y):
# Move to the position specified by x and y parameters.
hero.moveXY(x, y)
# Find the nearest enemy.
enemy = hero.findNearestEnemy()
# If there is an enemy
if enemy:
# then use buildXY with buildType, x, and y
hero.buildXY("fire-trap", 40, 22)
hero.buildXY("fence", 26, 35)
hero.buildXY("fire-trap", 40, 50)
hero.buildXY("fence", 54, 35)
pass
while True:
# Call maybeBuildSomething with "fire-trap" and the coordinates of the bottom X.
hero.buildXY("fire-trap", 51, 34)
hero.buildXY("fire-trap", 51, 37)
hero.buildXY("fire-trap", 51, 31)
# Call maybeBuildSomething, with "fence" at the left X!
hero.buildXY("fire-trap", 40, 19)
hero.buildXY("fire-trap", 43, 19)
hero.buildXY("fire-trap", 36, 19)
# Call maybeBuildSomething with "fire-trap" at the top X!
hero.buildXY("fire-trap", 25, 34)
hero.buildXY("fire-trap", 25, 31)
hero.buildXY("fire-trap", 25, 38)
# Call maybeBuildSomething with "fence" at the right X!
hero.buildXY("fire-trap", 40, 40)
hero.buildXY("fire-trap", 43, 40)
hero.buildXY("fire-trap", 37, 40)
I know because there is a random seed and it changes every time. Please I will take you step by step and eplain it. So do this if enemy.pos.x < hero.pos.x: # buildXY a "fire-trap" on the left X. hero.buildXY("fire-trap", 25, 34)
This will tell your hero move left if the enemy.pos.x is less than your heroes.