This aglorithm was designed to play an evolutionary strategy to the NIM game. The population is initialized with randomly chosen parameters that have a value between -1 and 1 and for each individual the fitness function counts how many games are won a total of times. The best strategies are also selected. We then have the function of mutation of the strategies with the subsequent replacement of the mutated population. Everything is repeated for a series of cycles and at the end the strategy with the best fitness of the final population is returned. "evolved_strategy_function" is the function that uses the parameters of the best evolved strategy to make moves in the Nim game based on specific logic. The code is clear and readable and the various comments provide further feedback to better understand all the phases of the algorithm. The use of the evolutionary approach is also clear thanks to the code which is modular with all the functions for mutation, fitness and evolved strategy well explained in the code.
This aglorithm was designed to play an evolutionary strategy to the NIM game. The population is initialized with randomly chosen parameters that have a value between -1 and 1 and for each individual the fitness function counts how many games are won a total of times. The best strategies are also selected. We then have the function of mutation of the strategies with the subsequent replacement of the mutated population. Everything is repeated for a series of cycles and at the end the strategy with the best fitness of the final population is returned. "evolved_strategy_function" is the function that uses the parameters of the best evolved strategy to make moves in the Nim game based on specific logic. The code is clear and readable and the various comments provide further feedback to better understand all the phases of the algorithm. The use of the evolutionary approach is also clear thanks to the code which is modular with all the functions for mutation, fitness and evolved strategy well explained in the code.