people playing: 75, servers online: 24, games played: 135,890,969 Top Player: Shmevin

  Toribash Community » Toribash » Mods » Lua scripts
Register FAQ General Rules Community
Reply
 
Thread Tools Display Modes
Old Mar 16, 2010   #1
squeakus
Junior Member
 
Join Date: Feb 2010



violence evolved version 2: Now with working genetic algorithm and combo maker
hokay! I finally have a version of my GA that i'm proud to put my name to! The last one had several bugs and only kept track of the best move, this one actually works and has loads of cool thing for viewing your best moves. To run it just copy the files to Cgames\toribash\data\scripts and you can start it from the setup -> scripts menu. it will then go about evolving a good move.

I made this script so that you could have an AI opponent for any toribash mod out there. It doesn't matter about the rules different, it should learn them given enough time.

here is how it works:
(0) It starts by generating 10 random moves (aka individuals)
(1) it checks how good each move is (aka fitness value) by executing it
(2) The fitness value is: toribot_score - ukebot_score
(3) once all 10 individuals have had a turn it then takes the top 30% of the population
(4) These are then recombined using crossover(cutting in half, sticking back together) to make the next 10 individuals for the next round
(5) Some of the individuals are mutated just to keep things interesting
(6) goto (1)

Remember a genetic algorithm is probabalistic, meaning it will create a lot of terrible moves before it starts getting good ones (hence the random flailing), it also means that you'll probably get a different solution every time you run the algorithm. I generally left it running overnight to get a decent solution. The population size is set to 10 because I was debugging it, i'd recommend increasing it to 50 if you want to keep things diverse.

If you don't want to start from scratch every time you restart the algorithm there is a flag at the very top of the file called loadPrev, set it to true and it will read from the population file. A word of warning though! first you have to run the algorithm once with loadPrev set to false to create the best and population files (i'm sorry i had to do it this ugly way but the file IO for mods is awful)

I moved the get_fitness function to the top of the file, The fitness function is what drives the algorithm, i have added a very basic one that just tries to maximise the score. you can add what ever you want in there, distance moved, decapitations, disqualifications, dismemberment, etc but remember that if you just check for limbs removed then thats all the algorithm will care about. Even if it scores terribly and chops off all it own limbs in the process its still going to think it did great and get to have lots of kids in the next generation, so be careful what you ask it to do! Also if you do come up with a good fitness function please post it on the forum, I don't actually play the game much and you probably know a lot more about what it should be doing.

There is also a new loadBest application. This will read in all the best moves that you created during your run and replay them for you. You can move between them by pressing n for next and p for previous. As the best file appends new best moves you can actually see how your move evolved over time. Another word of warning! if you have been running the GA mod previously it is best to close toribash and reopen it before running the loadBest mod (again the damn IO is on the blink)

I've also included two other scripts, comboGA and loadBestCombo. They are very similar to openerGA except that you can set the number of moves you want him to make at the top of the file. Its still hard-coded though so he will make an initial move and then the next after (totalMatchFrames/moves) frames. Remember to have the same number of moves in the top of comboGA and loadBestComboGA otherwise it will not show the moves.

I think this is about as far as I can push this as a mod, the file is becoming a bit unweildy and the lack of file IO for mods is a real pain. After this I might re-introduce uke to evolve against but the speed is the primary concern. If I want to evolve REAL AI capable of dealing with counters and chaining combos (and eventually beating humans,mwahahahaha!) then I need to speed it up dramatically. Is there any way of disabling the graphics or running other programs from the mods that anyone knows of

Anyways I hope you enjoy it!

tips for speeding it up:
in the game type "/opt fixedframerate 0" <-this will mean it runs as fast as it can (thanks again deejay!)
in the game settings change the match frames to 250
turn on disqualification
remember the more rounds the better the move!
Attached Files
File Type: lua openerGA.lua (8.4 KB, 612 views)
File Type: lua loadBest.lua (3.3 KB, 410 views)
File Type: lua comboGA.lua (9.1 KB, 523 views)
File Type: lua loadBestCombo.lua (3.8 KB, 449 views)
squeakus is offline   Reply With Quote
Old Mar 16, 2010   #2
pigking45
Forumite
 
7th Dan Black Belt
Join Date: Dec 2009
Posts: 1,577



can you make one for wushu or
[Pigs]|TA|AM|
pigking45 is offline   Reply With Quote
Old Mar 16, 2010   #3
VIDEOGAMES
BODYBODYBODYBODYBODYBO9DYBODYD0ODEYHIRFOIW
 
6th Dan Black Belt
Join Date: Mar 2009
Posts: 3,875
Clan: [T]



I just wanted to say this mod is a fantastic bit of coding genius.

A little hint if you want to cause the game to run faster, its possible to use /opt blood, trails, uke, tori, hud, and a variety of other parameters in order to remove them from sight and in most cases, increase the framerate.

All though I do not know all of the parameters, you can gain a huge framerate boost if you /opt uke 0 and /opt tori 0, although you will not be able to watch the progress of the fight.

Obviously you will also want to turn off shaders and anti aliasing (I believe they can both be turned off under options) , if you are using them, as they contribute very much to the framerate.

Sorry I could not be more helpful as to all of the /opt parameters, but I hope I at least gave you a few ideas as to increasing game performance, considering I would love to watch this mod develop.
oh yeah
VIDEOGAMES is offline   Reply With Quote
Old Mar 17, 2010   #4
darkdoom1
Member
 
Black Belt
Join Date: May 2009
Posts: 279



simply amazing! its funny to set it to 100 moves and 100 moveframes... he spazzes out! Its like he is having a seizure! check out the replay! He also tends to rip off both of his own hands... o well. time to set it back to like 10 moves! lol
Attached Files
File Type: rpl comboGA spasms.rpl (138.4 KB, 163 views)
[SIGPIC][/SIGPIC]
Mammary Gland Holders of the Humanoid Lifeforms Commonly Known As, Homo Sapiens.
darkdoom1 is offline   Reply With Quote
Old Mar 17, 2010   #5
Mesch
Member
 
3rd Dan Black Belt
Join Date: Aug 2007
Posts: 160



Very cool keep up the work!
You Better Get My Damn Ravioli!!! I'm Gonna Unleash the Beast up in this B***H!
Mesch is offline   Reply With Quote
Old Mar 18, 2010   #6
TheJFX
Senior Member
 
3rd Dan Black Belt
Join Date: Feb 2010
Posts: 559



Well
The script works great, but it seems to have problems starting off if the original starting points of uke and your tori are too far apart (instagibfeet)
Is there any way to insert a starter move for the tori to learn off of?
TheJFX is offline   Reply With Quote
Old Mar 18, 2010   #7
pigking45
Forumite
 
7th Dan Black Belt
Join Date: Dec 2009
Posts: 1,577



when i run it it always manages to wack off my own head
[Pigs]|TA|AM|
pigking45 is offline   Reply With Quote
Old Mar 18, 2010   #8
SC501
Senior Member
 
Brown Belt
Join Date: Nov 2008
Posts: 879



wow, nice script. mine is evolving an arm break now
*edit*
or maybe a suicide
[ESSENCE]

Last edited by SC501; Mar 18, 2010 at 04:54 PM..
SC501 is offline   Reply With Quote
Old Mar 18, 2010   #9
Zas
Forumite
 
10th Dan Black Belt
Join Date: Mar 2008
Posts: 1,925




Have to admit it keeps getting better. I'll see how it does after a few more hours.
Zas is offline   Reply With Quote
Old Mar 18, 2010   #10
lilezek
Junior Member
 
Blue Belt
Join Date: Mar 2010



What about fitness:
Code:
(toribot_score + ukebot_fractures + ukebot_dismembered) - (ukebot_score + toribot_fractures + toribot_dismembered)
I think it would get better in less time. You can do a super score combo, but a combo where you break oponent's members I think is better.
lilezek is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:54 AM.




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
ragdoll fighting game physics fighting game ragdoll fighting physics funmotion joints martial arts karate pc mac free game turn based game