View Full Version : Some sorta AI experiment

Robert Kosek
23-05-2006, 07:44 PM
As I said to WILL, I might post it later... well, I've done so.

I don't know what to call the thing. It's a bizzare mix of randomness and some neural network similarities. It's just best if you read the code. :roll: It was a total shot in the dark for me and was intended to be an experiment with Neural Networks. Whatever it can be classified as now, it works.

http://img326.imageshack.us/img326/456/screenshot7dm.th.jpg (http://img326.imageshack.us/my.php?image=screenshot7dm.jpg)

The average processing time for 1 "nextturn" calculation takes a mere 2 billionths of a second. I've done my best to comment this beast, so it's hard for me to describe it outside the unit, since I've said it already within the context of the unit.

Anyhow, I'm curious to your thoughts on it.

23-05-2006, 08:05 PM
This looks interesting, I've been looking for a nice AI system for Alert Fighter, but I hit a bit of a mental block when coding my own.

Are you going to release the code? The screen shot lools great :D

Robert Kosek
23-05-2006, 08:15 PM
Oops! Forgot to link to the code!! ROFLMAO! :lol:


MPL Licensed, full source.

23-05-2006, 08:39 PM
I have never done much at all with AI except specifc to single games.

Can you post an explanation of what your program does and why it is useful.

I looked at the picture and I would surmise that:

The programmer can add behaviour that characters in the game an do and place weights on choosing this behaviour given a set of circumstances.

Is that about the skinny of it?

In which case that sounds rather excellent.

I think I will download your code now...

Robert Kosek
23-05-2006, 08:51 PM
Basically what the AI does is "crawl" along a basic ruleset given by the programmer. I add things such as misfourtunes and calamaties and the AI randomly tries things to escape the bad states. It keeps a count of failures and successes, and then rules out the things that fail and weight the rest as being good or not. The skinny is that it learns what not to do and what to do for a given state.

The -1's you see are "disabled" nodes, they never fire. It takes 5 failures for a node to be deactivated.

The others are the weights, which is 1/3rd the actual success rate of that node for leaving the state. When picking between successful actions the bot makes a random number that is the sum of all the weights + 1 each weight. The bot then uses that random number as a "slider", so to speak, to choose the right action. For example(refer to the screenshot):
The sum of "Normal" actions + 1x4 is 22 (-1's aren't factored).
Let's say the random number is 8.

The action is Normal_Jump. Here's why.

The range for Normal_Move is 1..3 (weight + 1), the range for Normal_Jump is 4..12 and so on. So ranked by fitness the bigger the weight, the bigger the chance of the node being picked.

So if you were to add a state, you'd (with this code specifically) name it and specify the actions that make it possible to escape that state. As I said it was a blind shot for me and I cut many corners, so it's 90% hardcoded in the definitions.

QUICK FYI: The Bot State shows the current state, not the one that the action was previously based on. So if it says "Hurt" yet it successfully did nothing (weighted -1) then you know that it was in either Normal/Moving, not actually hurt the previous state.

Robert Kosek
23-05-2006, 08:55 PM
Just thought of this, but perhaps it's a Variegated Finite State Learning Machine? :lol: Ain't that a mouthful!?

23-05-2006, 09:21 PM
lookin good

What about multiple input states?
your bot could be "moving" and "hurt" at the same time.

Robert Kosek
23-05-2006, 09:23 PM
Currently unfactored. However to fix that I would just rank the states importance, with wounded being more important and so the bot would recharge first.

24-05-2006, 12:21 AM
Very cool. I'm gonna have to browse your code sometime to see how you impliment your NNs. Is it a Feedforward network you are using? Those seem to be most common.

BTW if anyone is interested in checking out my own AI Unit I made some few years ago, AI Workshop (http://aiworkshop.tripod.com/).

I created it while trying to come up with my own solution to the 'minesweeper' (or ant eating food) problem at AI Junkie (http://www.ai-junkie.com) in Fupster's Neural Networks tutorial. Another look at Neural Networks, but using Genetic Algorithms.

Robert Kosek
24-05-2006, 12:23 AM
Not sure if it even qualifies for a NN right now. ::) I had tried to design one without quite knowing what I was doing. Hard to say exactly what it is, but the closest I've to to an accurate name is a "Variegated Finite State Learning Machine"...?