Objective:
Chess game of Intelligent algorithm, online data a lot, very similar. I write this article, on the one hand is the classic <<PC game programming (Man-machine game)>> Expression of respect, on the other hand, also want to their own game programming life to do a review.
Previous blog: Game games of Artificial Intelligence (1)-evaluation function + game tree algorithm, focusing on the evaluation function + Game tree , this paper focuses on learning algorithms , and performance optimization and game-based problems.
Analysis:
The introduction of the evaluation function provides a theoretical basis for game AI.
However, the selection of the evaluation function is not simple, and the following problems are encountered:
1). The choice of evaluation factors, how to choose, whether the more factors the better
2). Normalization of the evaluation factor score
3). How to assign a reasonable weight factor
These are the places that need to be thought and optimized, inductive is the feature (factor) choice , weight coefficient learning .
It is mentioned that reinforcement learning , through interactive feedback with the environment to learn the model , see blog: "The application of several intelligent algorithms in the Othello program ∗".
Of course, the random algorithm in machine learning: simulated annealing/genetic algorithm , is also an effective way, and it is simpler and easier to understand, the author will focus on the interpretation here.
Genetic algorithm:
Genetic Algorithm (GA) is a simulation of the evolutionary process of nature. " Natural selection , adaptive Generation "is its eternal law.
First let's define the individual vectors (chromosomes):
Weight coefficients for each feature of the evaluation function are weighted vectors (A1, a2, A3, ..., an), as individual vectors
It must meet the following constraints :
• Coefficients in the weight vector and constant 1 (A1 + A2 + ... + an = 1)
• After the mutation/crossover operation, the coefficient weight and not 1, the normalization process is unified :
Again to define action :
• copy : The next generation copy of the weight factor vectors of the previous generation
• Variant : Randomly select a weight factor ai with a value set to a random value of (0~1) and then normalized
• Cross : Select two individual vectors and exchange the weighted coefficients by probability , and then the normalization process.
fitness function : Each individual and other individual PK, the total score is its fitness value.
1). Initial Stage : Select the vector individual for n random values
2). Mutual PK Phase : N vectors to each other PK, get their respective fitness value
3). Evolutionary Stage : Press Fitness value sort , introducing elimination rate/mutation rate, etc., for copy/mutation/crossover operation, Birth of a new n individual
Continuous Iteration 2), 3) Two stages until the appropriate individual is selected.
This process can achieve our learning needs, of course, we can continue to do the following optimizations:
introduction to the runner mechanism : Select an elite individual based on experience, Participate in the PK phase to assess individual fitness, but does not participate in Evolution (copy, mutation, crossover) process.
evolution by adaptive probability : Prevent a small group of highly adaptable individuals from being replicated and inherited. The case of the local optimal solution .
The rate of replication/mutation/crossover, as well as the number of groups, will affect the number of iterations and the convergence effect.
Summarize:
After using the genetic algorithm to study the parameters, the weighting coefficients can be allocated rationally, and the pre-agreed feature is selected . In short, ^_^ by filtering out features that approximate the weight factor to 0.
Originally wanted to continue to talk about the game AI classification, advanced optimization of the game tree , found that space is limited, then put the next article.
Written at the end:
If you think this article is helpful to you, please give it a little reward. In fact, I would like to try to see if blogging can bring me a little bit of revenue. No matter how much, is a kind of sincere affirmation to the landlord.
Artificial Intelligence of Chess Games (2)--Learning algorithm