Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23189

Car around the track

$
0
0

I have wrote the code to achieve the AI to learn how to do a lap on its own. For that, I have used Pygame and NEAT.

When training the AI, the program can only take 4 decisions:

  • Forward
  • Right
  • Left
  • Nothing (moves it a bit forward, otherwise I got stuck with some genomes not moving at all)

The data fed to the AI is the distance between the car and the edge of the track in 5 points, forward, at +45 and -45 deg and +90 and -90 deg. See picture: Car going around a track.

Each green horizontal line at the track is the "checkpoints" or reward for the AI

Problem is, when I run the simulation, I some genomes are not reproducing but the best ones they keep repeating the same outputs over and over again indefinitely, and seems the AI is not learning at all just reproducing the over and over the best performance.If population size is, lets say 20 cars, i end up only with the best car doing over and over the same route, instead of having the best car reproducing 20 times overwriting the "non good" ones.

Question:

  • How can I set the AI to get the best car and reproduce it but do not do the same route, but improvise a bit from it?

The NEAT file:

[NEAT]fitness_criterion     = maxfitness_threshold     = 10000pop_size              = 20reset_on_extinction   = False[DefaultGenome]aggregation_default     = sumaggregation_mutate_rate = 0.02aggregation_options     = sum# node activation optionsactivation_default      = reluactivation_mutate_rate  = 0.1activation_options      = relu# node bias optionsbias_init_mean          = 0.0bias_init_stdev         = 1.0bias_max_value          = 30.0bias_min_value          = -30.0bias_mutate_power       = 0.6bias_mutate_rate        = 1bias_replace_rate       = 0.3# genome compatibility optionscompatibility_disjoint_coefficient = 1.0compatibility_weight_coefficient   = 0.5# connection add/remove ratesconn_add_prob           = 0.5conn_delete_prob        = 0.8# connection enable optionsenabled_default         = Trueenabled_mutate_rate     = 0.01feed_forward            = Trueinitial_connection      = full_nodirect# node add/remove ratesnode_add_prob           = 0.2node_delete_prob        = 0.5# network parametersnum_hidden              = 10num_inputs              = 3num_outputs             = 4# node response optionsresponse_init_mean      = 1.0response_init_stdev     = 0.0response_max_value      = 30.0response_min_value      = -30.0response_mutate_power   = 0.01response_mutate_rate    = 0.01response_replace_rate   = 0.01# connection weight optionsweight_init_mean        = 0.0weight_init_stdev       = 1.0weight_max_value        = 30weight_min_value        = -30weight_mutate_power     = 0.5weight_mutate_rate      = 0.8weight_replace_rate     = 0.1[DefaultSpeciesSet]compatibility_threshold = 3.0[DefaultStagnation]species_fitness_func = maxmax_stagnation       = 2species_elitism      = 1[DefaultReproduction]elitism            = 3survival_threshold = 0.2

Question:

  • How can I set the AI to get the best car and reproduce it but do not do the same route, but improvise a bit from it?

Viewing all articles
Browse latest Browse all 23189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>