BoxCar 2D

Home | Designer | Best Cars | Forum | News | FAQ | The Algorithm | Versions | Contact

1. Basic Info

What is this?
What makes the cars stop?
Why isn't the target score increasing anymore?
Why do cars spawn upside-down?
What about a new version?

2. Controls

What does the Mutation Rate do?
Why Vote cars Up/Down?
What does wheel frequency do?

3. Output

What do the scores mean?
What do the red/black lines mean?
How do I save a car?

4. Input

How do I input a car?
Why doesn't the car perform the same after copy/paste?
Why doesn't my car look the same after input?
How do I import the entire current population to another track


1. Basic Info

 

What is this?

The program learns to build a car using a genetic algorithm. It starts with a population of 20 randomly generated shapes with wheels and runs each one to see how far it goes. The cars that go the furthest reproduce to produce offspring for the next generation. The offspring combine the traits of the parents to hopefully produce better cars. Now with the button at the bottom left u can choose to input cars and different terrains. This lets people post their results and even design a car by hand.

car evolution

It uses a physics library called box2D to simulate the effects of gravity, friction, collisions, motor torque, and spring tension for the car. This lets the car be a wide range of shapes and sizes, while still making the simulation realistic. This is based on the AS3 box2D flash port of the library. Watch the demo of some of its capabilities.

My inspiration for this project comes from qubit.devisland.net/ga. My implementation uses the physics library to make the car a real object instead of two point masses. There are also many extra variables because of the complicated car and axles and the color cleary illustrates the evolution.

What makes the cars stop?

There is a stopping condition says that the car has to move a little bit in any direction. It has less time to move at the beginning of the track and more time later on when its harder. Choosing when to make the car stop is turning out to be one of the biggest challenges. It's either too early or too late.

Now theres also a timer for each terrain so the cars won't get stuck forever and you can leave it running unattended.

Why isn't the target score increasing anymore?

The cars stop at the end of each track. For the default track thats usually around 1200. Try the other tracks. The Default (Random) track changes the track every generation. All the tracks eventually end but most get impossible towards the end (I think).

Why do cars spawn upside down?

I know it's painful when a cool car spawns upside down, but the program doesn't have any sense of what is up or down. The position and angles of the wheels are part of what the program is trying to learn/optimize. For more information about how the data is represented click see Designing the Car.

What about a new version?

I'm always working on updates. Thanks for the interest and suggestions. You can see i've implemented a lot of them.

 

2. Controls

What does the mutation rate do?

Each generation, in addition to crossover, the cars also undergo mutation. Each aspect of the car has the possibility to change: the shape of the car, the axle angles, the number of wheels, and wheel position. The mutation rate is the probability that each variable mutates at the end of the generation. At 100% all variables mutate each generation and nothing is learned. Therefore it provides a good control.

Why vote cars up/down?

Voting cars up gives them a better chance in the tournament selection. And voting cars down removes them from the mating pool entirely. The next button is a chance to just stop the car in its tracks, without killing it.

What does the wheel frequency do?

The wheel frequency controls the probability of randomly generating wheels at the beginning and with mutation. At 0% there won't be any wheels and at 100% there will be the maximum number of wheels all the time. It's better to set it lower as you increase the wheel size.

3. Output

What do the scores mean?

The score for each car is the distance it travels in the x-direction. The scores for each car are displayed in blue on the left side of the screen. The time is the amount remaining for that car. After each car finishes, its final score and runtime are displayed in blue on the left.

What do the red/black lines mean?

The plotted lines on the top right of the screen show the maximum score (red) and average score (black) for each generation.

How do I save a car?

Click the "Copy Curent" or "Copy Best" to copy the current or best car to the clipboard. Then you can paste it into the designer to modify it or use the seed button to paste in into any terrain.

4. Input

How do I input a car?

Click on the "Input Seed / Terrain" button at the bottom left on the screen. You can then paste a car into the program and it will copy that car directly into the track and its offspring with random cars.

Why doesn't the car perform the same after copy/paste?

Internally the cars are represented with much higher precision than when they're output. This can lead to slight differences in the physics that can lead to big difference in the outcome. Also, due to floating point precision on different machines, its not guaranteed to run the same on different architectures. I've increased the precision of the output to help cars hopefully perform the same each time.

Why doesn't my car look the same after input?

The wheel number effects the way a car looks. Make sure the wheel number is set properly. In version 2.2 and above, the wheel number is part of the output to avoid confusion. It will accept input without the wheel number and set it so every wheel thats on in the chromosome in created.

How do i import the entire current population to another track?

This is a somewhat hidden feature. Click the "Input Seed / Terrain" button and change the terrain. Then click cancel and you're current population is on a new track.