AI Crashavoid

AI Crashavoid

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

Post Reply
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

AI Crashavoid

Post by PicassoCT »

Hi, after experiencing some crashes with AI i have a suggestion. As far as i got it, most of the Crashes come along, because one of the Units is not giving back correct data, cant be identified or so on.

My Request: Can`t the AI forget most of its own Units & Buildings instead of Crashing and re-start again, as if the Old Things didn`t exist any more for it, just some Ally/Neutral Object to ignore ? That way a CON-Unit or the Com would still be active after the worst -
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

Invalid data is returned on enemy units, and it only really happens to allied units in the most obscure situations imaginable.

What you suggested as a solution is somewhat vague and I havent a clue what exactly you mean. But this should all simply be solved by checking retrieved data for error values and handling them accordingly...
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Post by PicassoCT »

So this Crash is avoidable ? - i just had some kind of reproducable AI Crashes when i built some Units and send them to them into the Defenses. There was the Line - UnknownUnit or something like that ... so i thought it might just forgotten its own Units.
Such things happened with fighters before, who were send to left upper Corner and were forgotten there, although they could have done terrible Damage to my Base. I imagined it as some Kind of "freeze" because of that failed attempt.
My (wrong) Suggestion was, if the AI can`t find this Units in its "Memory", it should not even try to search for them anymore, and give up whatever it had done till that Moment - starting from Zero. Just imagine it building a CommanderDouble - dropping it somewhere in your Backyard and that fellow begins the same "Programm"..

But that was mainly Missunderstanding on my part! Thx AF - how do you intend to solve that invalid Enemy Units Positions/Unittypes Problem?
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Post by PicassoCT »

So this Crash is avoidable ? - i just had some kind of reproducable AI Crashes when i built some Units and send them to them into the Defenses. There was the Line - UnknownUnit or something like that ... so i thought it might just forgotten its own Units.
Such things happened with fighters before, who were send to left upper Corner and were forgotten there, although they could have done terrible Damage to my Base. I imagined it as some Kind of "freeze" because of that failed attempt.
My (wrong) Suggestion was, if the AI can`t find this Units in its "Memory", it should not even try to search for them anymore, and give up whatever it had done till that Moment - starting from Zero. Just imagine it building a CommanderDouble - dropping it somewhere in your Backyard and that fellow begins the same "Programm"..

But that was mainly Missunderstanding on my part! Thx AF - how do you intend to solve that invalid Enemy Units Positions/Unittypes Problem?
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

Crashes are hard to eradicate completely in C++.
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Post by PicassoCT »

But my Suggestion was a "Dirty-Work-Around" by simply rebooting the AI, it would result in great Weakness of the AI Opponent, if he just would forget his Base and Units. Never seen the Alzheimerl Ilness win a Match!
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

picasso, if the AI tries tor etrieve a untidef for a unti it shoudlnt be able to get info about ti gets passed back a null pointer. Any attempt to use that point generates an access vioaltion error which crashes spring.

the unknown unit message you speak of I dont know about, obviously the error was caught and something else causes the crash.

I assume you speak fo AAI? Or is it TSI?

The corner bug is caused by nto catchigne rror values. Spring returns 0,0,0 or 0,1,0 as error values for positions, aka the corner. In AAI/NTai when the corner bug occurs its because the AI decides where to attack based on a threat matrix, and thus it polls all the enemy units on the map, assigns them a threat value then puts it on the map, but if the engien returns an error value and it isnt caught then that value is added to the corner of the threat matrix and the AI ends up picking the corner as its target because of the high matrix value. In OTAI it would attack the nearest unit so if it got an error value it would send them to 0,0,0 hence another instance of the corner bug.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

The only real way to fix the crashes is to fix the bugs in the AIs. Writing uncrashable code in C++ isn't that hard actually, as long as you keep a few things in mind:
  • always make sure pointers can not be NULL, or use them only after testing them for NULL.
  • always check return value of a function that may fail (theoretically meaning basically every function, especially file operations are important.)
  • just don't assume too much, e.g. don't assume config files are in a certain format: the user could have borked them, display an error, don't crash
  • always make sure the divider in divisions isn't 0
Post Reply

Return to “AI”