160 likes | 286 Views
By Bharat Ponnaluri. Design of a real time strategy game with a genetic AI. Abstract. Current method of AI programming: Functions combinations of evaluation functions+constants Disadvantages of current method Difficult to generate good combinations
E N D
By Bharat Ponnaluri Design of a real time strategy game with a genetic AI
Abstract • Current method of AI programming: • Functions combinations of evaluation functions+constants • Disadvantages of current method • Difficult to generate good combinations • Difficult when brute force calculations are not feasible • A skilled player can often beat a handicapped AI with a signficant numerical advantage.
Images from: http://www.twcenter.net/forums/showthread.php?t=359530
How do GAs 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
Sample chromosome Chromosome enemyStrength()/2*myStrength()-3*fooA()/43.........+power() Possible genes public int fooA() .... public int enemyStrength() .... public int myStrength()
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 • GAs are complicated • Take a significant amount of computing power • Networking will increase complexity
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
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
Important Classes • Classes • FormualaGenerator: • Driver Program • GraphPanel: • Draws the graph of the average fitness and maximum fitness. • Makes the GA run periodically in synchornization with the graph. • Chromosome: • Represents the chromosomes/expressions.
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 • Sample Expressions for 150 • Static Mutation 1.0292804250299605 + ((2.7400839829565777 / 1.0605221382369576) * 7.741718241469524 * 7.316070011134583) - ((-0.9821438516501173) / 4.043144676725913) + (0.9986661909539591 * 6.634650893629718 * 0.3645726822807098) = 150.026535 --Dynamic Mutation 1.0292804250299605 + ((2.7400839829565777 / 1.0605221382369576) * 7.741718241469524 * 7.316070011134583) - ((-0.9821438516501173) / 4.043144676725913) + (0.9986661909539591 * 6.634650893629718 * 0.3645726822807098) = 150.026535
Generating a formula for an input-output pair -Formula: x^4+x^3+x^2+x+1 -Sample Expressions -1*x/3-3*x+8-1*x+9-10*x*7-5*x*9/6*x+10*5*x*6*6*x-3/8*x+7-8*x+4*5*x*4-9*x+4-6 -9*x*9*2*x*9*3*x/3+5*x-5*1*x/9/2*x/7*8*x*1/7*x*5/8*x-4-7*x/5*4*x*4/1*x/4*6 -Conclusion: Polynomials are not recognized.
Analysis of results • Using dynamic muation rates did not help • The GA generally works but occasionally crashes due to a bug which deletes all the chromosomes • The average change and static deviation in fitness does not change • Shows that the GA does not get stuck on local exterma.