Evolving Neural Networks to Play Mastermind
CSEF · 2011 Mathematics & Software Second Award
Overview
Objectives/Goals The objective is to write a computer program that trains neural networks using a genetic algorithm to play Mastermind. It is hoped that the program can train neural networks to be able to, on average, solve at least 1%, or 13 combinations, of all 1296 combinations of Mastermind. The impact of changing different settings of the neural networks and genetic algorithm will be explored. Methods/Materials A computer was used for programming and running the experiment. The Mastermind simulating program itself was coded by the researcher in Java using resources from both Heaton Research's open source Encog Project and Sun Microsystems. The program generates a population of neural networks, trains the networks on a random subset of Mastermind combinations using a genetic algorithm for 20,000 epochs, then exports a log summarizing the number of combinations solved by the best-evolved network as well as the score the network received from the fitness function. Results With four different settings, the program was able to evolve a neural network that could solve at least 13 out of 1296 combinations. The four settings that allowed the program to achieve this were with the baseline settings (off of which all of the other settings were varied), with the hidden layer size decreased, with the mutation rate increased, and with the crossover rate increased. Conclusions/Discussion Increasing the crossover rate allows more networks to survive, which may lead to greater diversity in the population; this diversity means a greater chance for a latent beneficial gene to survive until it is needed, producing more successful results. Also, introducing a "supermutation" function into the program greatly improves performance. Supermutation involves randomly mutating every neural network in the population when no progress is made after a certain number of epochs. This allows the neural networks to escape from local maxima and continue improving.
Summary statement
This project involves writing a Java program that uses a genetic algorithm to train a population of neural networks to play Mastermind.
Help received
Parent helped with discussing the design of the program.
Awards (1)
Competition history
- CSEF 2011
Resources
Related projects
CSEF · 2019
Creating a Neural Network to Play the Game of Connect Four Using a Genetic Algorithm
CSEF · 2016
Analyzing the Effects of Hidden Neuron Quantity on Neural Network Performance
CSEF · 2014
Balancing Diversity and Fitness while Evolving Neural Networks
CSEF · 2003
Artificial Intelligence: Can a Neural Network Learn to Play Connect 4?
ISEF · 2020
Implementing Supervised Deep Learning with Feedforward Neural Network Using Genetic Algorithms
CSEF · 2009
Choice Based on Past Knowledge using Multi-Layered Neural Networks in Tic-Tac-Toe
ISEF · 2014
Programming an Adaptive Artificial Intelligence Utilizing Neural Networks and the Monte Carlo Tree Search Method
ISEF · 2016
Permaximize
Closest projects by meaning, across every fair and year in the corpus.
Browse more like this
Source: California Science & Engineering Fair public projects