A technical and pseudo psychological peek into Raven Shields AI


In putting the last touches on Private Airport (kai), I’ve been spending some more time to study how the games Artificial Intelligence works, special thanks to [SAS]_Maj_WIZ for pointing out a more thorough list of developer diagnostics ;). Since this is the closest look I’ve taken at Rainbows AI in about 5 years, and an even closer study of Terrorist and Hostage behaviour, I think it’s only fair to make a journal entry about it.

Here is a summery of my findings, and annotations about theories I’ve maintained for years:

The laser eyebrow problem

From the standing position, the source of each pawns aim is directly behind the skull, roughly where the head would be if the pawns stood erectly (like a tango). The point of aim, passes directly though eye level. When crouched the point is roughly near to behind the collar bone, and passes through the lower nasal cavity. In prone, it is much the same.

In real life (and any decent shooting game), that aim point should be chained to the weapon in the players hands.

How Tangos Fire Out Their Ass

Experiments with ShowFOV and GunDirection, demonstrate that there is no real connection between pawn animations, where the AI is looking, and where the AI is actually aiming; or as I have been saying for years, What You See Is Not Always What You Get. The most humerus moment in my testing, occurred with the Rear Guard “Facing” the rear but covering the elements front. My research shows that even if Rainbow is aiming at the target, they fail to engage terrorists outside their point of view. I.e. in the case of that rear guard, if a tango had walked up behind the element: it would’ve taken a moment for his aim point to realign with his field of view, resulting in the death of 2/3 the Rainbow AI element!

In short, this means that the AI walks around much like a Tank with an independent turret, only the artificial intelligence is riding in the drivers seat, not the gunners. Coincidentally, this is why the game has no real concept of muzzle clearance (as I have also been saying for years).

This may explain some of the more rolling on the floor laughing moments that often occur, when a “How close can you go” opportunity crops up in game. To prove a point, I cornered a tango in a corner and had him empty his magazine into me. Side stepping away and deactivating GOD mode, he was able to fire several rounds point blank into my pawn, before his aim point rotated to my new position – I died once the aim point got to me, not when the animations showed him shooting me.

Also it seems that hostages always seem to aim directly at Rainbow, but luckily the terrorist AI doesn’t notice that (or they would always see us comming).

So far, these tests satisfactory seem to prove that my ~6 years old hypothesis, about the “Tango firing out of his arse” problem being is indeed codified into Raven Shield by design. Between network latency, the (usual) use of unreliable UDP communication methods for multiplayer game play, and the systems divergent means of rendering and applying these actions (seeing, aiming, firing, hitting), suggest that there is no way to solve the aforementioned (annoying) problem without fundamental changes to the way Raven Shield works. Since that is not viable, one can only look at working around the problem; even with more processing power then a Cray XT5 super computer, you also need a very high throughput network link between clients and server, likely to an extend that is unobtainable over the modern internet.

In laymen’s terms, this means no matter how good your computer hardware or internet connection is,  the computer will always be able to cheat you. Should that change, most likely it will be so far in the future, we will be dead by then.

On the upside, I do believe that why the game is like this, was probably done in order to give the player more ‘time’ to shoot first (yes, some tangos have very slow reaction times: this appears why). It also appears to explain many of the discrepancies between common online play, single player, and LAN parties. However it is also worth noting, that this may have instead occurred due to limitations of the Unreal Engine (2) or Raven Shields own design and implementation.

Interesting Note: Now that an illegal RvS 1.60 SDK is available on the internet, it may be possible for cheaters to develop a method to take advantage of these problems. Imagine walking up on some one in Adversarial because you think they are looking away, then they shoot you out their arse ;). Luckily the engine has some respectable counter messures to such becoming (more) common.

Looking at the AIs skills

One of the very few things, that I have ever been able to praise Rainbow Six 3: Raven Shield for, is that the Rainbow AI often “Appears” to be covering their sectors, even if they totally suck at room clearing. In fact, their room clearing behaviour suggests that either the AI engine is extremely limited, or the game was made by people who know as much about CQB as the average RvS player, that is: absolutely nothing.

Since there is no connection (see above) between where the character on screen is looking (seeing), and where they are aiming (pointing), this means What You See Is Really Not What You Get. Have you ever seen in Single Player, where Rainbow is looking straight at a tango and gets owned without a shot? This is why. It is also why we can do the same to tangos online.

Terrorist movement is closer to What You See Is What You Get, then Rainbows; IMHO the movement for Rainbow was done to ‘look’ more realistic then it actually is (or the AI programmer sucked even worse then everything thinks). They also seem to have a tendency to remain fixed on hostages with their aimpoint, even while walking around a fair distance away. Ever got first sight on a tango, shot him trice, only to curse at him “Magically” shooting the hostage with barely a twitch? Yeah baby… he had that gun pointed at the hostage, all the while he was looking into your eyes.

Every type of AI in the game, demonstrates very poor skills at getting around the maps. I remember when I first started learning about pathing in Unreal Engines, I couldn’t help but think, “We’re still living in a dark age”… and that’s all I will say on that lol.

Hostage behaviour, well, what can I say… what you see is exactly what you get: a stupid slug. On the upside, the terrorists do not show any signs of being aware to hostages; this is why for example, if a Rainbow goes down while escorting, and the hostage becomes a prisoner again, the terrorist may continue walking past. All the fancy stuff about the tangos shooting the hostage, is a mixture of the games rudimentary AI, and things that map designer has programmed.

Since I don’t believe in taking advantage of the map design, or exploiting things I shouldn’t know in real life about the missions, I will not make a closer study of that kind of stuff, nor will I tell others much about it. If you want to figure out how to take even that (ugly) edge over the game, you can go learn how RvS works for yourself. Beat it punk.

I just study the mechanics and psychology of the games AI, you know, the whole know your enemy thing. In actual ops with SAS, I tend to employ more knowledge of human psychological behaviour then how the game was designed. That is both by intention

A Random Bullet Test

A tango surrendered and I fired a shot into his head, the round should have impacted his hand (placed on his head). There was a blood puff and a bullet hole in the wall directly behind his head, however the tango survived. Weapon used was an M16A2 at approximately 350-450 unreal units.

This suggests that terrorists have no brains, since the angle means the bullet must have penetrated his skull, and his hand (I pray) being all that slowed the high velocity FMJ round down enough to prevent a kill. Suggesting that any hit box modifiers applied, were for a ‘hand’ (arm) shot rather then a head shot.

N.B. other tests I have done over the years suggest this kind of problem and the ballistics model used, is why sniper rifles may incur a two-shot requirement on tango kills, and the exaggerated effects of JHP/FMJ selection on SWAT 4.

Anyone still awake and scratching their heads?



All this is based on roughly 6+ years of playing the game, much more then trivial knowledge of such matters, and being a very, highly observant individual.

Oh Brother, Where Art Thou Noggin?

With the questions my brother has been asking me about his computer, and his “Plans” for rebuilding her into a higher end machine, I’m starting to wonder how he even got one built in the first place… what was it, in one ear and out the other? lol.

And I am the moron, who was barred from building his own computer !?

Marc Espie on portability

Marc Espie on portability: “
A short while ago, Marc Espie (espie@) wrote to the ports mailinglist with a short rant about autoconf. His mail gives good insights into the problems porters face when dealing with GNU software, especially those using autoconf.”

This actually describes one of the many reasons I despise working a lot of other ‘programmers’ in this world, many of whom exhibit even greater levels of brain injury then that post takes as examples.
In my not so humble opinion: GNU autotools is either a good idea gone horrible wrong (in practice), or a royal brain fuck that just got out of hand. Users who can use such tools properly, seem to be falling by attrition to younger developers, many of whom (in my experinces anyway) wouldn’t know portability if it strung them on the keester like sitting on a scorpion. The GNU build system can an extremely good tool chain to work with, or it can be your worst freaking nightmare; a lot of people just don’t seem to care any more. My policy has always been, to support what I use (BSD/Win), and trying to minimise the heartache of getting code built on another platform.
Although the GNU project is perhaps the largest distributor of infectious disease on the Internet, I blame the developer idiocy I see around me, on the youth and not on the software. Most “Old wizards” seem to actually know their tools…..

Mario: Treat your tools like a friend. Keep ’em by you. Never let ’em down, and they’re always at your side.

Luigi: Hey, Mario, how is it that for every situation that could possibly come up, you always got a saying about tools? 

Mario: I got ’em from Papa. 

Both: He got ’em from Grandpapa!

Private Airport (kai) going RC

After much abuse and perhaps a weeks kicking, or two thirds of a week in man hours, the first map in my RvS map pack is almost complete. The first one, as one might infer from the title above, is a custom version of the Private Airport. In having to find something reasonable to prefix or suffix the maps with, I chose the simple suffix of ‘(kai)’ for each map, why? Just blame it on an Endless Waltz.

The map has been optimized for Co-Op Mission and Team Adversarial play, but should function as expected in most game types; there is also a tweak for Bomb mode. You would still recognize it as the Private Airport, and I have tried not to destroy the maps excellent flow, merely augment it and revivify the game play. Several areas are in my humble opinion, more realistic, while still reflecting the intended feel of the map. Since there is virtually no one left alive, who is playing Raven Shield off a 32MB or 64MB AGP card, I have also taken the liberty of “Fixing” the portaling a bit, trading the frame rate on your toaster oven, in the hopes of reducing some of the floating guns a wee bit (in so far, as that is actually doable in this fucked up game). I also seem to have fixed one of the most annoying rooms in all of RvS, in that process ;). See, I do know what I have been cussin’ at for all these years :-P. My changes shouldn’t impact anyone who has a computer that could play RvS without extreme abuse in the first place (Yes, it is time to give up on your 4MB 3dfx card and buy a new computer), and shouldn’t effect performance for 96-98% of players.

In architecting the changes for mission mode, the thought that kept running through my mind is “This map is gonna be pure evil”, and if you enjoy doing things Ninja style as much as I do, on top of forceful dynamic fare, one will no doubt enjoy playing the coop mission on ROE: RED and saving the day like a sneaky son of a gun, hehehe. Things have been engineered to offer a more tactical experience to both coop and advers. mode, and I think my Private Airport (kai) will be much better suited for Force on Force Training, not to mention bounding drills.

The changes are numerous, tallying over 25 completed tasks on my RTM, and countless dozens of on-the-fly changes that occurred to my twisted mind during editing phase. Being a methodical type about getting my plans carried out, of course corrections and issue tracking was pushed into my RTM list as needed, instant triage.

I will likely make the map available to a select few for closed door testing, once I’ve finished a bit more private testing on the airport. After that, I would say the map is essentially good to go out the door. There is still an unfinished portion of the map, that is non essential, but to complete it properly, would entail triple the work and completing a subsequently desired feature set. There is also a few other features I would like to add, such as maximizing the sniping opportunities even further, but that can wait until later. The next iteration of the map, will likely contain such changes.

For now, I’m content to move onto the last leg of testing the map, and to get started on my ‘next’ one, mauhauhauahauhauha!!!!!

Building better memory management for high performance wired/wireless networks: Part 1

Building better memory management for high performance wired/wireless networks: Part 1: “The authors describe a variable pool memory management scheme that has been implemented for LTE and WiMAX protocol stacks and has exhibited excellent performance, especially when compared to traditional fixed-pool implementations.

Email this Article
Add to digg
Add to del.icio.us


Maybe I’m a freako, but I find these this article set to be intensely interesting.
In my travels, I’ve read plenty of miles of code, including more then a few programs that go as far as memory pools, and even writing a real memory allocator for all practical intents and purposes. This ranges from programs simpler then most (non UNIX) users would think trivial, all the way to more “Complex” systems. In fact, I’ve even spent time spelunking kernel virtual memory and file system code, which can be a truly interesting set of experiences in their own right.
In working on Stargella, I’ve wondered whether or not using such techniques would be a viable method of improving the games performance, but for this point in time, everything relies on the C library to work wonders where dynamic memory is needed. While I can see potential savings from adapting a more elaborate memory management schema, it’s rare that I’m kicking something around, that really warrants the extra time for creating and debugging code for it, over just rolling with the local libc brew. Of course being the code monkey I am, I always keep an open mind for what the future may bring in the way of change.
Although I will use malloc() quite freely in coding, I also look at it like a reload in a CQB situation: if you’re reloading, you’re not able to engage more threats, and that (at least for me in SAS) is often the slowest element to an aggressive and dynamic advance. On the other hand though, I generally expect the operating system to provide a decent memory allocator for most tasks, rather then a brain damaged one o/. Ways to minimize the cost of allocating memory however, is something that I always consider a plus.
Hmmm 🙂

Redefining pot luck

Tonight Food Network displayed one cracker jack of a mission, in which Robert Irvine of Dinner: Impossible was sent off to the UNC. The objective? Turn whatever he could scavenge out of the dorm rooms into a quality meal for a ~hundred students, in less then six hours!

So here Irvine is with his sous-chef, and they’re trying to figure out what the hell can you do with a barrel of cheese balls, dozens of cans of different soups, a megaton of ramen noodles, and so many other odds and ends lined up on tables. Not to mention a deep fryer that went out so many times, he had to threaten the to throw the rent-a-fryer guy in it, lol. In the end they had to raid the sonority houses just to gather enough proteins to make a decent meal. Impressively they shipped about 19 dishes, and no one died of a heart attack in the process. Battle planning went out in like the first 15-min, and they had to result to an on the fly menu plan. It was shocking that they actually came up with something edible, let along that much food lol. In response to someone saying they would make his last minute concoction for the fair, billed as “Robert’s Corn Dogs”, he quibbled something about how he would never cook like that in a sane situation.  Despite what’s probably the most ludicrous episode I’ve ever seen, somehow they pulled it off with a hair trigger.

What makes Dinner: Impossible such an enjoyable show, is watching the host stew through it… and thanking GOD that you don’t have his job, hahaha. If Guy Fieri has the best job on Food Network, Robert Irvine has the most stressful. Me, I would just like to tag along on Triple-D, and gain back my lost 40 lbs in the process xD.

It’s just one of those nights….

… where I’m to restless about getting things done, yet to freaking tired to actually get anything of value done. I’ve already spent most of the day like a humming bird, even while on an RvS break; so it’s starting to get ridiculous lol.

For the past few days, I’ve been pondering ideas and looking at where I would like to be in the next ten years. Of course, getting through this year is a prerequisite 8=). I tend to analyze things systematically, so it’s a problem I engage no differently then any other, it is merely a bigger issue to study. At present Operation Redeemer is proceeding at a terribly slow pace, one that’s being forced upon me o/, and likewise data also suggests this will increase the odds of later being shafted before things conclude. Experience has shown me that families either represents the finest support system ever created, or the exact opposite: matter and anti-matter. Sadly with about the same impact on moving forward, only useful with a warp core and containment field. The principal agenda guiding my short term plans (Redeemer), is focused on brushing away the obstacles that make any larger aims, an utter impossibility. Ever being who I am inside, of course I’ve gotta lay foundation on later plans too. In the end though, only time can tell the future.

At the more immediate moment, I’m just whipped. There’s no shelter from exhaustion at this point, and probably never will be in my life: that’s one reason that I tend to take things one day at a time. I’m so fucking tired, yet hate to watch the hours go by without getting anything practical done. I also know, working on most of the stuff that needs doing, isn’t wise when I feel like passin’ out.

The crappy thing is, if I log off now, either I’ll be wide awake in a couple of hours (and back in the same boat), or by the time dawn rolls around, I’ll feel like slamming my sleep starved head into a wall, o/.

After getting my CP back in January, I’ve finally gotten to put it to good use: in our old churches back parking yard. My mother also has, for lack of being able to spell the Italian word coming to mind, I’ll just describe as having gained injured nerves >_>.

I’ve known the theorem and mechanics of driving since I was like eight or nine, so my focal point is on filling the experience gap. Ma has been driving the same ’93 F.O.R.D. for almost as many years as its been off the assembly line, and knows its handling inside and out; I don’t. Unlike my mother however, I can trivially calculate the distance between the car and what’s around it, stuff like that is a skill I’ve developed over the years, I can both feel it and fill the missing picture in, based on what my mind has already seen. Thus getting to close to the curbing means either I miscalculated the difference between the steering wheel, and the actual wheels current vectors, or it took to long for my foot to shift between pedals: not that I can’t see where I’m going 8=). Towards the beginning, I had to threaten my mother to shut up and stop grabbing at my arm, or I would retaliate either by (intentionally) taking the car over the curb, or make her stand outside and watch. I don’t give a fuck if there’s more racket going on then in a warzone, jabber all you like, but don’t interfere! Geeze I’m not an idiot, I know better to go over the curb; and that stopped as soon as she stopped jacking the wheel towards the curbing, whenever the car got too close. See, don’t bother me, and things get done properly -.-

My mother is insanely short, and to narrow minded to assume others have the same visual problems that induces. What can I say, when I first sat down in the drivers seat I nearly knocked my glasses off, and had my head angled funny, just to avoid cracking it on the ceiling… and I’m vertically challenged myself. Just getting the seat and steering wheel adjusted was a feat, involving suspending myself over the cleaning supplies in back, in order to clear to crap out of the way so the seat would have somewhere to slide back to, and then trying to extricate myself, without castration, broken legs, or a sliced open belly. It felt like hanging myself from the cars interior roof, and applying a spiders agility lol.

The area I had for practice, is just two sets of parking spaces several car lengths long, joined by very tight turns on either end. Small enough to require paying close attention, yet empty enough to only have to worry about one parked car, hehe. Did several dozen laps around the yard over an hours time, including a K-turn to go about the other way. Started out going at the engines idle speed, before studying how she handles under different patterns of acceleration and breaking; I doubt if a claustrophobic amount of practice space in is a good thing for a noob, but I never the less, take it scientifically. For me, it is very important to learn how the vehicle handles, because I’m not going to be responsible for taking it on the road, unless I know it well enough to keep the damn thing under control. I’m crazy, but I’m not suicidal :-P.

Three things that I noticed about the family Ford: the old accelerator has a hair thin trigger, it’s got a fat arse when it comes to rate of angle change in reverse, and exactly like in dreams that I’ve had about driving, the car will move forward even with foot off the accelerator. After 16-17 years of reading the dashboard sticker that says, “To shift from park, depress break pedal” in English and French, I of course remembered to do that without hesitation. I could probably understand the thing in spoken French by now o/.

Unlike my brother many moons ago, I opted to keep things under tight control while practising. Heh, I can still remember when Reese got his learners, and ended up zipping around a large Sports Authority parking lot like a bat out of hell. At least, I was seat belted into the rear drivers side seat, and spent most of his learning sessions being plastered against the rear passenger side window, lol.

Now the big question, is how many months will it take before I get more time to practice o/.

This weekends multi-part plan

  1. shave off the moustache and company; done
  2. get a hair cut; hopefully sorted before Monday
  3. a long shower; done as soon as the mops and laundry gtfomw
  4. finish pc-bsd v8 review
  5. report Stargellas sysio code to windows; stupid rsync screw overs…
With luck by Monday, I’ll both feel less like Chewbacca the Wookie and have a lot of work done, hehe.

Bug smashing on the stack, hehe

Ok, I’ve spent some time longer then expected working on my games net code, mostly because I both needed one nights sleep this week, and wanted proper IPv4/IPv6 support going on. Sunday I basically finished principal work on the net module, and completed a pair of test cases: a really simple client and server program. After that went smooth, I had planned to complete the finishing touches.

The problem: the server example segfaulted. Now those who know me, I consider it a plight upon my honour as a programmer, for any code that I’ve written to crash without due cause (i.e. not my fault). So I spent work on Monday taking a break: refining code quality and then porting it from unix to windows. During the nights final testing runs after that however, I had not solved the mysterious crash yet, and got the same results. I switched over to my laptop and recompiled with debugging symbols, only to find that my program worked as normal, only dying with a segmentation violation once main() had completed, and the programs shutdown now “Beyond” my control.

My first thought of course, was “Fuck, I’ve probably screwed my stack”[1], a quick Google suggested I was right. I also noted that turning on GCCs stack protection option prevented the crash, so did manually adding a pointer to about 5 bytes of extra character data to the stack. Everything to me, looked like the the return address from main was being clobbered, or imagine invoking a buggy function that tries to return to somewhere other then where you called it from. Before going to bed, I narrowed it down to the interface for accept(). Further testing showed that omitting the request for data and just claiming the new socket descriptor, caused the crash to end but still, some funky problems with an invalid socket. Inspection of the operation also showed that the changes were well within the buffers boundary, yet it as still causing the crash. So I finished the remaining stuff (i.e. free()ing memory) and went to bed.

Having failed to figure it out this afternoon, and starting to get quite drowsy, I played a trump card and installed Valgrind. It’s one of those uber sexy tools you dream of like driving a Ferrari, but don’t always find a way to get a hold of lol. For developers in general, I would say that Valgrind is the closet thing to a killer app for Linux developers, as you are ever going to get. In my problem case however, Valgrind wasn’t able to reveal the source of the problem, only that the problem was indeed, writing to memory it I shouldn’t be screwing with o/.

So putting down Valgrind and GDB, and turning to my favourite debugging tool: the human mind. It was like someone threw on the lights, once I saw the problem. Man, it’s wonderful what a good nights sleep can do!

Many data structures in Stargella are intentionally designed so that they can be allocated on the stack or heap as needed, in order to conserve on unnecessary dynamic memory allocation overhead, in so far as is possible. So the example server/client code, of course allocated its per socket data structures right inside main(). Because there is no real promise of source level compatibility between systems, the networking module is implemented as a header file, having function prototypes and a data structure representing a socket; which contains an opaque pointer to implementation specific details, itself defined in unix.c and windows.c, along with the actual implementations of the network functions. Because of that,the behaviour of accept() can’t be emulated. Net_Accept() takes two pointers as parameters, first to a socket that has been through Net_Listen(), and secondly to another socket that will be initialised with the new connection, and Net_Accept() then returns an appropriate boolean value.

All the stuff interesting to the operating systems sockets API, is accessed through that aforementioned  pointer, e.g s->sock->whatever. What was the big all flugging problem? The mock up of Net_Accept(), was originally written to just return the file descriptor from accept(), allowing me to make sure that Net_Listen() actually worked correctly. Then I adjusted it to handle setting up the data of the new socket, in order to test the IPv4/IPv6 indifference and rewrite the client/server examples using Net_Send() and Net_Recv(), and that’s when the crashes started.

I forgot to allocate memory for the sub structure before writing to the fields in it, resulting in some nasty results. When I say that I don’t mind manual memory management, I forget to mention, that programming while deprived of sleep, is never a good idea, with or without garbage collection ^_^.

Now that the net code is virtually complete, I can hook it into my Raven Shield server admin tool, which will make sure to iron out any missing kinks, before it gets committed to my game. Hehehe.