Wednesday, April 30, 2014

kAI - a component based AI Tool

kAI - a component based AI tool
For my third year project for my degree, I developed kAI - a component based AI tools. kAI is a library and visual tool for developing AI’s specifically for games.

The way it works is coders produces code behaviours which designers can then import in to the tool. kAI behaviours are then a collection of these code behaviours and other kAI behaviours arranged into a network. 

The tool is similar to Kismet/Blueprint - the visual programming tool found in Unreal. The key difference is that is specialised towards AI. As a result, you can't use programming primitives like for loops (hence no programming style bugs and hangs). Instead, all behaviours can be either active or inactive and are updated accordingly. 

The update system (detailed in 3.2.2.1 in the report) means that what frame any behaviours become active is deterministic, despite the non-determinism of the order in which the nodes are updated. 

kAI also supports real time debugging using the editor. In this, you can see what the behaviours are doing in real time. The editor will show what nodes are active and what current values data ports have

An example behaviour from the editor
The project can be downloaded from GitHub (including pre-compiled executables) and it includes 2 example projects. The source can be found at https://github.com/thk123/kAI and the executables at: https://github.com/thk123/kAI/releases/tag/v1.0

The report is a lengthy document (~90 pages) that explains a lot about the project. Chapter 4 is a user guide and is probably the most useful part of the document. It contains detailed walk thoroughs of most of the features of kAI. The report is called ProjectReport.pdf and is at the root of the repository.

My final report
It was a lot of fun to develop and I developed some pretty neat code including operator constraints for generic functions that I'll tidy that up in to a standalone library at some point, and converting functions into nodes with ports. 

In-spite of the limited development time (which can be seen in the "functional" interface that the editor has), the tool proved surprisingly useful when creating AIs and the debugger is very powerful for this kind of thing. I believe kAI to be flexible enough that you could make just about any AI in it and still get some benefit (even if you just used kAI as a general purpose visual debugging tool).