3D Game AI in WebGL and Javascript

Programming artificial intelligence for games, aka Game AI usually is a challenge. And if you are limited by CPU, lines of code, memory and even the programming language itself, it quickly isn't that fun anymore. I just released a free update of CopperCube, version 4.0.3, which includes an update to the included Game AI behavior. If you ever used it, you know that it is very basic, but with this new update, I made it a bit smarter and a bit more tweak-able. But see for yourself, in this WebGL demo:
Both game AIs in this demo only use 20 KB of JavaScript code to do what they do: One AI is instructed to try to go along a path forming a circle around the room, while the other one is set to 'randomly patrol'. Both are set to hate each other, so attack each other. I've not given them any weapons, but they don't know this: They still will try to fire at each other. What this demo tries to show is that the AI doesn't know anything about the obstacles in the room, so they blindly stumble around in the area, but try to keep at least their countenance up a bit. If you would have tried this with the previous version of the AI in CopperCube, this would have looked pretty ridiculous.

The same AI behavior is of course also available if your publish your app as Android app, Windows .exe or Flash .swf file: It uses the same minimal amount of code on all platforms, so it runs very quickly everywhere. As most game "AI"s, there is a simple state machine behind it. Thus calling it "AI" is a bit exaggerated. In this case, the AI has just 4 high level states ("do nothing", "reach position", "attack item" and "die and stop"), and based on the situation, it will switch between the states.
In this CopperCube update, the AI has been tweaked so that it can handle obstacles better, and the user now is also able to set waypoints where the AI is supposed to go. Also, specify how long the AI should wait once it reached its target position is possible now. With this, it should be easier to create nicer games, I hope. But of course: The AI still can be improved a lot. And it is no comparison to the AI in modern games. But it is a start. :)

two comments, already:

I don’t know why, but it somehow made me think of boids
xaos - 14 03 13 - 11:09

Yes, me too :)
niko - 14 03 13 - 11:52


Name:  
Remember personal info?
yes
no
Email (optional):
URL (optional):
Enter "layered" (antispam):
Comment:Emoticons / Textile

  ( Register your username / Log in )

Notify: Yes, send me email when someone replies.  

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.
Note: If you type in your email adress above, it will be visible to other visitors, although it will be hidden for bots using javaScript.