
HTML5 Genetic Cars - jmduke
http://rednuht.org/genetic_cars_2/
======
IvyMike
Maybe someone more versed in the state-of-the-art can help me: has the concept
of "speciation" ever been applied to genetic algorithms?

In my instance, there are two predominant "types" of cars that are doing
approximately equally well--the "rhinoboat" and the "assdragger". But when
these two solutions are combined in the crossover, I think they make an
offspring that is terrible.

If the algorithm would mate only the rhinoboats with rhinoboats and
assdraggers with assdraggers, I'm convinced we'd end up with some
superrhinoboats and superassdraggers, but instead I just get an unhappy
compromise.

Maybe make "similarity to self" one of the genotype parameters. A high rating
here would mean the phenotype would have a bias against being combined with
dissimilar creatures. This allows the propensity towards speciation to develop
evolutionarily, too.

~~~
ianterrell
You, sir, have mastered at least one of the two hard problems in computer
science.

~~~
habosa
Seriously. I knew right away that I also had "rhinobat"s and "assdragger"s.

------
bsimpson
I just spent half an hour of my life rooting for imaginary cars that ceased to
exist as soon as I closed the tab.

~~~
grinich
On the cosmic scale, rooting for any sports team isn't much different... ;P

~~~
BHSPitMonkey
Even from practical frames of reference, it has about the same effect on most
of the spectators.

------
ronaldx
Observation: The cars tend to optimize to get over a challenging hurdle (while
it's being worked on, the cars converge to a single solution: which works
well), but then are no longer general enough to get over later hurdles.

~~~
acallaghan
I found my life to be strikingly similar

~~~
ihsw
Unlike those cars we can move in three dimensions, so you're free to find
another set of hurdles to overcome. :)

~~~
jld
If only we could move freely in four dimensions, as to navigate around events
that are difficult hurdles to overcome, such as comet strikes and nuclear
holocausts.

~~~
Yourfags
that would still be a third dimension since you're just choosing to avoid
something entirely within our realm, ever advancing technology is still not
advanced compared to forever... or something like that =)

------
hvs
That system is too complex not to have an intelligent designer.

~~~
unimpressive
Even if it is, who designed the designer?

~~~
nsomaru
And thus we (I) infer the existence of the big G in the infinity of
intelligent designers required to keep going down that rabbit hole.

------
SeanDav
Is there a way to save the current world seed?

I have a layout that is defeating all cars even after 50 generations and
counting. Would love to keep on testing against this world.

~~~
Glyptodon
Have people actually had the course completed? I've been using 'genghisKhan'
as my track seed and they always stop around 2/3 to 3/4 of the way it seems.

~~~
dpcx
The "course" always gets longer. No matter how long it currently is.

~~~
dreen
No, it stops at around ~220 after which the car just falls into the void.

I got to around 200 without hacking after about 300 generations but then the
terrain just gets too much for any of the little guys.

So if you want to beef them up a little, type this in javascript console:

    
    
        motorSpeed = 50;
        wheelMaxRadius = 2.0;
        chassisMaxAxis = 2.5;
    

and hit New Population

~~~
obituary_latte
Oh man...some hilarious iterations there. Especially funny after playing with
the normal version for a while. All of a sudden: "PARDON ME HUGE WHEELS
HAULIN' ASS COMIN' THROUGH"

~~~
pavel_lishin
I can't even see the track now.

------
89vision
This looks very similar to something that was posted on reddit a couple of
years ago.

[http://boxcar2d.com/](http://boxcar2d.com/)

~~~
jld
The author mentions it's based on that, but totally rewritten.

"The program uses a simple genetic algorithm to evolve random two-wheeled
shapes into cars over generations. Loosely based on BoxCar2D, but written from
scratch, only using the same physics engine (box2d). seedrandom.js written by
David Bau. (thanks!)"

------
benjoffe
I've been iterating over sequential seeds looking for one that contains the
most downhill terrain, so far the best is: 24427169 - it descends very rapidly
in the later part of the track. I'll keep this running over night and post
results.

Edit: 71044092 beats that (declines 47 units in the distance of the track,
which is 220 units long).

~~~
fimoreth
I used your seed and my cars have fallen off the track...

~~~
benjoffe
Yeah after 220 platforms the terrain on all seeds ends, which is a shame.

~~~
kristianp
My best car seemed to get past 300 before the road ran out:
[http://imgur.com/f1Gr25d](http://imgur.com/f1Gr25d)

~~~
kristianp
Although I think this was because it fell off the edge and kept moving
forwards as it fell.

------
kayge
This is ridiculously entertaining, and bringing back some fond college lecture
memories. Feature request: Ability to hover over the "Top Scores" and see a
snapshot of what the Car looked like.

------
phaedryx
If this were a screensaver, I'd never get anything done.

------
dreen
This is great, desperately needs sounds! VROOOOOOM

~~~
harrylove
I am not ashamed to say I was adding dragster sounds, squealing tires,
grinding metal, crash sounds, and little driver sounds in my head. Those guys
were striving soooo hard to get up that hill. "Ooh ooh ooh, I can make it, I
can make it!"

There really is something to this that needs exploration as a multiplayer
game. The aleatoric quality makes it infinitely watchable for me.
GenetExcitebike.

~~~
saraid216
> There really is something to this that needs exploration as a multiplayer
> game. The aleatoric quality makes it infinitely watchable for me.

This quality?

[http://darthsanddroids.net/episodes/0038.html](http://darthsanddroids.net/episodes/0038.html)

~~~
harrylove
Yes, and specifically Roger Caillois's use of the term in Man, Play and
Games[1]. And I suppose if you want to be technical about it, this simulation
appears to have a little piece of each of his four categories of games, to
include agon, mimicry, and ilinx with the aforementioned alea.

[http://en.wikipedia.org/wiki/Man,_Play_and_Games](http://en.wikipedia.org/wiki/Man,_Play_and_Games)

~~~
saraid216
I was a little confused that you feel that chance isn't a strong enough factor
in multiplayer games. It's so widespread and pervasive that I'm willing to
"omnipresent" is only a minor exaggeration.

~~~
harrylove
I'm sorry. I did not mean to convey that multiplayer games have no elements of
chance, or alea. I was trying to say that I thought this simulation would
benefit from adding a multiplayer element to it. And there are probably many
implementations of multiplayer-ness that could be explored.

The "aleatoric" part was a separate observation about a quality of the
simulation that made it more enjoyable for me. And then upon further
reflection, it seemed to me that this simulation had (or could have) all the
elements of a game, as classified by Caillois.

------
balanceiskey15
Oh what I would give to pit my genetically-superior boxcar against a
challenger.

~~~
MDCore
Boxcar2d let you save the genome of the car. I spent months running multiple
instances, trying to develop a car to beat those tracks (and the others on the
forum).

This one has some amazing features. Hopefully Rafael will give us some way to
compete!

~~~
alan_cx
It says at the bottom: "Create new world with seed: The same seed always
creates the same track, so you can agree on a seed with your friends and
compete. :) "

Sadly, that is pretty much the only bit I understood, ish...

------
MichaelGG
This is fantastic. There should be a place to enter your own inputs though.
The point of genetic algorithms is to find solutions that you can't engineer
yourself, right? I'd like to try my hand against evolution.

------
c-oreills
Just burned a couple of hours of developer time as everyone crowded around my
monitor rooting for imaginary cars. Oops.

------
ancarda
The seed "HN" produces a fairly stable world (1 car makes it quite far).
Eventually crashes.

~~~
quote
Highscore 188.23, that wall at the end just proves too high..

~~~
brianpgordon
I got past that wall, but the track goes completely crazy after that and it's
impossible to proceed.

[http://i.imgur.com/KPfKdab.png](http://i.imgur.com/KPfKdab.png)

------
mck-
We need a high-scores page with levels :)

Level: marc - 172.68

~~~
kayge
Level: HN - 2667.94

Believe it or not, my cars evolved into "Flying Cars" (They start with one
wheel stuck in the terrain, moving slowly forward, then it releases and goes
flying over the track)

[http://imgur.com/n6g8VRH](http://imgur.com/n6g8VRH)

~~~
benjamincburns
Either there's a glitch in the game, or I'm calling JS console shenanigans.
The red line on the chart gives it away, as does the mini map since it draws
lazily. Playing the same level my top score is 221.12, and my mini map looks
the same as yours.

~~~
kayge
Nah, no shenanigans. It was definitely a glitch, but I'm not sure if I can
explain it much better. The "flying cars" start with one wheel on top of the
track, and one wheel below the track. As the wheels turn, it makes very
little/slow progress, but you can see the car sort of shaking/struggling to
release. That release eventually happens as the lower wheel gets to a point
where it can cross back to the top of the track, and that twisting motion
flings the car up and forward _very_ quickly. The cars never even see the
track again. I'm not sure what actually causes the car to stop... the replay
wasn't very interesting to watch after the initial 'launch', as it just spins
in whitespace for a little while and then eventually just stops spinning in an
upright position while travelling forward.

~~~
benjamincburns
Weird, but interesting bug. Have you reloaded it and ran it long enough to
determine if it's reproducible?

~~~
kayge
That was the longest run I've done, somewhere between 24 and 36 hours left
mostly untouched and forgotten on the settings you can see in the picture
(with Surprise! mode on to speed things up). Unfortunately I did mess with it
a couple times when I got bored with its progress, cranking up the Mutation
rate for a few runs to bring in some extra variety; so it would probably be
tricky to reproduce intentionally. I've got a new version up and running
again, since this one did eventually crash.

Definitely weird and interesting. The funny thing to me was that it is sort of
a "realistic" evolution, since flying cars could be an eventual next step for
real-life transportation. Although hopefully with a less violent launch system
:)

~~~
mck-
Kudos -- that's awesome :D

------
loupeabody
This is awesome! When a handful of cars actually make for a good race it's
especially mesmerizing.

I feel like it's only a matter of time before some startup implements a
genetic driven visualization of the data from their app. If the effect is as
compelling, I'd be staring at their marketing page for a long time.

~~~
agilebyte
How would you determine the fitness of a "visualization" programatically?

~~~
terabytest
Genetic A/B Testing!

~~~
randomsearch
Ha, you laugh, but human-in-the-loop evolutionary algorithms are well
established. And the research communities involved are now looking at
applications to cloud computing. So it's just a matter of time before this...
recombination.

------
emehrkay
This seed: "Enter sdfsdfs string" has an almost impossible hill at the end.
I've been watching for 20 mins

Edit: This app is very well put together. The "winner"(one that got the
furthest) of the previous round is up front for the next and I believes
becomes the zero car

~~~
vitomd
The road will be harder and harder in the end. The code said so: for(var k =
0; k < maxFloorTiles; k++) { last_tile = cw_createFloorTile(tile_position,
(Math.random() _3 - 1.5)_ 1.5*k/maxFloorTiles);

Last parameter is the angle

------
RoryH
This put a smile on my face. There's something nice and simple about it.

------
boneheadmed
It took only about 9 generations to the evolve the Tron lightcycle. Way too
cool. This is like the marble races down hotwheels tracks we used to do as
kids while recording the times, only way less work.

------
Kiro
I'm using 5% mutation rate and have 1 elite clone. I thought that meant that
the whole population would be based on the winner with a 5% mutation chance
(so all 19 are children of the winner). However, I have a track with an
"impossible" hill and every round there's one car that almost makes it over
but it's never that one which is blue next round.

How does this work exactly?

EDIT: It seems the one that almost made it was a replay ghost or something and
not part of the population. Still wondering if I understood it correct though.

~~~
meandthebean
I recommend a smaller mutation rate. You see the inheritance of the previous
winner a lot better.

------
sirsar
I'd like to also have an "intelligent design" button. You'd set the vertices
and radii and compete against the evolved cars.

------
whouweling
I've also experimented a bit with this type of simulation quite some time ago,
you can find the result here
[http://lifesoup.sourceforge.net/](http://lifesoup.sourceforge.net/)

This tries to simulate simple "swimmers" where the fastest survives and spawn
new entities with slight variations.

(Note: this is not my best code :-))

------
Kiro
Shouldn't 0% mutation rate and 1 elite clone mean that all cars in the next
generation will look the same?

~~~
bvdbijl
No, because it combines cars to generate new ones. Better performing cars have
a larger chance to become a 'parent'. You should check out the source, it's
suprisingly readable

------
lsjroberts
For anyone who is interested it is probably worth checking out this -
[http://www.rockpapershotgun.com/2013/06/24/darwinning-
specie...](http://www.rockpapershotgun.com/2013/06/24/darwinning-species-
artificial-life-real-evolution/)

------
Gravityloss
Speedup improvement should be possible by not actually evaluating the clones
as we already know their results - or maybe just show one as a placeholder.

At the moment, if you add "elite clones", the camera follows the stack (but
all are exactly on top of each other) and it's a bit slow.

------
Houshalter
This is very fun, I love playing around with genetic algorithms and watching
them evolve. How exactly does the simulation work? Does it stop after a
certain amount of time, or do they burn fuel or something? Are they selected
for distance, or how long they survive, or what?

~~~
pests
I can't answer all the questions but it seems that the current generation is
tested until it can no longer make progress for a certain amount of time
(displayed as the bar next to its number decreasing, only to be refilled when
exceeding its current _maximum_ distance.)

------
guiambros
What is equally amazing is that the author is a world yo-yo champion, and
truly a yo-yo ninja:
[http://www.youtube.com/watch?v=Y5DeyIScwzg](http://www.youtube.com/watch?v=Y5DeyIScwzg)

That seems his past time, when not coding genetic algorithms...

------
dorkrawk
For those of you interested in GAs, I built a small Ruby gem to make building
genetic algorithms a little easier:
[https://github.com/dorkrawk/darwinning](https://github.com/dorkrawk/darwinning)

------
vitomd
That's my favourite genetic algorithm page , also worth check is this
[http://boxcar2d.com/index.html](http://boxcar2d.com/index.html) where you can
create your car and see the best created.

------
ChuckMcM
This was a lot of fun. A suggestion for improvement might be to weight where
the changes can come (so more or less likely to change wheelbase, or more or
less likely to change height, etc) But overall very nicely done.

------
Systemic33
Let's compare results/stats on the map "Hacker News"

~~~
Fuzzwah
That seed has an amazingly difficult part at around 156

~~~
Fuzzwah
I switched to "Hacker News Cars" and my master race of fishmobiles are now at:
#1: 183.44 d:178.09 h:-5.26/2.87m (gen 22)

There is an epic hill at 180..... Will give it another 10 generations and see
what they can do.

~~~
ajays
That was a tough one. Finally, at gen 669, one of the cars managed to jump it.

#1: 200.72 d:195.95 h:-5.38/6.55m (gen 669)

------
lettergram
Hmmm mine just grew into giant two wheels essentially. Started with high
mutation, then when I saw one reach about 160 put it to 3% mutations with 5
clones and slowly increasing every time

------
jamesjporter
Awesome! A really cool version of this would let the user write their own
algorithm and then have users compete against each other for whose algorithm
can evolve the best car.

------
bcoates
World seed "schnoo" has a particularly tough hill from 125-145 that several
different models can almost but not quite overcome. Anyone able to get over
it?

~~~
ISL
Yes. Small body car, low density but large wheels.

    
    
      #1: 192.22 d:187.68 h:-0.61/17.32m (gen 4694)
      #2: 192.09 d:187.42 h:-0.75/17.78m (gen 7914)
      #3: 191.32 d:187.34 h:-0.75/18.05m (gen 7430)
      #4: 191.16 d:186.26 h:-0.75/16.91m (gen 7822)

------
DanBC
I freaking love this.

There didn't appear to be anyway to send a small donation to the creators.

People competing against each other on a variety of pre-made tracks would be
amazing.

------
seestheday
That worked surprisingly well on my blackberry z10.

------
davidw
It sort of reminds me of Dukes of Hazard. It seemed that they would _always_
go off a jump in the car chase scenes.

------
styts
Could you add a genome for "weight"? Some cars seem so light that they
overturn easily.

~~~
jeremyarussell
As mentioned already you mean gene, but yes you can and he does already with
the wheel density, giving the darker ones more mass than the lighter ones.

------
hcarvalhoalves
Cool. Now make a version with legs and you'll freak some people out.

------
MWil
I watched this shit for like 30 minutes

------
MWil
is there always a wall around 200?

------
anymane
This is a lot of fun to watch, great idea

------
tokipin
this is well done

------
MWil
vbbvyubeuyfvefeojfeiojf

at 200, there's a bloody wall!!!

------
MrBra
beautiful

------
MattiasE
Awesome!

------
tonetheman
holy batmobile.... awesome

------
chrisrickard
Fantastic!

------
cfontes
it's the 10th time this one pops up in HN.

------
thrownaway2424
Please stay on topic, by implementing a genetic Edward Snowden who runs as far
as possible from the NSA. This is HN, after all.

