Scripted AI?

Miscellaneous Forums/General Discussion/Scripted AI?

Yeah, it's me again, banging on about scripting again. I've got scripting implemented for GUI, game entities and now cutscenes, but I'm not yet sure how to implement scripting for AI.

I'm obviously going to need to bind some functions for the scripts to work with. I have no problem with that. What I'm not sure about is how to structure it. The most basic way would be to have one script per agent, this script is just called every update, it runs through, does whatever the script tells it and that's that.

Maybe that's all I need, but I'd like to hear about alternative methods, if there are any. Perhaps I should assume that the AI uses some kind of state machine and have one script for each state? Maybe I should script triggers and states separately? I don't know. I'm just musing.

Although there's plenty of information around on AI and scripting, I can't find anything at all about the architecture of a scripted AI system. It's almost as though it's just assumed there's only one way to do it. Unless the one way is what I suggested above - a script you call every frame ( or less often if the agent is further away from the action, I guess ) - I don't even know what that one way is. Even so, that doesn't mean that there couldn't or shouldn't be other ways.

Any thoughts, ideas or experiences on this?

I would instead have one script, but multiple state machine registers per AI Agent, there is no use in duplicating a script, just duplicate the 'virtual machine' registers itself, like an operating system also does. (Context switching and Register windowing comes to mind)

By that I mean, one script will run concurrently between multiple agents using their own program counter and register values. Also, if you want different scripts running, then yeah -- of course you would have them loaded separately, but there's no point in duplicating the same script for multiple agents. That's how I do it anyway :)

If you've got the time have a look at TORCS - The Open Racing Car Simulator. It should give you plenty of ideas about how to go about doing just this, and is open source.

Zenith: Good point, thanks!

FlameDuck: Indeed I do have time, and it's an interesting subject to me. TORCS looks like a very good place to start reading. Thanks!