Genetic Algorithm used to build a car with the Box2D physics library.

Discussion in 'Off Topic' started by Seba, Jan 25, 2011.

  1. Seba

    aa Seba DR. BIG FUCKER, PHD

    Messages:
    2,363
    Positive Ratings:
    2,365
    • Thanks Thanks x 1
  2. Jakkarra

    Jakkarra L4: Comfortable Member

    Messages:
    167
    Positive Ratings:
    36
    This is actually pretty cool.
     
  3. Trotim

    aa Trotim

    Messages:
    1,180
    Positive Ratings:
    995
    Why does it always reset so quickly? I've seen many versions that could've gone on a lot longer but were simply reset due to a slight bump.
     
  4. nik

    nik L12: Fabulous Member

    Messages:
    987
    Positive Ratings:
    246
    holy crap.
     
  5. Jakkarra

    Jakkarra L4: Comfortable Member

    Messages:
    167
    Positive Ratings:
    36
    It seems to reset when the thing stops moving entirely for a moment.
     
  6. Zhan

    Zhan L5: Dapper Member

    Messages:
    208
    Positive Ratings:
    114
    This is really neat, thanks for sharing the link. Did you write this yourself?
     
  7. Seba

    aa Seba DR. BIG FUCKER, PHD

    Messages:
    2,363
    Positive Ratings:
    2,365
    Heh, I did not. Someone in chat posted it an hour or two ago.
     
  8. nik

    nik L12: Fabulous Member

    Messages:
    987
    Positive Ratings:
    246
    so you're stealing their thunder?
     
  9. The Political Gamer

    aa The Political Gamer

    Messages:
    4,468
    Positive Ratings:
    1,682
  10. Exist

    Exist L6: Sharp Member

    Messages:
    306
    Positive Ratings:
    112
    Really erks me, flash designer with an iPhone, tricking blows I can't view my own animations with out converting them. Anyway, box2d is an easy library to work with in flash. Adobe created a program that converts the source code of a library (I think it supports C++, hAxE and someother can't remember.) to AS3. Box2D has a component based physics engine for the FlashIDE. This means, you can create a shape, define it as a component, pick it's properties, and it will automatically obtain physic attributes. You can also hinge oobjects together making it easy to create cars and such.

    The game Fantastic Contraption uses Box2D, allowing for the very flexible gameplay experience.
     
  11. Dr. ROCKZO

    Dr. ROCKZO L8: Fancy Shmancy Member

    Messages:
    580
    Positive Ratings:
    159
    These are what mine are looking like, and they work quite well, the spike keeps them from wheelie-ing, but jagged areas sort of stump them. I'll be interested to see what it develops to conquer that. I love this game.

    [​IMG]

    EDIT: For a few generations it started to develop an annoying habit of getting stuck on the back wheel and stumbling through, it still worked but could have been so much faster. I guess it worked that out, because it's back to normal Dump Trucks now.

    It'd be interesting to have the option to design our first car, and let it evolve from there, to see if evolution could make any improvements on what we decided to be perfection.
     
  12. Ravidge

    aa Ravidge Grand Vizier

    Messages:
    1,544
    Positive Ratings:
    2,493
    I left it running while I was in school. It's on generation 64 and has not made any progress since gen 4.
    It's still getting stuck in the same place. And anything it tries that could potentially get past that gets stuck on some earlier obstacle or flips over.

    The area of doom:
    [​IMG]
     
  13. Zhan

    Zhan L5: Dapper Member

    Messages:
    208
    Positive Ratings:
    114
    I guess Ravidge's have just been underachieving, several of mine from each generation are hitting the 220-230 range. Has anyone had one that passed 230 yet?

    [​IMG]

    One thing that occured to me is that perhaps the problem with the selective pressures in this simulation that cause a species of cars to get stuck at one point and never evolve past it is that the track is the same every time. With a track that's randomized, the evolution of the cars would probably be more robust: able to handle a wider range of terrain instead of just selecting for cars that all fail at one point in the track. The downside with a randomized track would be, of course, that any significant evolution would take much longer since a good mutation that increases fitness would only produce a better result on some tracks.
     
  14. Mick-a-nator

    aa Mick-a-nator

    Messages:
    640
    Positive Ratings:
    314
    Awesome!
    Nice to see something come out of this branch of computer science again. I remember seeing a program evolve a human walking. Now that was freakishly cool.
    I will try to find that again actually...
     
  15. A Boojum Snark

    aa A Boojum Snark Toraipoddodezain Mazahabado

    Messages:
    4,769
    Positive Ratings:
    5,527
    The track just needs better generation code. Having it be the same each run would be fine if it didn't have segments that are virtually impossible to pass with the available components. My track (I'm not sure if the track is the same all the time, or generated new at each initialization of the app) had one point at 205 that was literally a /\/\ shape with all four angles at about 50 degrees, immediately after a big hill. So everything would either crash headfirst into the slope because it went fast down the hill, or get hung up on the peak when the first wheel passed.
     
  16. drp

    aa drp

    Messages:
    2,251
    Positive Ratings:
    2,551
    leave it running. it will learn to fly to get passed those peaks
     
    • Thanks Thanks x 1
  17. Whated

    Whated L2: Junior Member

    Messages:
    89
    Positive Ratings:
    20
    Excuse me what does the mutation rate do? :S
     
  18. Bermuda Cake

    Bermuda Cake L9: Fashionable Member

    Messages:
    679
    Positive Ratings:
    192
    how much variation there will be between cars - it's the same with genetic mutation in living things
    Didn't realise I wasn't controlling the car until generation 3 :/
     
  19. Whated

    Whated L2: Junior Member

    Messages:
    89
    Positive Ratings:
    20
    Lol? You can control the car? how! :D
     
  20. Bermuda Cake

    Bermuda Cake L9: Fashionable Member

    Messages:
    679
    Positive Ratings:
    192
    no, I thought I was :/