Tutorial: Maze

This page serves as a refrence for the maze demo.

Explanation of Parameters:

Model Size:Number of nodes in the hidden layer of the recurrent neural network that each agent represents. The more nodes, the more complex the model is.

# of Generations: Number of generations used to train the maze-solving algorithm. Since this problem is simple, this number is low, and most successuful algorithms solving this problem will succeed within 20 generations.

Population Size: The number of agents in the population.

Selection Proportion: Proportion of the fittest agents that are chosen for selection.

Mutation Probability: The probability that any given piece of information of an agent is mutated during crossover.

Mutation Factor When a gene is mutated, the difference the mutation makes is determined by the mutation factor. The higher the mutation factor, the more difference a mutation makes.

Explanation of Performance Metrics

Maximum Fitness of Each Generation: This value ranges from 0 to 3. The maximum fitness of all agents of each generation. The fitness is dependent on the amount of moves taken to reach the goal, the final distance from the goal, and wether or not the agent survived. The higher this value, the better.

Proportion of Surviving Agents of Each Generation: The proportion of agents that survived, ranging from 0 to 1. The higher this value, the better.

Minimum Distance From Goal of Each Generation: The minimum distance from the goal at the end of the generation out of all agents. A value of zero means at least one agent reached the goal. The lower this value, the better.

Moves Taken to Reach Goal or Die of Each Generation: The amount of moves made by the agent who made the least moves. The maximum amount of moves allowed is 30. The minimum amount of moves it takes to ge to the goal is 18. The lower this value, the better.

Analysis of Presets:

Standard: This preset is nothing special as it uses standard parameters to optimize this maze solving algorithm. By generation 5, the agent is able to solve this maze. The fitness peaks at generation 4 but levels off at generation 5 and onwards. This is most likely due to some agents not being perfectly optimized. The proportion of agents that survive steadily increases over time, but not to the point we would want it to (only twenty percent of agents survive by the last generation). Some agents make it to the goal by generation 2, but do not take the optimal path. The best agent finds the optimal path by generation 5.

Better: This preset is the same as the standard exept the model is more than twice as complex (50 nodes compared to 20). This should mean that the model is smarter and should be better and more robust. The model converges on a solution pretty quickly, and has generations where an agent reaches perfect fitness (3). By generation 8, almost all the agents in the population survive. A more complex model yeilds more successful agents.

Low Population: This preset reduces the population size from 100 to 20, meaning the genetic algorithm has less chances to find the correct solution. As you can see in the maze, the model fails to solve it. However, the model reaches maximum fitness by generation 10, and all the agents survive. This is due to the agents just learning to stay in one place the entire time, evident by their distances to the goal and amount of moves taken. Although the algorithm "optimizes" the fitness function, it does not accomplish our goal, showing why a large population is important.

High Mutation: This preset has increased the probability of mutation and the level of mutation. In this preset, the agents sometimes solve the maze, but sometimes don't. The fitness graph is erratic, and barely any agents survive. Some agents reach the goal, but they don't always take the most optimal path. While this algorithm may be able to solve the maze in any given generation, the solution will be obfuscated out of existance due to the high mutation rate. While mutation can be helpful in preventing premature convergence, too much mutation will ultimately ruin our results.