The AI’s send “There is an AI alive” message to the player all the time (use Always->Skip to skip a few frames, no need to do it every frame).

Now, the player has a property “Everyone dead” , that he increments automatically every frame
(or every other frames, with Skip as well).

But every time he receives “There is an AI alive” from AI, he makes “Everone dead” back to zero.

Now, when all AI are dead, he will stop zeroing “Everyone dead”, so it will eventually become
larger than, say, 10.

So if “Everyone dead” becomes sufficiently large, it should mean that there are no AI’s left
to send the “There is an AI alive” message.

This is how I would do it. The downside is that once they are all dead, it takes some time for
the player to realize that. But that is not necessarily bad, as the game might go on for a couple
seconds and then change scene to Victory! or whatever needs be done.

PS: To clear the AI after a task has been completed, you can do something similar with the
player sending a message to everyone and the AI’s have a counter. When they stop receiving
the message and the counter goes over a value, they endObject() themselves. I suppose it is
possible for the player to send a message to everyone (I do not know for a fact), so it should be
feasible.

It’s a good workaround but not very efficient. so from now on, use the code i wrote a post of me higher and use that. 1 always 1 python all you need to check for win or lose situation. You can still add a delay of how many tics you like, to not let it popup instantly.

Now you can also see how easy python actually is compared to the logic bricks.

I would like to get this code edited to get to a certain point where the fp triggers one of the scenes I have, due to not clearing the AI.

So a object that is located where ever, will be the switch on for a scene

own.scene.replace(‘lose_screen’)

Not sure if in addition to a change it is best to have it in one code or a separate one?

I was thinking may be use bricks for this, but then the AI has to be slow or fast to have success or failure, I am not to sure how to get a program to work a certain way. I guess may be the bricks would be a better option for this task.

Thanks.

def update_enemies(cont):

own = cont.owner
own['enemy_list'] = [object for object in own.scene.objects if 'enemy' in object]