Sunday, February 08, 2009

Behavior Tree XML

Previously I was working on parsing XML for the game entities and thought I'd continue through to actually parsing the AI setup from that effort. So now after a few hours work (which included a lot of refactoring and there's a ton left to do of that) I can now actually specify an XML file as part of the AIComponent specification in the GameObject's XML.

Here's a typical GameObjects XML:


Arrgh, it wont display XML! :)


Hopefully you can see here that the game object has a number of components. In this case, the AI component (a gamecomponent of type "AI") has a tree specified as another XML file. When I parse the AIComponent spec, I'm basically passing that xml file spec to the AIComponent, which instantiates the AIActor class with the given XML file, which then loads the Behavior Tree of the actor with it. Long winded, but certainly much more flexible than before.

Now I've got to refactor some of the blackboard code to do the same thing I think. Although I need to do more work there to allow arbitrary values to be added, queried and removed. CRUD as I believe the acronym goes.

So now I can play with different priority values easier. But its still not as flexible as runtime tweaking. I guess the next big step is to add Lua or some other scripting engine into the codebase. Can't say I'm a massive fan of Lua's syntax though, might try GameMonkeyScript or AngelScript.

The other option, is to make myself a network proxy interface and allow this kind of tweaking to work via the network. Essentially this means that I need an object attribute system (I already do) which then works transparently over a network, which is pretty simple. Then I just code a nice C# app that does remote inspection of the various objects+attributes and bobs your uncle. Or auntie if you have a weird family :)

Right, onwards..

.Z.

Thursday, February 05, 2009

Snow day fun!

Hmm, seems like a semi-productive day. Snowing outside anyway so I wasn't going to go out

I got an XML parser sorted out for the game objects in my engine. Basically all game objects are component based (i.e they use aggregation rather than inheritance).

So now I have a bit more flexibility as I can save my test worlds in an xml file and have the world loader class simply load the world.xml file (or whatever) that defines all of the agents and other objects in the game.

Next up is to do the same for the behavior tree itself. I've already done an editor of sorts that I can knock into better shape for the XML creation of a tree, so its just a matter of using the excellent XMLReader library to parse in the BT itself. (Incidentally, if anyone is looking for an XML class that does the business, I am preferring this one to TinyXML, which I've also used in the project).

Fun thing is that I got libCurl setup yesterday to pull a spreadsheet from google docs as XML, I can then feed this into the world loader class and theoretically I can actually distribute my game "levels" via google!

I also wasted an hour or two looking at the various video capture software to try and record a video of the app (its not really a game yet). Tried wegame, guncam, fastcampro but of course fraps is the only really useful solution outside dumping raw frames and using something like premiere to turn that into a video. Fraps did a bloody good job of recording 720p video from the game, but unfortunately windows movie maker bites at encoding. But it was good fun splicing a few shots together and titling it all. Although I think the footage looks bad enough that I'll keep it to myself for posterity.

I also packaged up a .zip file of the game today to see how trim I can get it. A quick purge of some of the nvidia texture library from my media folder and I'm down to an 8meg zip file. If I were a bit more aggressive about pruning I think about 5-6meg is probably achievable. Not the ideal download, but then most of it is Ogre libraries, which now I think about it, I can mostly do without.

Anyway, a productive fun day doing some general AI coding and engine schlok and having fun making dumb movies to amuse myself. Life is good when it snows!!!