Using genetic algorithm to build a Fifa Ultimate Team squad.
#TODO
More about Genetic Algorithm
The Genetic Algorithm has 5 main components:
- Initial population
- Fitness function
- Selection
- Crossover
- Mutation
Each of these components were adapted to create the best Fifa ultimate team squad. More about Fifa ultimate team.
The initial population is represented as a List of Squads with randomly selected players from the Ultimate team database. The number of squads is determined by the population size parameter. The intial population is created using the called getInitialSquads()
in GeneticAlgorithm.
Params:
- populationSize : int = number of squads in each generation population
The fitness function is represented by the chemistry of each squad, an attribute from the Links formed between Players in specific Positions. To find the chemistry of the squad call getChemistry()
method.
Selection is based on probability. The higher the fitness value for a particular squad, the more likely it is to be selected. This is possible by creating a squad pool with all squads given their fitness. Squads are selected at random from the pool.
Once a squad is selected from the selection process, it goes through the crossover step with another squad. The problem is that squads from different countries/clubs do not match well. Therefore, a squad will only perform the crossover process with a squad of the same country or club. This is done by picking another squad from the squad pool at random until a squad of the same country or club is found. Once found, the squads are combined to create a new squad with players from both teams. There are equal chances of a player to come from either squad.
Mutation is the process of picking a random player from a squad and swapping him with a random player from the Ultimate Team database. Mutation rate is initially set to 25%, but this value can be adjusted in the main function.