Hey everyone, I recently put up an arcade map that uses an evolutionary algorithm (or genetic algorithm) to evolve the best combination of units to use against any army you specify. Basically, you create an army and it will find the best army to use against it, that does the most damage while losing as few units as possible.
It works by creating some random armies to fight in the first generation of battles. They get assigned a score and the highest scoring armies go on to fight in the next generation, along with some mutated versions with slightly different units. After a few generations of this, it evolves armies with the highest possible score. The results are displayed on a bar graph so you can see the improvement over time.
It's not so much of a playable game, because you can't control any of the units. It's more of a demonstration of a simple genetic algorithm.
Would be cool to have server side banks per map to store genetic info of some kind of evolving AI, so it would be stupid after map upload, but the more ppl play it, the smarter AI becomes.
@Zolden: Go I'd also like to see if its possible to make it decide strategies, not only unit compositions.
@Olsenn: Go you should find someone willing to give it good use. Like Zolden said a type of map where the AI improves the more you play it. Even if it has to use client-side bank files.
I've done a lot of thinking about an AI that learns the more that people play against it. Server side banks would definitely be nice, but if that never gets implemented it could also be accomplished by having people upload their bank files to a website and releasing a smarter version every so often. A fully fledged AI that learns as it fights against people would be very cool. For now this is just a basic proof of concept and a demo of a genetic algorithm.
My map does have the option to output detailed results to a bank file, but it's output only. I might make a windows app to view them in a friendly way.
I do want to add attack behavior to it (attack priorities, focus fire, etc...) and evolve that along with the unit selection, instead of leaving it to the default unit AI.
If you intend on making an AI this advanced, honestly, why not make it in something other than SC2? Coming from someone who specializes in AI, I can tell you that making a true learning AI takes a very long time, and a very powerful server. Much longer than I would consider worth putting into an SC2 map.
Sure, saving the best results against a certain army composition, and then recording data works fine. But there is A LOT more to it. Luckily SC2 doesn't deal with hit detection, which makes things a lot easier. But normally you have to go through things like predicting the units movement by running A* algorithms on every unit, predicting the most probable movement patterns based on previous actions executed by a particular unit. If advanced priorities are created, it only becomes more complicated. Something as simple as the unit's range is a huge factor in calculating the estimated movement of a single unit. Once the base is figured, it has to iterate through a bunch of different scenarios, finding the most probable for success. It then creates the army, tests it, and then runs the process again.
AI is not just recording data, it is manipulating it and running simulations. But yeah... SC2 isn't nearly powerful enough for that. So this is just about as close as you can get to a learning AI, I suppose.
But that being said, excellent work. I am amazed at how well it worked out. Could be very useful in a lot of scenarios, and is quite frankly just fun to watch haha.
@TacoManStan: Go
Alternatively he could make a way more simple game, than SC2 melee in the editor and have learning ai with that game (something I thought for many of my games). The problem is there is no server side saving...
SC2 isn't nearly powerful enough for that. So this is just about as close as you can get to a learning AI, I suppose.
We can't say that sc2 isn't powerful for AI learning. AI learning includes alot of methods. Some of them need more calculation power than sc2 may provide, some are ok about what we have.
We just got spoilt by using unbelieavably powerful machines these days. While 30 years ago ppl had been doing amazing things on machines, whose perfomance was like 100 times less then modern dishwasher's processor.
So, the computers we use, the amount of perfomance we have within sc2 is more then enough to implement a good neural network evolution, it just may require some programming tricks to make it work effective and don't waste perfomance.
Why do you care? You have solved it with bank sharing between players.
So, if players cooperate vs AI, they will simply keep it in the personal bank, and at map init, map will shasre the best AI between all players and use it as the AI to kick players' asses.
Or another idea. Now some arcade maps levelup players, but their level reflects nothing, just the amount of games played. But we could create a map which would levelup player's "pet AI" written inside his bank. So, for example, a map like tug of war, but player only cares about strategy or income, while AI's fight against each other, chose unit composition, micro. AI could modify itself during the game or on init, and the result of the game would be the feedback for AI to estimate its modifications. So, the more a player plays, the smarter his AI gets, so it would be the real levelup.
@Zolden: Go
Well, it would be pain to sync banks for AI and server side saving would be much more efficient. But who knows I may make one for NSS:)
Also for complex AI-s the 1mb wouldnt be enough...
I was gonna say, you can make it multiplayer (like 2 players at most or something) and have your AI's current approach to army types spread like a virus through players. Not necessarily each player having their own AI, so much as each player spreading their AI's improvements to another player when they play with them.
Not a bad idea for getting past the server-side bank issue, but the 1mb bank limit size would limit it. Although 1mb can store quite a bit of info if it's condensed well.
For a multiplayer aspect, it could have an AI player as an ally for each player.
It could also learn by mimicking what a human player does, so as it plays against someone it could compile what he/she does and remember it.
Guys, we can't say anything about would or would not it be enough to store anything within 1mb without referencing a specific method. I've tried to imagine something that won't fit into 1mb and looks like it should be realy redundunt and probably wrong approach. Also, 1mb is 250 000 fixed numbers. Calculating stuff using all those will definitely affect perfomance. So, bank size isn't a bottleneck for a smart ass learning ai.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hey everyone, I recently put up an arcade map that uses an evolutionary algorithm (or genetic algorithm) to evolve the best combination of units to use against any army you specify. Basically, you create an army and it will find the best army to use against it, that does the most damage while losing as few units as possible.
It works by creating some random armies to fight in the first generation of battles. They get assigned a score and the highest scoring armies go on to fight in the next generation, along with some mutated versions with slightly different units. After a few generations of this, it evolves armies with the highest possible score. The results are displayed on a bar graph so you can see the improvement over time.
It's not so much of a playable game, because you can't control any of the units. It's more of a demonstration of a simple genetic algorithm.
Screenshots:
Screenshot 1: creating the army
Screenshot 2: units allowed for the evolving army
Screenshot 3: summary and algorithm settings
Screenshot 4: battle
Screenshot 5: results graph
Good job, evolutionary algorithms kick asses.
Would be cool to have server side banks per map to store genetic info of some kind of evolving AI, so it would be stupid after map upload, but the more ppl play it, the smarter AI becomes.
@Zolden: Go I'd also like to see if its possible to make it decide strategies, not only unit compositions.
@Olsenn: Go you should find someone willing to give it good use. Like Zolden said a type of map where the AI improves the more you play it. Even if it has to use client-side bank files.
I've done a lot of thinking about an AI that learns the more that people play against it. Server side banks would definitely be nice, but if that never gets implemented it could also be accomplished by having people upload their bank files to a website and releasing a smarter version every so often. A fully fledged AI that learns as it fights against people would be very cool. For now this is just a basic proof of concept and a demo of a genetic algorithm.
My map does have the option to output detailed results to a bank file, but it's output only. I might make a windows app to view them in a friendly way.
I do want to add attack behavior to it (attack priorities, focus fire, etc...) and evolve that along with the unit selection, instead of leaving it to the default unit AI.
If you intend on making an AI this advanced, honestly, why not make it in something other than SC2? Coming from someone who specializes in AI, I can tell you that making a true learning AI takes a very long time, and a very powerful server. Much longer than I would consider worth putting into an SC2 map.
Sure, saving the best results against a certain army composition, and then recording data works fine. But there is A LOT more to it. Luckily SC2 doesn't deal with hit detection, which makes things a lot easier. But normally you have to go through things like predicting the units movement by running A* algorithms on every unit, predicting the most probable movement patterns based on previous actions executed by a particular unit. If advanced priorities are created, it only becomes more complicated. Something as simple as the unit's range is a huge factor in calculating the estimated movement of a single unit. Once the base is figured, it has to iterate through a bunch of different scenarios, finding the most probable for success. It then creates the army, tests it, and then runs the process again.
AI is not just recording data, it is manipulating it and running simulations. But yeah... SC2 isn't nearly powerful enough for that. So this is just about as close as you can get to a learning AI, I suppose.
But that being said, excellent work. I am amazed at how well it worked out. Could be very useful in a lot of scenarios, and is quite frankly just fun to watch haha.
Great to be back and part of the community again!
@TacoManStan: Go Alternatively he could make a way more simple game, than SC2 melee in the editor and have learning ai with that game (something I thought for many of my games). The problem is there is no server side saving...
We can't say that sc2 isn't powerful for AI learning. AI learning includes alot of methods. Some of them need more calculation power than sc2 may provide, some are ok about what we have.
We just got spoilt by using unbelieavably powerful machines these days. While 30 years ago ppl had been doing amazing things on machines, whose perfomance was like 100 times less then modern dishwasher's processor.
So, the computers we use, the amount of perfomance we have within sc2 is more then enough to implement a good neural network evolution, it just may require some programming tricks to make it work effective and don't waste perfomance.
Why do you care? You have solved it with bank sharing between players.
So, if players cooperate vs AI, they will simply keep it in the personal bank, and at map init, map will shasre the best AI between all players and use it as the AI to kick players' asses.
Or another idea. Now some arcade maps levelup players, but their level reflects nothing, just the amount of games played. But we could create a map which would levelup player's "pet AI" written inside his bank. So, for example, a map like tug of war, but player only cares about strategy or income, while AI's fight against each other, chose unit composition, micro. AI could modify itself during the game or on init, and the result of the game would be the feedback for AI to estimate its modifications. So, the more a player plays, the smarter his AI gets, so it would be the real levelup.
It's up to us to decide what AI codes in its genes. Genes are just numbers, they can be interpreted as we want.
@Zolden: Go Well, it would be pain to sync banks for AI and server side saving would be much more efficient. But who knows I may make one for NSS:)
Also for complex AI-s the 1mb wouldnt be enough...
I was gonna say, you can make it multiplayer (like 2 players at most or something) and have your AI's current approach to army types spread like a virus through players. Not necessarily each player having their own AI, so much as each player spreading their AI's improvements to another player when they play with them.
@Amaroq64: Go
Not a bad idea for getting past the server-side bank issue, but the 1mb bank limit size would limit it. Although 1mb can store quite a bit of info if it's condensed well.
For a multiplayer aspect, it could have an AI player as an ally for each player.
It could also learn by mimicking what a human player does, so as it plays against someone it could compile what he/she does and remember it.
Guys, we can't say anything about would or would not it be enough to store anything within 1mb without referencing a specific method. I've tried to imagine something that won't fit into 1mb and looks like it should be realy redundunt and probably wrong approach. Also, 1mb is 250 000 fixed numbers. Calculating stuff using all those will definitely affect perfomance. So, bank size isn't a bottleneck for a smart ass learning ai.