Post on 30-Nov-2014
description
Better Chess ThroughBetter Chess ThroughGenetic ProgrammingGenetic Programming
Christopher SwensonChristopher Swensonchristopher-swenson@utulsa.educhristopher-swenson@utulsa.edu
Overview
The ProblemThe SolutionHow the Solution works
minimax strategyGenetic Programming
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
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
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
Minimax Tree
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
Example
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
Genetic Programming
John Koza, late 1980sExtension of Genetic Algorithms, with variable length chromosomes (programs)Express programs as LISP-like trees
4 + 5 +
4 5
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
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
Crossover (cont’d.)New Function A New Function B
# Pawns+
X
# Queens 9
/
# Knights 2
(# Queens x 9) + (# Knights / 2) # Pawns
Swap
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
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
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
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
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
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
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)))
8th Generation (White) vs. 1st Generation (Black)
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
Future Work
More Expressivity in Function SetConditionalsBetter Chess functionsTime
pruningHuman Java Applet interfaceFICS interface (freechess.org)Parallel computing ability
Use FICS?