The Daily Click ::. Projects ::. TAHC2
 

Project: TAHC2
Project Started: 20th October, 2009 Last Update: 8th April, 2012
Project Owner: 3kliksphilip Project Members: Mr_Tom James Luke
Project Type: Secret Project Progress:

AI fun with fast loops
Posted 18th Aug 11, by Mr_Tom  
Here is a little peak at some of the code for the AI in TAHC2. This event allows a soldier to check for line of sight to all the enemies within an arc of vision and within a range and then target the closest enemy within that range.

It will save internally the ID value of its target enemy, as well as its coordinates and range. By adding a few MORE conditions, I should be able to let each soldier know how many allies are nearby relative to enemies and then make a fight or flight decision.

Any ideas for more AI features?
Preview


Posted by Fanotherpg 18th August, 2011

Wouldn't it be better for each enemy to calculate it's distance from player and just send the smallest value to the player?
 
Posted by Mr_Tom 18th August, 2011

there are indeed probably better ways to do it but this isnt just to a player character, it has to work for all instances of three different 'factions' of AI all detecting each instance of the other 2 groups. In this engine its blue red and yellow diamonds but that will probably be soldiers, zombies and civilians or something.
 
Posted by 3kliksphilip 19th August, 2011

There are a lot of things that would have been a lot easier to add if it was just you and a load of zombies. But we want it to be a proper living, breathing world, slowly decaying and being torn down by flesh-hungry zombies.
 
Posted by Dean James Reynolds 19th August, 2011

@3kliksphlip THAT IS THE LONGEST BIGGEST JUICIEST EVENT I'VE SEEN IN MY MMF2 HISTORY! NERDGASM. Lol Anyway it sounds super cool, for the "Arc-Range Detector" thing couldn't you just Use a detector active lol?
 
Posted by 3kliksphilip 19th August, 2011

It's Tom's event, not mine! By detector active, do you mean lots of shooty-out active objects to see what can and cannot be seen? Not sure if Mr_Tom's too keen on them...

We've both been trying out LOADS of different methods of making LOS, Fog of War etc, it's interesting to see how different methods can affect the framerate so much. I'm pleased with what we've managed so far, and it's something that's easily improved in future bug fixes and the like.
 
Posted by Mr_Tom 20th August, 2011

btw that event doesnt actually work.
 
Posted by UrbanMonk 25th August, 2011

The OR in the middle somehow doubled the size of that event.

Also it seems unnecessary, but then again I've never done complicated AI before.

Cool!
 
Posted by Sketchy 8th April, 2012

What a mess
You really need to get in the habit of using alterable values, spreading code out over multiple lines, and using the event *list* editor - it will make your code *much* easier to read and more efficient too.

Remember, it's always quicker to read a stored value than it is to recalculate it. All those duplicate checks for distance and line of sight are very inefficient. You should be doing the check once, and storing the result. Plus you should be using ForEach loops, not fastloops.
 


 



Project Forums


Favourite

Advertisement

Worth A Click