Help with Mad Maxer Strikes Back, py

Level Name: Mad Maxer Strikes Back
In-game username: Djhulk4
Description of the bug: weird error that I cant understand even though I had already completed the level so I know the code works
Code:

# The smaller ogres here do more damage!
# Attack the ogres with the least health first.
while True:
    weakest = None
    leastHealth = 99999
    enemyIndex = 0
    enemies = hero.findEnemies()
    # Loop through all enemies.
    while enemyIndex < len(enemies):
        # If an enemy's health is less than leastHealth,
        enemy = enemies[enemyIndex]
        if enemy.health < leastHealth:
            # make it the weakest and set leastHealth to its health.
            weakest = enemy
            leastHealth = enemy
            #  Don't forget to increase enemyIndex by 1.
        enemyIndex += 1
    if weakest:
        # Attack the weakest ogre.
        hero.attack(weakest)
        pass

Screenshot of Error:


Console Logs of Error:

Inside updateConfig
aether-app-c0323b7996ab46e6ee56.bundle.js:123 Modern plugin chosen for: 'python'
play-685f05f3f3663762bd2a.bundle.js:1 PlayLevelView: loaded session e {cid: "c5825", attributes: {…}, _changing: false, _previousAttributes: {…}, changed: {…}, …}
app.js:117 Did-Load-Route
VM1127:39 Generated random seed 10911916833 of type submissionCount from sessionIDs ["5f736c838a8625003b09388d"] submissionCount 0
aether-app-c0323b7996ab46e6ee56.bundle.js:123 |上帝's Archer| Modern javascript detected, aw yeah!
aether-app-c0323b7996ab46e6ee56.bundle.js:123 |上帝's Archer| Worker initialized after 560ms
aether-app-c0323b7996ab46e6ee56.bundle.js:123 上帝: Let there be light upon Mad Maxer Strikes Back! (preload: false)
aether-app-c0323b7996ab46e6ee56.bundle.js:123 |上帝's Archer| Using modern language plugin: python
aether_worker.js:9 Modern javascript detected, aw yeah!
aether_worker.js:26 Using modern language plugin: python
aether-app-c0323b7996ab46e6ee56.bundle.js:123 |上帝's Archer| Generated random seed 10911916833 of type submissionCount from sessionIDs 5f736c838a8625003b09388d submissionCount 0
aether-app-c0323b7996ab46e6ee56.bundle.js:123 |上帝's Cyril| Modern javascript detected, aw yeah!
aether-app-c0323b7996ab46e6ee56.bundle.js:123 |上帝's Cyril| Worker initialized after 277ms
aether-app-c0323b7996ab46e6ee56.bundle.js:123 |上帝's Archer| ALAAAAAAAAAAAAAAAAAAAAAAARM!!
aether-app-c0323b7996ab46e6ee56.bundle.js:123 |上帝's Archer| TypeError: Tried to load an unsafe native value into the interperter:object / Kraggan
aether-app-c0323b7996ab46e6ee56.bundle.js:123 |上帝's Archer| Hero Placeholder had new Programmable problem: plan Line 12: TypeError: TypeError: Tried to load an unsafe native value into the interperter:object / Kraggan 0
play-685f05f3f3663762bd2a.bundle.js:1 Uncaught TypeError: Cannot read property 'castAether' of undefined
    at play-685f05f3f3663762bd2a.bundle.js:1
    at Worker.<anonymous> (play-685f05f3f3663762bd2a.bundle.js:1)
(anonymous) @ play-685f05f3f3663762bd2a.bundle.js:1
(anonymous) @ play-685f05f3f3663762bd2a.bundle.js:1
aether-app-c0323b7996ab46e6ee56.bundle.js:123 |上帝's Archer| The world ended in lost on frame 232
app.js:38 Saw view load event level-view level-view
aether-app-c0323b7996ab46e6ee56.bundle.js:123 |上帝's Archer| And it was so: (5.121ms per frame, 232 frames)
Simulation   : 1188ms 
Serialization: 23ms
Delivery     : 2ms
FPS          : 390.6
play-685f05f3f3663762bd2a.bundle.js:1 PlayLevelView: level started
play-685f05f3f3663762bd2a.bundle.js:1 could not find doc for getCooldown from undefined for this of {Defensive Infantry Shield: Array(2), Long Sword: Array(2), Twilight Glasses: Array(12), Sapphire Sense Stone: Array(8), Emperor's Gloves: Array(4), …} with item n {cid: "c6157", attributes: {…}, _changing: false, _previousAttributes: {…}, onFileUploaded: ƒ, …}
aether-app-c0323b7996ab46e6ee56.bundle.js:123 |上帝's Archer| ===== Profile: None collected =====
aether-app-c0323b7996ab46e6ee56.bundle.js:123 上帝: Let there be light upon Mad Maxer Strikes Back! (preload: false)
aether-app-c0323b7996ab46e6ee56.bundle.js:123 |上帝's Archer| Generated random seed 10911916833 of type submissionCount from sessionIDs 5f736c838a8625003b09388d submissionCount 0
aether-app-c0323b7996ab46e6ee56.bundle.js:123 |上帝's Archer| ALAAAAAAAAAAAAAAAAAAAAAAARM!!
aether-app-c0323b7996ab46e6ee56.bundle.js:123 |上帝's Archer| TypeError: Tried to load an unsafe native value into the interperter:object / Kraggan
aether-app-c0323b7996ab46e6ee56.bundle.js:123 |上帝's Archer| Hero Placeholder had new Programmable problem: plan Line 12: TypeError: TypeError: Tried to load an unsafe native value into the interperter:object / Kraggan 0
aether-app-c0323b7996ab46e6ee56.bundle.js:123 |上帝's Archer| The world ended in lost on frame 232
aether-app-c0323b7996ab46e6ee56.bundle.js:123 |上帝's Archer| And it was so: (5.448ms per frame, 232 frames)
Simulation   : 1264ms 
Serialization: 7ms
Delivery     : 1ms
FPS          : 367.1
aether-app-c0323b7996ab46e6ee56.bundle.js:123 No frames were changed out of all 232

~DJ, by the way this is my first post so sorry if I didn’t do something right

I think your problem is in line 15 when you say this leastHealth = enemy I think you need to say leastHealth = enemy.health

1 Like

thank you that was it, sorry I didn’t realize I had deleted, like 5 min before it was saying

I have never saw that error but maybe @Deadpool198 knows what is wrong.

All the enemies have seven health so then aren’t all of them weakest?

I don’t know I just started coding like a week ago I am still confused on most of this stuff but apparently I am able to get some of it do to me getting this far

Welcome welcome @Djhulk4 to the forum! It is a lovely place where you can share all kinds of stuff (appropriate of course), share bugs, and even get assistance for code! We suggest that you review this topic which shows all essentials of this board! And we suggest you review this topic which shows how to post your code correctly! Thanks!! :partying_face: :partying_face:
Try again in a few hours, if it still doesn’t work, try restarting the level and re-writing the code. If that still doesn’t work, try emailing this information to support@codecombat.com
Lydia

1 Like

Besides what Speedy found, you also need to indent your ‘enemyIndex += 1’ line one more time…right now, it’s a member of the while loop, but needs to be part of the if statement instead.

Hint: For most levels, the the pre-defined comments are indented to where the code should line up.

1 Like

Yep that is the right code