Monday 19 August 2013

Kohonen SOM AI monsters

I put a forum post in the development section on Temple Of The Roguelike about this, which got a few replies. After which I decided to just take the plunge and add it in.

Kohonens Self Organising Map

Basically, it's a 2D array of anything which has been created and tweaked from an n-dimensional input source. Whatever that input is, or where it came from is irrelevant to the 2D array. What this does really, is just to organise the 2D array based on the relationships the inputs have to one another.

What makes it interesting, is that it does this fine tuning unsupervised. 

What I did so far

It's a neural network. So, I made a 2D array of 1000 x 1000 "neurons", which gives me about 100,000. That's about the same amount as all the neurons in a tiny ant. But, how those neurons in an ant are interconnected, I dont know. In my network, adjacent neurons are connected only.

I then gave this network a long list of 3D data to "investigate", or train. It took a while. But the relationships were always the same when finished. Sometimes, the start points might be different (the network doesnt know which is the start really).

So, once I could see the neural network code was working fine, I plugged it into my monster code.

What Next

I now have hundreds of monsters in the game wandering around with brains that can learn stuff. The monsters for now use A* pathfinding to chase the player, but once I switch on the neural network code and start using it, well, they will be smarter, and very difficult to kill.

Cloud Based

I use MEF (http://msdn.microsoft.com/en-us/library/dd460648.aspx) for plugins in the game. This AI stuff i'm doing will be moved over to separate plugins in a few weeks. After that, I will place it on some type of cloud service. I'll then link the training process of the AI from the game, back to the cloud.

As more and more people play the game, the cloud AI will learn. Players will be able to switch out the AI plugin anyway, so if it gets too hard to play, they can just activate a local AI plugin and ignore the cloud AI.

Finally, I will have a game that has an unsupervised cloud AI, where the monsters adapt and get better, as players get better. Who will win? I don't know really :)

One Last Thing...

There are hundreds of RLs out there, with all the wonderful things a RL is. Sure, I could spend 7 days to just whack in all that stuff too and make SurviveRL another one on the list. I don't see the point though. We can all keep playing those RLs for now, and keep monitoring SurviveRL as it develops into something of a hybrid RL. So, if enough people ever ask, I'll take 7 days and just hack in RL stuff. For now though, i'll keep on developing on a tangent.

No comments:

Post a Comment