Underground Business-Help!

Can’t move to the X point…

What I think is wrong with your code is that there is always skeletons near your hero and attacking them just ignore the moveXY code.

I believe if you replace your if enemy with:

if enemy and hero.gold < 300:

it should fix the problem

Tried before ,didn’t work…

I checked the answers of other players in the scoring board and sometimes your code will work but not always.
I guaranteed the success by putting “if hero.gold >= 300” as the first condition and all other conditions as sub conditions with “elif” and “else”. I think the mimic or the hero must collect the gems from the peasants, so I made the hero oscillate ( with move not moveXY) between the enemies and the gems.


checked the gold before going to exit:

pet.debug("hero's gold is " + hero.gold) 

( anybody has access to pet.debug without advanced books)

You normally won’t get the gold if the mimic moves directly to the hero’s position. You have to make the mimic move 3 meters up of the hero like this: pet.moveXY(hero.pos.x, hero.pos.y + 3).

1 Like

ah I had trouble with this too but I figured it out.

1 Like

Finally I used flag… but I don’t think it’s the best solution…

If you have finished the level and are in the search of better solution click “Scores” , choose one of the tabs on the left and click on “Watch”. You can find tons of clever thinking in every level.

I didn’t use flag for this.

yeah just look at the scores.

Can someone who has finished the level explain what is going on in the code of Hazow ( Top Players by Gold Collected, All-Time)

var isOver = false;

function onSpawn(event) {
    //  moving pet
    isOver = true;
}
pet.on("spawn", onSpawn);

while (!isOver) {
    // fighting
}
while(true){
     // collecting excess gold and going home 
}

How can this structure be exploited and is it faster and more efficient than conventional resolutions?

I would help but I don’t do java.

sorry
(20 characters is really getting annoying)

1 Like

Yeah 20 characters are really annoying.

I think he/she did that so that no one could could copy their coding. A lot of people changed their code to comments or erased their code so that no one could copy it.

@Seojin_Roy_Lee The code of Hazow is still intact - little modification so it cannot be copy&pasted:

var isOver = false;

function onSpawn(event) {
    // go to the corners
    pet.moveXY(hero.pos.x, hero.pos.y);
    isOver = true;}

pet.on("spawn", onSpawn);

while (!isOver) {
    var enemy = hero.findNearestEnemy();
    if(enemy){
        while (enemy.health > 0) {
            hero.attack(enemy);}}
    hero.moveXY(20, 34);}

while(true){
    var coin = hero.findNearestItem();
    if(!coin){ break;}
    hero.move(coin.pos);}
hero.moveXY(50, 34);

@Gamestack in this case simply remove braces and change a little bit the indentation and you have python from JS

Cool. Thx. I’ll check that.