Wednesday 30 June 2010

The Big Ai Test -> Post Debug Hell - Corporate Devs Free Beer!?

BBBBBBZZZZZZZZZZZZZzzzzzzzzzzzzzzzzzzzzzzzzzZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
Anyone else got a funny buzzing in their ears ... ?


Whoa - almost missed a monthly update ... so ignoring the sudden outbreak of tinitus ...

So ... Ai is ... about sorted ... there's a few rough edges here and there ... but it's about sorted.



It's got Dijkstra pathfinding ported over from my original ancient demo and it's got basic dynamic avoidance for when they run into each other ... something more high tech than my previous "bounce off each other" that dated from way back when.

And it's really 3 Ai routines in one. There's my originally conceived Call of Lawyers style trigger based, squad Ai movement goals ->. It's a scripted design to get Ai exactly where they are wanted.


It was supposed to be "gratuitous bunny slippers" but turned into "gratuitous bum shots" ...

And then there's two fully dynamic routines.

First up, is a simple "move towards nearest enemy", think of it like rubber banding. The Ai selects the nearest target and moves towards it regardless of whether it could actually be detected or not. It's supposed to be a little trick to force action to happen, and can be used against a specific target - eg: the player.

The second method is purely dynamic, with the Ai deciding it's goals visually and then with an audible fallback if it cannot see anything. Failing to detect any targets at all means that it will patrol randomly.

Visual targeting, whether for dynamic goal decisions or just plain shooting is decided across a number of visual factors from how alert the Ai is, the angle at which the would be target is, the distance, the target's pose - lying in a bush being a lot harder to see than jumping up and down, whether the target is firing itself (aim for muzzle flash at long range), and so on and so forth.

Hearing is done by a mixture of Ai alertness, target noise - if it's shooting, or close range movement - creeping around just behind. There is also a state of "global alertness" so if an Ai is far away but can still hear gunfire they'll stop chilling and start to investigate. All of this enables the most basic use of stealth possible.



Each of these 3 methods come off the main Ai routine and allows for instant changing between them if required --- it also helps to keep the Ai integrated, and avoids many different datablock/functions from being created for seperate types of Ai --- though it also might have just been me wanting to try and keep things tidy and integrated together as one. After so much going back and forth between things as I teach myself development - I didn't fancy doing that with my Ai, so it's pretty much everything that I can think of, which I would need.

In testing this integration works fine for both ranged-based and melee-based Ai.


Zulus! ... I mean, PathNodes! ... thousands of 'em

Ai have stress and threat levels (one used to check the other) so depending on how much threat they are facing depends on how they act, from running around normally -> to ducking and being cautious -> to being pinned down -> falling back -------> to full blown rout with accompanying cover head and flee animation.

All of these states can also be scripted/triggered rather than engage organically, and of course they can also be ignored.

Needless to say all this took a fair bit hammering away at the old keyboard - and then even more time debugging all of my errors - especially as it seems far too easy to get one thing working, go on to another, and then break the first. Mr Fairfax has my sympathies ...

After much happily hunting around a maze working all the issues out -

... like isObject really means doesExist which technically isn't the same thing ...

- it was time for some large scale testing and a chance to try out a community script snippet for automated pathnode grid creation, which works quite nicely out of the bag.



First up is something I seem to have recorded at entirely the wrong size - cos that ain't 720p. It's an initial outdoor test with a fairly widely spaced nodegrid.

There are 32 Ai, split into 2 teams, all of whom are using the Dynamic audio/visual Hunting routines. It's a bit laggy with the forward rendering of the shadows, and the paths were not precompiled but getting built from the node grid when requested. Without the extra overhead of the video it was giving around 40fps in-game. It does give quite a nice "organic feel to a battle".


1080p test - but you'll have to click the YouTube sidn to get the HiDef source ... though YT insists on chewing on my quality

Second up is the same battle but with shadows disabled to lessen the stress on the GPU and 50 dynamically hunting Ai to heighten the stress test for the CPU. Paths are precompiled this time. Even in the midst of one helluva firefight, fps keeps between 60-90, depending on how many Ai have to render LOD_0 up close to the camera.

So all in all, I'm pretty chuffed, --- or maybe that should just be relieved ... and talking about blowing your own trump-vuvazela... stuff!

Also stuff - BBBBZZZZZZZZZZzzzzzzzzzzZZZZZZZZZZZZ and a big ball of fire in the sky the likes of which this part of cloudy Auld England doesn't get terribly much of, have been vying for my attention this month. As had a weekend break --- No use of a contomiter for three days! Possibly a new personal record though I did get to go to some Corporate Dev's own bar (instead of a sign advertizing the company building, they just have a normal brass name/number plate with the face buttons of their controller in the corner) ... and the booze is subsidized! 6 bottles of imported Euro lager and free popcorn for 7 quid (10bucks). It is still just a glorified canteen with coloured chairs though.

I was the only person wearing a tie and suit jacket. ... goddamn hippies ...