210 likes | 216 Views
By Bharat Ponnaluri. Design of a real time strategy game with a genetic AI. Abstract. Current strategy game AI Involved combinations of heuristics and constants. The combinations need to be optimized for the AI to be effective
E N D
By Bharat Ponnaluri Design of a real time strategy game with a genetic AI
Abstract • Current strategy game AI • Involved combinations of heuristics and constants. • The combinations need to be optimized for the AI to be effective • Too many possible constants&combinations-->difficult optimization • Chess heuristic evaluations • Moves available • Is the king safe • Pawn structure • Material balance • Genetic AI • Can produce constants and combinations of heuristic algorithms quickly by eliminating suboptimal combinations.
Introduction • Design of a simple real time strategy game • Build troops and try to take over cities • Like Risk in real time • Goal is to have an intelligent AI optimized with genetic algorithms • AI design • Coding of simple building block heuristic evaluation functions • Addition of constants(Agressiveness,stinginess) that determine behaviour • Chromosomes will be random combinations of • Heuristic evalution functions • Used to evaluate the quality of a possible course of action based on game data
Personality Traits • Goal: To make the AI more interesting and humanlike • Traits • Agressiveness • Paranoia • Stinginess • Vengence • Trustworthiness
Observation • AI will take advantage of other players' behavior • Examples • Assertivness • The AI will keep track of when a player retreats • The AI will attack a player which retreats a lot • Attacking game leader • One player is threatening to win • AI will track who tries to stop that player • Then the AI will let that player do the work
Game Theory • Advantages • Not very complicated • Easily understandable by AI • Good model of human behavior
Game Theory: War of attrition • Two players fighting over city • Backing down=loss in percieved assertiveness • Fighting=massive loss in strength • t=time that conflict lasts
Sample chromosome • Chromosome • enemyStrength()/2*myStrength()-3*fooA()/43.........+power() • Possible genes • public int fooA() • .... • public int enemyStrength() • .... • public int myStrength()
Heuristic evaluation functions • Heuristic evaluation functions • Used to evaluate the quality of a possible course of action based on game data • Example: • Public int getTrafficJamFactor() • Return ( 1.001^(number of cars))/roadSize
Game Theory • Advantages • Easy to understand • Representes humanlike behavior • Simple for computer to follow
How do genetic algorithms work • Replicate evolution • Steps • Determine random combinations of heuristics and constants(chromosomes) • Test chromosomes • Remove suboptimal chromosomes • Mutate surviving chromosomes • Swap data between surviving chromosomes • If chromosomes are optimal,end algorithm • Otherwise, repeat steps 1-7
Advantages and Disadvantages • Advantages • Can function without user input • Can optimize a large number of constants • Usually is very good at optimizing stuff • Can determine unknown solutions • Possible disadvantages • Genetic algorithms are complicated • Take a significant amount of computing power • Networking will increase complexity
Evolutionary Stable Strategies(ESS) • Gene pool of defectors means cooperating players will lose • Advantages • Diverse AI personalities • Disadvantages • May lead to suboptimal/boring AI's
ESS: Example • Population of turtling AI's • AI's only counterattack or attack weak players • A more balanced AI will lose • Playing against a group of turtling AI's is boring
Degree-Constrained Spanning Trees • Degree constrained spanning tree • All verticies are nodes • Maximum number of leaves per node • Genetic algorithm • Optimized weights for a heuristic evaluation function
Tiddlywinks • Fit largest possible circle that does not overlap discs • Genetic algorithm • Generates random circles • Keeps the larger circles
Generating a target number using a mathematical expression • Combination of numbers(1-9) and mathematical operators(-,+,*,/) adding up to a target number • Each number=4 bits • Chromosome • 0110 1010 0101 1100 0100 1101 0010 1010 0001 • 6+5*4/2 +1 • Suboptimal chromosomes-->result far from target number • Can be scaled for large numbers &decimals • No attempting to use brute force to test out random combinations.
New Heurstics • Find Targets() • Average proximity • Income power factor • Troop power factor • Potential borders
Testing results • Numbers greater than 1 are not good • From last working version(before new heurstics)
Conclusion • Speed is an issue • Debugging was unexpectedly difficult