2 things, One, the code i found on the other posts doesn’t work. 2. Here is my code
Ask the healer for help when you’re under one-third health.
loop:
enemy = self.findNearestEnemy()
currentHealth = self.health
healingThreshold = self.maxHealth / 3
if enemy:
# move to the healing point and say, “heal me”.
if healingThreshold:
self.moveXY(65, 46)
self.say(“heal me”)
# Otherwise, attack. You’ll need to fight hard!
else:
self.attack(enemy)
self.attack(enemy)
if self.isReady(“cleave”) and self.distanceTo(enemy) < 5:
self.cleave(enemy)
( i had to delete one if the notes it was in the way)
healingThreshold is always truthy (unless your maxHealth is 0).
Other nitpicks:
Cleaving with the long sword is almost useless after the forest levels (basically most ogres have > 50 health, cleave only does 15 damage).
You are doing too many “blocking” actions in the loop per iteration; try to do only at most one (except healing; that will take two)
You’ll need sufficient health (you didn’t say); assuming basic warrior types, maybe 600+?
The seeds generated for this level are completely messed up (for me, at least). So once you get your code right, you’ll probably have to submit multiple times.
i have 313 health. Also what is a backtick, “blocking” action and how is healingThreshold truthy (and what does truthy mean) ( I started last week I am fairly new to python and other programing languages.)
“Truthy” means that the expression evaluates to True. (Likewise, “Falsy” means the expression evaluates to False.) Pretty sure this was covered in the forest campaign.
healingThreshold is always truthy because x / 3 (for x ≠ 0) is a non-zero number, and all numbers except 0 are truthy.
If an action takes some time to complete it is considered “blocking” your code execution. (Hover over the spell palette to check; ie. self.attack is “blocking” because it takes almost 1s, self.findNearestEnemy is not “blocking”, self.moveXY is “blocking” because you can’t do anything else until reached your target position.) If an action is “blocking”, your hero is unable to do anything else until the action is complete. This is why you’ll want to have as few blocking actions as possible, to be able to choose to do what action as many times as possible.
The backtick (`) should be on the key with the tilde (~).
I’m also free to play and I had plenty of gems by the time I got to the desert level…you could simulate some games…
loop:
enemy = self.findNearestEnemy()
currentHealth = self.health
healingThreshold = self.maxHealth / 3
if enemy:
# move to the healing point and say, "heal me".
if currentHealth < healingThreshold:
self.moveXY(65, 46)
self.say("heal me")
# Otherwise, attack. You'll need to fight hard!
else:
self.attack(enemy)
self.attack(enemy)
if self.isReady("cleave") and self.distanceTo(enemy) < 5:
self.cleave(enemy)
This topic is now closed. New replies are no longer allowed.
If at first you’re locked, try again? Sounds wrong to me. Use existing topics! We got them for a reason. If other people’s code doesn’t work, try to find out why and post an updated version.
Your newest code has the problem that you only heal when an enemy is present. If you are below the threshold, but there is no enemy, then you won’t go healing, period. Try to change that first.
Any further discussion in an existing topic please.