Where's The Problem About The Function "notWait()"

Here’s the problem: every time my hero collected 73 coins, the lower area on the right stopped producing coins. My hero could only attack the ogres.
Even if I’m able to solve this problem through placing flags, but I want to achieve this goal by writing code.
So I finished the function “notWait()”. The coordinate inside the function is the coordinate of the middle of the map. After hero walked there, he can find other coins and go to that part.
But this made a infinity loop. I don’t understand.
Please tell me why. Or just offer another idea which can solve the problem~ Thanks!:pray::pray::pray:

Try moving DY to the other areas.

Sorry, I mean try to move XY.

What type of glasses do u have

The strongest :sunglasses:
The one which can see through walls

Well, it didn’t work :sob:

Hi @Hammer, could you message me your whole solution so I could have a better understanding of your code? it’s hard for me to tell what went wrong from the screenshot. :wink:

The function notWait() is at the bottom :sweat_smile:

(solution removed)

There are some functions about yaks because they were written in the Sarven Desert. I copied them.

Please do not post final solutions. This is counter-productive toward the goal of this forum. Posting answers takes the whole point out of the game. Also, please format your code correctly. It should look like this:

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.say("Run to the nearest corner.")
        hero.say("My code is formatted properly!")

Thank you and welcome to the board.

Hi @Hammer, like @TheDemonPrince said, it is not encouraged to post solution code directly, (If it’s a code that is not working I think it should be fine. However, you didn’t format your code properly I guess that’s why it gets edited even if it’s not a solution.

Use pre-formatted text to post the code. You can find it in the toolbar above the input area.
Also it helps to add the level link to the post, it will take some time to locate the level you mentioned, like this

OK, The way I did this level is by defining 3 functions:

  1. collect coins by certain priority
  2. if there is not any coin the hero can see, let the hero move to the center of the map where he/she can have a clear view of the whole area (you mentioned that you have the google with infinity range, so maybe define a range for it? :slight_smile:)
  3. a function which allow the hero to attack nearest enemy whenever they spwan

I suggest you re-write your solution and change the function “notWait()”, it feels to me that this add un-necessary complexity to the level.

Let me know if it helps!:wink:

1 Like

Another way to do it is to use flag, when one area no longer spawn coins, manually guide your hero to other areas.


Thats wierd, why is that happening?


Well, I know, but I want to find out a way to achieve this without using flags

The second one is exactly what I want! “let the hero move to the center of the map where he/she can have a clear view of the whole area”. You inspired me that I could set a range because I can SEE the coin but unable to COLLECT it.
Thank you very much.

Glad it helped! :wink::+1: