can i have some help
Can you post your code and is this the last level, right? Cause if it is I’m not there…
@Shiloh_HuberElms a bit too powerful; use long sword. the cleave one. and could u show us your code formatted?
The best totoal health is around 1300 if you ask me.
Can you stick to one topic @Shiloh_HuberElms . It won’t help to have more than one. Let’s stay on this one:
this is my new code
hero.moveXY(63, 47)
hero.moveXY(81, 55)
enemy = hero.findNearestEnemy()
while True:
enemy = hero.findNearestEnemy()
if hero.health < 200:
hero.moveXY(48, 67)
break
if enemy.type == "archer":
hero.attack(enemy)
else:
hero.findNearestEnemy()
hero.attack(enemy)
You need a weaker sword. use the sword with cleave. and can you format your code? the whole thing properly?
the armour is good. but the sword is too powerful. your soldiers will die too easily
All that matters is that you take the items with the most activated abilities, which the AI can’t use.
Can someone help me? i cant beat this level. here is my code:
self.moveXY(68, 78)
back = 0
while True:
enemys = self.findEnemies()
index = 0
closest_soldier = None
soldier_dist = 999
closest_archer = None
archer_dist = 999
closest = None
dist = 999
while(index<len(enemys)):
distance = self.distanceTo(enemys[index])
if(enemys[index].health>0 and enemys[index].type != "sand-yak" ):
if(enemys[index].type == 'archer' and distance<archer_dist):
archer_dist=distance
closest_archer = enemys[index]
if(enemys[index].type == 'soldier' and distance<soldier_dist):
soldier_dist=distance
closest_soldier = enemys[index]
if(distance<dist):
soldier_dist=dist
closest = enemys[index]
index +=1
if(closest_soldier and soldier_dist<10):
enemy = closest_soldier
elif(closest_archer and archer_dist<20):
enemy = closest_archer
else:
enemy = closest
if(enemy):
if(self.health<self.maxHealth/2.5 and back==0):
self.moveXY(40, 85)
back = 1
elif(self.health<self.maxHealth/5 and back==1):
self.moveXY(40, 85)
back = 2
elif(self.isReady("jump") and self.distanceTo>15):
self.jumpTo(enemy.pos)
elif(self.isReady("bash")):
self.bash(enemy)
elif(self.isReady("power-up")):
self.powerUp()
self.attack(enemy)
elif(self.isReady("cleave")):
self.cleave(enemy)
else:
self.attack(enemy)
and this is my setup:
Hey, @Gamestriker9!
So, this topic covered how to beat this level. Basically, the clone mimics your stats. The only thing differentiating you and your clone is your code. You have to create a program that does things your enemies do not.
Hint: use abilities, especially those like “cleave” and “chain-lightning”
I recommand you the long sword, cleave the archers and then hide. Punch enemy hero also works.
I picked the sword called “sharpened sword”, the best shield & 2nd best armor, and used no special abilities apart from my brain also, @MlifShake, how would you hide using a warrior, and how would cleave help?
Invis ring, then cleave archers, then shield until you have next invis, then retreat.
The enemy’s default code is to attack the nearest enemy, so you can act as a meat shield standing there and take damage (use deflector).
Also, except for cleave, I used nothing else.
You can check findStrongest() within part of your code, the code below is a hint to the players are stuck
def findStrongest(units):
bestHealth = 0
bestTarget = None
unitIndex = 0
while unitIndex < len(units): # While the index is smaller then the length of units
unit = units[enemyIndex] # Get a unit from the index
if unit.health > bestHealth: # If this unit's health is greater than we seen
if unit.type == "sand-yak": # If the unit's health is from the yak...
break # ...break out so you don't accidentally attack it
bestHealth = unit.health # otherwise, set the bestHealth to the unit's health
bestTarget = unit # Set the bestTarget to the unit
unitIndex += 1 # Increment index to move on to the next unit
return bestTarget # Returns the bestTarget to be the strongest enemy
while True:
enemies = hero.findEnemies()
strongest = findStrongest(enemies)
# And on with using your abilities, hope this helps people that are stuck
Welcome to the forum @Aladore_Lycan1 !
Maybe try putting this line under the if enemy statement, it should remove the error
I still get the same error message.
Can you please post your new code