4
$\begingroup$

I have been working for ages on a neuro-evolution AI program, where cars learn how to race around a track. Presently, I have a rudimentary fitness function that awards points for every degree traveled in the CW direction about the center of the window (removes points in CCW dir) and removes a certain amount of points for every collision that occurs. Cars also lose points for every moment they stay still and/or are colliding with something. My end goal is to create cars that can complete a track full of obstacles, faster than a human controlled car.

Is there a better fitness function that would result in more efficient cars that

  1. make better use of their sensors,
  2. are efficient in getting around the track (don't weave like a drunk driver), and
  3. are faster in general (cars are too cautious, but this is a race!)

?

Half of the population seems to just spin around.

I have fully implemented my neuro-evolution program. Here's my implementation. However, you'll find that it isn't perfect.

How should I alter my fitness function to generate better driving cars?

Currently, the cars will only turn left or right if the outer sensors are activated. However, if the sensors directly in front are activated, the neural network is configured in such a way that "ignores" this signal. So, the cars crash head-on into obstacles but avoid obstacles in their periphery. I think this is due to the fact that the fitness function (which gives points for the displacement in 3 second time period) is too generous and removes the incentive for cars to avoid obstacles. I've tried altering the punishment for collisions and the reward for driving in the right direction but it still isn't performing the way I would like it to.

Here are some screenshots

Population of Cars in Racing Ring Revive mode (revisiting past generations of cars

$\endgroup$
4
  • $\begingroup$ It would be nice to know how you exactly determine that the car travelled (rotated) 1 degree. Does the car get positive reward every time when it goes around its own little circle? $\endgroup$ Commented Oct 7, 2017 at 19:03
  • $\begingroup$ It seems like you might want to add additional layering for score instead of just the immediate I moved one degree I get a point. Perhaps a moving window that calculates total degrees moved over the last TBD-seconds. I would probably give that more weight than near-term score. I would think that should help prevent weaving and circling. Which might beg the question of why keep a near-term score at all but I would keep the near-term score because I suspect it will help get around obstacles. $\endgroup$
    – Dunk
    Commented Oct 11, 2017 at 17:21
  • $\begingroup$ You also might need to take into account 'obstacles' movement. That includes speed and direction. Perhaps your cars are circling because they are trying to avoid other cars. However, in a real race, cars race side-by-side because they have to assume the other drivers are going to follow certain 'driving rules'. Thus, they don't need to be concerned about hitting cars driving next to them. Their biggest concern is not hitting the car in front of them. $\endgroup$
    – Dunk
    Commented Oct 11, 2017 at 17:25
  • $\begingroup$ You can set a series of checkpoints - see this excellent article by Byte Master on codeproject.com: codeproject.com/Articles/1220276/ReInventing-Neural-Networks $\endgroup$
    – Mike AI
    Commented Feb 22, 2018 at 19:28

1 Answer 1

1
$\begingroup$

You're correct that it is related to the fitness function, but only indirectly. Recall that a function is the mathematical embodiment of a conceptual relationship. The model is a motion model. Proximity is not simply applying the distance formula $D = \sqrt{(x_2 - x_2)^2 + (y_2 - y_2)^2}$.

Proximity as we "feel it" when driving a car is based on the risks we see in the trajectories of ourselves and the other moving objects along with the stationary objects. Mathematically, this is an integral over time of a distribution of probable locations.

Look for work in the aeronautics industry about collision avoidance. The mathematics and algorithms are well developed for antiaircraft weaponry (where the fitness function is the inverse of the one you want) and air traffic control, where the fitness is like yours except with an altitude dimension.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .