Quake AI diagrams

Discuss Artificial Intelligence and Bot programming.
Post Reply
daemonicky
Posts: 185
Joined: Wed Apr 13, 2011 1:34 pm

Quake AI diagrams

Post by daemonicky »

Oh page, where were you when I was browsing Quake C :) http://ai-depot.com/FiniteStateMachines ... tical.html

Does anyone have experience with making such nice diagrams out of some code? I think taht it would be cool to do it for arbitrary QuakeC, it can make it easier to orient in your code and easier for others to dive into it.
:)
Sajt
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Post by Sajt »

Those sort of diagrams are confusing :( The code is much easier to understand for me...
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
daemonicky
Posts: 185
Joined: Wed Apr 13, 2011 1:34 pm

Post by daemonicky »

Sajt wrote:Those sort of diagrams are confusing :( The code is much easier to understand for me...
I believe each person has its own way of understanding. BUt, I would really like to recommend you just getting to know some UML, I found some of them usable. They are quite obvious and they are standard.


I am a visual guy, so I like Venn diagrams, ERD ... I have done little coding in visual languages, but they appeal asi nice to me :
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

A state diagram would be cool to describe Quake's AI. But in a nutshell this is the monster "brain":

Code: Select all

1) do I have a movetarget ? If so, then I'll run self.th_walk towards it;
2) if not, I'll just hang on here running my self.th_stand function every 0.1 seconds(*), hopeffuly awaiting some player find me;
3) if I see a client, I'll set my .enemy field to point him, play my sight sound to show how pissed off I am, turn to him calling ai_face() and exec my self.th_run function;
4) if my self.th_missile is set and I have a clear path, I'll call it randomly;
5) if I am close enough and I have self.th_melee set, I'll exec it;
6) at any time, if somebody hurts me I may (or may not) play my pain animation and, if it has a different classname(**), I'll save my current value for self.enemy in self.oldenemy, set self.enemy with my agressor entity and go on;
7) if my health is below zero, I'm done. I play one of my cool death animations, turn non-solid(***) and eventually I'll drop a backpack with some goodies. If my health is too low, I'll just turn a rain of rotten meat giblets;
8) I am very stupid to deal with obstacles, specially long walls,  and human clients abuse this limitation in several ways. Also, I have no understanding of the world where I roam aimlessly: I use to avoid water, even small puddles that would be otherwise safe to cross on foot. I don't distinguish water from lava or slime, and gaps deeper than 32 Quake units are virtually show stoppers to me.
(*) some QuakeC coders (read: me mostly) may set higher frequencies to the standing AI. This requires handling animation in a independent timing;
(**) monster_army (and monster_enforcer IIRC) are the exceptions, they'll try to kill another of their kind;
(***) except of course if you're running some gibbable corpse mod :)
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Lardarse
Posts: 266
Joined: Sat Nov 05, 2005 1:58 pm
Location: Bristol, UK

Post by Lardarse »

frag.machine wrote:monster_army (and monster_enforcer IIRC) are the exceptions, they'll try to kill another of their kind
Nope. Enforcers are "smart" enough not to.
Roaming status: Testing and documentation
Post Reply