better chess through genetic programming
DESCRIPTION
A tutorial on genetic programming with applications to chess.TRANSCRIPT
![Page 1: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/1.jpg)
Better Chess ThroughBetter Chess ThroughGenetic ProgrammingGenetic Programming
Christopher SwensonChristopher [email protected]@utulsa.edu
![Page 2: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/2.jpg)
Overview
The ProblemThe SolutionHow the Solution works
minimax strategyGenetic Programming
![Page 3: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/3.jpg)
Programming Chess
Easy to learn, difficult to master gamesUntil recently, almost impossible for computers to play at the grandmaster level
State space incredible 28000 raw, 2600 with pruningProgramming for chess is an expensive process, requiring chess experts to work with programmers for years
RequirementsCheapFastMinimize development time
![Page 4: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/4.jpg)
SolutionUse a standard technique ( minimax)
Looks at all possible future moves to a certain depth4 ≈ Novice8 ≈ Expert12 ≈ Grandmaster
Branch factor for chess is around 40, 7–8 with good pruning techniques (812 ≈ 70 billion)Requires an “evaluation function” for choosing which future is preferable
Evaluation function:Gives a board a numerical score (utility)This is the real meat of
![Page 5: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/5.jpg)
Minimax
– Keeps track of best move for us to make (we want to maximize the utility the worst situation we can get ourselves into) – Keeps track of best move for opponent to make (we want to minimize the utility of our opponent’s best situation)Works by looking at all possible decisions you could make, by estimating all possible decision your opponent could make, etc
![Page 6: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/6.jpg)
Minimax Tree
![Page 7: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/7.jpg)
Evaluation Functions
Just a simple function to give a board a scoreEvaluate the leaf nodes, and then let minimax determine which path is optimalFor chess, should incorporate which pieces are still on the board, position, etcThis is where the hard work comes in
![Page 8: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/8.jpg)
Example
![Page 9: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/9.jpg)
Genetic AlgorithmsMethod allowing you to generate near-optimal solutions with little knowledge, using the properties of evolutionSolutions guaranteed to reach near optimality over time (Schema Theorem)Solutions represented as fixed-length “chromosomes”
Crossover operations offspringMutations variation
Best suited for ≥ NP problemsTraveling Salesperson Problem
![Page 10: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/10.jpg)
Genetic Programming
John Koza, late 1980sExtension of Genetic Algorithms, with variable length chromosomes (programs)Express programs as LISP-like trees
4 + 5 +
4 5
![Page 11: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/11.jpg)
Crossover
+
X
# Queens 9
# Pawns
/
# Knights 2
Function A Function B
(# Queens x 9) + (# Pawns) # Knights / 2
Select two functions from gene pool at random
![Page 12: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/12.jpg)
Crossover (cont’d.)
+
X
# Queens 9
# Pawns
/
# Knights 2
Function A Function B
(# Queens x 9) + (# Pawns) # Knights / 2
Select a node on each function at random for crossover
![Page 13: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/13.jpg)
Crossover (cont’d.)New Function A New Function B
# Pawns+
X
# Queens 9
/
# Knights 2
(# Queens x 9) + (# Knights / 2) # Pawns
Swap
![Page 14: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/14.jpg)
Gene Pool
100 Generations512 Chromosomes in the Gene Pool / GenerationThe next generation is determined by randomly selecting two chromosomes, mutating and crossing them over, and letting them play a chess matchEach time the best is calculated by holding a tournament
![Page 15: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/15.jpg)
Why Genetic Programming?
AdvantagesEasy to programFastShown to work in other research
DisadvantagesProblems with depth on first several movesLimited by expressivity of “function set” (genes)High amount of branchingStrategy often complex
![Page 16: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/16.jpg)
Simpler Task
Vinciperdi – aka “Loser’s Chess”Same as chess, but to win you must lose all of your pieces or force your opponent to checkmate youIf there is a capture available, you must make it
![Page 17: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/17.jpg)
Why Loser’s Chess?
Simpler than regular chessBranching reduced by forced captures
Faster than regular chessOpenings lead to captures very fastGames tend to be end fast, since captures occur almost every move
A simple evaluation function set is sufficient for most modelingMuch of the work for Loser’s Chess can be extended to regular chess
![Page 18: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/18.jpg)
Work So Far
In Spring 2003, I began implementation of these concepts in JavaImplemented multi-threaded genetic programming library and minimax tree searchingPicked up work again in Fall 2004, starting with implementing rules for Loser’s ChessCurrently at about 4,000 lines of source code
![Page 19: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/19.jpg)
Preliminary Results
Difficult to judge progressProgram generates incredibly complicated solutions (hundreds of points)Takes long time to run (several days for 100 generations) due to the complexity of calculations on a chess board (~ 2 hours / generation)Each generation increases the average complexity in the gene pool, and therefore increases execution time
![Page 20: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/20.jpg)
Some Example Chromosomes for Normal Chess
1st generation – 15 points*(+(*(# Pawns, 7),+(1,# Attacked Pieces)),-(*(# Attacking Pieces,# Attacked Pieces),+(# Queens, 5)))
8th generation – 15 points+(-(/(# Rooks, 15),+(# Queens, # Attacking Pieces)),*(*(# Attacking Pieces, # Attacked Pieces),*(# Bishops, # Queens)))
![Page 21: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/21.jpg)
8th Generation (White) vs. 1st Generation (Black)
![Page 22: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/22.jpg)
But What About Humans?
• These programs are designed to play each other, and therefore many flaws may go undiscovered until humans play some of the games
• It is possible to incorporate a Java Chess Applet into the genetic functions, allowing human players to affect the outcome
![Page 23: Better Chess through Genetic Programming](https://reader033.vdocuments.site/reader033/viewer/2022061201/547a979cb4af9f806f8b4716/html5/thumbnails/23.jpg)
Future Work
More Expressivity in Function SetConditionalsBetter Chess functionsTime
pruningHuman Java Applet interfaceFICS interface (freechess.org)Parallel computing ability
Use FICS?