SOLVED: "Unsuported Compare operator: undefined" for if-else statement in Endangered Burl

Howdy.

Python newbie.

Getting the following error message in a red popup for the Endangered Burl level –

“Fix Your Code: Unsuported Compare operator, undefined”

I have read all the hints, changed characters, reloaded the game, finished the prior level completely, searched and read all the Discourse discussions on “Endangered Burl”, searched github…etc…but cannot work around this.

I have isolated the problem to an issue with my “if” statements. The original, unchanged code for the level produces the same error. Here is my much-simplified bit of troubleshooting code –

hero.moveXY(18, 15)   
while True:
    enemy = hero.findNearestEnemy()
    hero.say(enemy.type) #added this to know when hero detects a particular enemy
    if enemy.type is not "burl":
        hero.attack(enemy)

If I #rem out the “if enemy.type” line, the hero will attack the nearest enemy as expected (a burl…). When I run the program above, the “Unsuported Compare operator” error message appears.

My platform is Win7/64 - IE11 on an i7/16Gb laptop, all updates current; video optimized.

Thank you.

Ray

1 Like

(deleted…because…)

1 Like

Figured I might as well make use of my time, so moved on to the next level “Picnic Buster.” As soon as I started the level I got the same error message…with the code examples already in place (I hadn’t touched a thing yet on the example screen shot). Is a library not loading, or ???

The problem succinctly is that the game does not like comparative operators, any of them (I’ve tried others, and get the same error message.) Do I need a more special pair of glasses or underwear or some other kit?

1 Like

@GuitpickinCowHippy I ran your code on a different level and the logic statement works. So I do not think that is the problem. (the level started with enemies in range of sight)

I was using the Fine Wooden Glasses which has the hero.findNearestEnemy() function.

A few things to note about the game. Some times error messages come up that do not relate to the cause of the problem. So take them with a grain of salt.

The hero.findNearestEnemy() function will return null if there are no enemies. So trying to access the enemy.type of a null may be the issue?

Have you tried checking the existence of the enemy variable before trying to access its attribute?`

1 Like

HtW -

I (just now) tried both the FWGs and the Mahogany glasses; get the same error with both.

I had included the hero.say(enemy.type) statement to help debug whether/when hero was detecting an enemy. I also included the initial hero.moveXY(18, 15) statement to position hero in immediate proximity to the advancing enemy to avoid null instances.

I have tried reverting back to simpler kit (faux fur hat, etc.) to see if that might be a contributing factor. I also went back to previous levels which used comparators, and those worked fine. EDIT - Actually, there has been no previous use of comparative statements, only simple if conditionals, so…

But, being an experienced (if stale) programmer, I shall persist exactly as if my continued employment depended on my solving this problem :). There is ALWAYS a solution.

Thank you for your reply. I will update here as/if/when I have a breakthrough…or a breakdown, perhaps…

Ray

1 Like

Just now went back to Patrol Buster level and tried a simple if enemy.type is “ogre”: statement, and get the same error. Hmm.

1 Like

Odd. I have tried the code as is, in a test level and it works.

  • you might have to refresh the browser, click on the hero etc to get the test level to start

Here are the game editors: https://www.codecombat.com/editor

Try entering the name of the level you are having issues with and loading it up.

If you fork the level you can change it as you please and try different tweaks.

I do not have access to the level in question to test it on my end as I don’t have a subscription. So this is about as far as I can test.

Here is the wiki to help you learn more about the level editor, if you are interested. It still has burs and sharp stabby parts, but after a while you learn how to do certain operations and its actually quite fun to use.

1 Like

I ran my code in the suggested test site, and saw the same errors.

CC’s support suggested clearing my cache, which I had already done several times, but that suggestion tripped something in my brain.

Internet Explorer (11) v. Chrome

So, I opened CC in Chrome, and ran my code. Perfect, nary a hitch, hiccup, fart or burp.

Lesson learned; case closed. I am not going to bother trying to figure out exactly what the problem is with IE. I’m too lazy, and there would not be sufficient ROI to justify the effort.

Thank you for your help.

Ray

3 Likes

You should probably just use chrome in the future

1 Like

Safari and FireFox seem to work well on my system also.

2 Likes

maybe Its the computer

1 Like