Toribash
Original Post
[WIP] Perceptron
I'm currently educating myself in Lua with a specific focus on the Toribash API, for what I consider fairly obvious reasons. As a first project, I thought I'd do something interesting in concept and not very hard to implement; use of a perceptron to generate a "move" which meets certain requirements.
If you're not familiar with what a perceptron is, it's quite basically a simple model of a neuron, and I'll outline one below. By using a single one of these, I have so far successfully implemented a "move generator" which will eventually meet a specific set of requirements. At the moment it isn't very intelligent at all, which is why I am not posting the source yet. It brute-forces moves with repetition (*gasp*, that's horrible!), so I'll spend the next few hours working on a more intelligent system that won't be too memory intensive.

A perceptron takes two or more "inputs" and produces an output. One input is internal - a natural bias. Inputs are multiplied by a "weighting" factor and then the perceptron's internal processing determines the output (always a boolean value).

Any comments or suggestions would be appreciated!

Release Notes
v1:
  • Implemented a basic genetic algorithm. By default, 100 damage points = 1 fitness point and 1 body part detachment = 50 fitness points; this is fully customisable depending on how much you like detachments.
  • Not making full use of the perceptron structure yet. At the moment, it generates moves endlessly rather than stopping when it meets a set requirement.
  • You may want to set turnframes to 50 so that you actually have a chance to hit the opponent.

Planned Features
  • Saving of the top n movesets and their fitnesses (in order of fitness).
  • Stopping after meeting the target requirement.
  • Some adjustments to the algorithm; it's not as good as it perhaps could be.
  • Multi-turn moves! One turn really isn't enough for a great move, but for now just an opening move will do.
Attached Files
percy.lua (2.9 KB, 44 views)
Last edited by ZaggZigg; Aug 4, 2011 at 12:12 PM.
Good luck. I thought about something like that, too but I'm not into AI so it didn't really work.
I'm really looking forward to see results.
Signature temporarily out of order.
Originally Posted by psycore View Post
Good luck. I thought about something like that, too but I'm not into AI so it didn't really work.
I'm really looking forward to see results.

Thanks! I'm not really much of an AI person myself, but this was an opportunity for expansion of my knowledge. I'm always up for that.

Originally Posted by Melmoth View Post
You should take a look at squeakus' scripts.

Thanks to you, too. Looking over those made me realise that I had a design error in my algorithm (not a major one, but it would have made things a whole lot slower).

First version is in the OP. It's not very special - just keeps generating moves for you and gradually gets better (if you set the turnframes high enough to actually hit the opponent!).
Hey i have a question: can you have a premade opener, and make the script to start at a frame set by user?
Also good luck with your script, it's awesome so far.
and hey. the numbers appears only for 1 to 2 digits only. the the whole score.
~knight zero~
-- Why doesn't Lua have i++ or even i += 1? :[

haha. I feel with you.

It runs a lot faster if you turn fixedframerate off, turn shaders off, disable blood, bloodstains, tori, uke and hud. Although it's funny watch him fighting.

nice script. btw, why is it called percy? perceptron - percy. I guess that's why
Last edited by psycore; Aug 4, 2011 at 06:00 PM.
Signature temporarily out of order.
Originally Posted by KZero07 View Post
Can you modify it so he wont do the same moves?

How do you mean?
I'm guessing that you're talking about the occasional (sometimes not so occasional) move repetition; that's bound to happen as I'm taking only from the top 5 (by default) fitnesses and just switching blocks of 10 joint states between pairs. The next release will attempt to do it better and hopefully there will be less repetition and more advancement.

Originally Posted by dista View Post
Hey i have a question: can you have a premade opener, and make the script to start at a frame set by user?
Also good luck with your script, it's awesome so far.

Hopefully, that will eventually be possible. It is technically possible at the moment, just not in my script. And thanks.

Originally Posted by KZero07 View Post
and hey. the numbers appears only for 1 to 2 digits only. the the whole score.

Not sure what you mean here. Do you mean that the fitnesses don't just reflect the score? They aren't supposed to.

Originally Posted by psycore View Post
haha. I feel with you.

It runs a lot faster if you turn fixedframerate off, turn shaders off, disable blood, bloodstains, tori, uke and hud. Although it's funny watch him fighting.

nice script. btw, why is it called percy? perceptron - percy. I guess that's why

Thanks for the tips.
Yes, that's why. I felt like giving it a name, since it's supposed to behave like a semi-intelligent organism.

I'll get to work on some improvements now.