My hero survives with 2995 health.
But I didnât use the invisibility ring.
It took me about a week of tweaking my code before I could survive long enough to get the 60 second bonus. I kept changing heroes and tactics and slowly lasting longer and longer until I finally got it on the bazillionth try.
@MunkeyShynes, I still need to protect the minefield.
Not necessarily. It blows up when I run my code too. It just has to survive for 30 seconds to pass the level. I noticed when I ran your code that youâre not continuously collecting coins. Itâs seems to stop for a while and then begin again. This isnât good because it limits the number of griffin riders you can summon. You need as many as possible to keep the ogres and munchkins away from the minefield for as long as possible.
Edit: It appears that once Tharin commands the griffin-riders to attack, he no longer goes back to collecting coins. Also, once the first fang-rider is killed, he keeps attacking even after its dead.
It appears that once the code begins a function, it gets stuck in that function. If you summon a griffin-rider, he stands in one place swinging his sword, presumably summoning that one griffin-rider over and over again. Once you attack, the code is stuck in the attack function until another condition is introduced that causes the code to move on to another function.
I managed to pass the level using your code and equipment by simply changing the move method to moveXY in the pickUpCoin() function. However, if youâre going to go after the 60 second bonus, itâs going to take a lot of reconstruction. This level works a ton better when you use arrays.
I tweaked a little bit your code and beat the level with the bonus with no so good armor.
def chooseStrategy():
# .... your code here
# if enemy.type is "fangrider" and hero.distanceTo(enemy) < 30:
# fangriders must be on the left to the mines
if enemy.type is "fangrider" and enemy.pos.x < 38:
# my function doesn't return "collect-coins" commented the rows
# else:
# return "collect-coins"
def heroAttack():
# Your code here
# same logic as above
# if enemy and hero.distanceTo(enemy) < 30:
if enemy and enemy.type == 'fangrider' and enemy.pos.x < 38:
hero.attack(enemy)
loop:
# Your code here
elif strategy == "fight-back":
heroAttack()
# Collect coins unconditionally after summoning and killing intruders
# elif strategy == "collect-coins":
pickUpCoin()
You can improve pickUpCoin() , summon a peasant to help you collecting coins, replace
for griffin in hero.findByType("griffin-rider"):
# with
griffins = hero.findByType("griffin-rider")
for griffin in griffins:
for not making a call to a method on every iteration
Wow. Didnât know that, thanks. But have no idea, why is it so.
btw guys, you know that you can go through the landmine, right? (you can literally walk through it)
I killed enemies myself before 35 seconds, then shielded for the rest of the time. Easy (Need max armor tho)
Didnât know that. Didnât even try it. I spent a week on this level, changing heroes and strategies, tweaking it little by little until I got the 60 second bonus. But then, I like to follow directions to get the point of the lesson. Iâve even made some notes of things I want to go back and change when I get time to improve it.
Well, if you are Ritic, then you can literally rig the landmines so the enemies canât get to it (shadow vortex) then you can scattershot everything in the vortex. Easy!
Thanks for all the help!
after some time I got it to work
This is weird when I ran it, it said success but when I submitted it, it said incomplete?
Just submit again until you get a seed that works.
Okay, thanks!
I do not know what happened but my hero is not commanding my griffinriders to attack!
If youâd like assistance, post the code that you have so far and advise of any errors you are receiving. We need information in order to figure out whatâs going on. Simply saying itâs not working isnât enough.
this is my code:
// The goal is to survive for 30 seconds, and keep the mines intact for at least 30 seconds.
function chooseStrategy() {
var enemies = hero.findEnemies();
// If you can summon a griffin-rider, return âgriffin-riderâ
if (enemies.length > 0) {
return âgriffin-riderâ;
}
// If there is a fangrider on your side of the mines, return âfight-backâ
if (enemies.length > 0) {
return "fight-back";
} // Otherwise, return "collect-coins"
else {
return "collect-coin";
}
}
function commandAttack() {
// Command your griffin riders to attack ogres.
var enemy = hero.findNearest(hero.findEnemies());
var friend = hero.findNearest(hero.findFriends());
if (enemy) {
hero.command(friend, âattackâ, enemy);
}
}
function pickUpCoin() {
// Collect coins
var items = hero.findItems();
for (var i = 0; i < items.length; i++) {
if (items && items.vlaue > 1) {
hero.moveXY(item.pos.x, item.pos.y);
}
}
}
function heroAttack() {
// Your hero should attack fang riders that cross the minefield.
var enemy = hero.findNearestEnemy();
if (enemy && enemy.type == âfangriderâ) {
hero.attack(enemy);
}
}
while (true) {
var strategy = chooseStrategy();
// Call a function, depending on what the current strategy is.
if (strategy == âgriffin-riderâ) {
commandAttack();
}
if (strategy == âfight-backâ) {
heroAttack();
}
if (strategy == âcollect-coinâ) {
pickUpCoin();
}
}