December 2019
Intermediate to advanced
368 pages
11h 10m
English
This function is an implementation of the maze-solver fitness function that we discussed earlier. This function receives the distance to the maze exit, the novelty score, and the list of coefficient pairs generated by the current generation of the objective function candidates. Next, it uses the received input parameters to calculate the fitness score as follows:
normalized_novelty = novelty if novelty >= 1.00: normalized_novelty = math.log(novelty) norm_distance = math.log(distance) max_fitness = 0 best_coeffs = [-1, -1] for coeff in obj_func_coeffs: fitness = coeff[0] / norm_distance + coeff[1] * normalized_novelty if fitness > max_fitness: max_fitness = fitness best_coeffs[0] = coeff[0] ...
Read now
Unlock full access