BonSAI
BonSAI is the extensible AI system used in Mike Kreuzer games. An extensible AI is an artificial intelligence that a gamer can modify.
The name BonSAI comes from good (Bon), Scripted AI (SAI). It shares smallness with the method of cultivating artificially small potted plants, and over time will get even better.
Using BonSAI
As a gamer you don't have to play with the internals of BonSAI if you don't want to. But you can.
As a game developer, all you need to do to use BonSAI in your own game is to give me the appropriate credit. BonSAI is issued under the MIT/Expat license, full details are available here. The C# interpreter has a slightly different license, but the effect is the same. Full deatils are available on the C# Script site. These licenses applies to BonSAI, not to your (or my) games.
Under the hood
Simply put, a game calls the .NET framework to interpret C# scripts that tell your computer opponent what to do. In reality BonSAI consists of a number of layers, described below. In the following diagram, items in green are binary files, items in brown are text. The source code for the binaries is of course avalailable.
| A C# interpreter that uses .NET to read ... |
| C# scripts, that call ... |
| A CLIPS expert system that uses .NET to read ... |
| Rules about what to do. |
The C# scripts hand over to the rules read by CLIPS, to decide how to react. A game could just call CLIPS, but then that's all it could do. As it is, C# scripts can be used to do whatever you want. The whole AI could be written in C#, though BonSAI is a hybrid system to avoid re-inventing too many wheels.
.NET
BonSAI uses the .NET framework, you can download the latest version from MS.
Wet Paint!
Testing and development of BonSAI continues in preparation for the release of AFRIKA. Until then this page will act as a repository of test files & explanations.
BonSAI will remain very much a work in progress even after it's released, and because it's open source you'll be able to help.
Scripts & source code
When it's finished, a single BonSAI.zip file will be available. For the moment, the components highlighted in green are complete.
| Component. | File name(s). | Download. | Version. | Source code. |
| Embedded in the game | Example code soon. | |||
| C# interpreter | CSScriptLibrary.dll | Download (26k zipped) | 1.7 | The C# Script site has the source code. |
| C# scripts | *.cs | Soon | Soon | |
| Expert system routines | CLIPS.dll IClips.dll ProAi.Clips.dll |
The ProAI CLIPS .NET Lib site has this download. | CLIPS 6.24 | The ProAI CLIPS .NET Lib site has the source code. |
| CLIPS rules | *.cli | Soon | Soon |
| Editing. |
| If you're interested in changing the behavior of the
AI, the CLIPS rules are the place to start. The rest of the framework
is just a ... framework. To edit the rules I recommend the Protégé ontology editor. Be sure to read about the compatibility issues before you start. (Basically you'll only be using a subset of what the program offers). Any text editor will also work. If you want to edit the C# files I recommend MS Visual Studio; the Express Edition is free. Or again, use the text editor of your choice. |
C# & CLIPS
C# was chosen as the scripting language because of its enormous existing code and user bases, the maturity of the language, and the access that it provides to the .NET framework. C# scripting is made possible by the hard work of Oleg Shilo. His original C# Script Code Project page is here, and his C# Script page is here.
Early versions of BonSAI used the scripting language Lua, which was originally chosen because of its small and relatively easy to embed interpreter. Lua and the Lua interperter's API are changed with depressing frequency though, and while it has its good points, in the end C# was simply better at those things too.
CLIPS was chosen because while incompatible languages and standards have proliferated in the field of expert systems, CLIPS is in the public domain, and remains a great base on which to build.
Security
Sadly, I need to state the obvious. Any scripting engine will make it possible to write and circulate malicious scripts. The DLLs distributed here have not been modified ("sandbagged") to restrict any of their operations, so they will do exactly what a script tells them to do. I have written crippled versions, but always quickly came up against legitimate cases where they were too restrictive. This is a powerful tool. Use your common sense, DO NOT load and runs scripts with unknown provenance.




