How do I create a kinda 'genetic algorithm'

0 favourites
  • 9 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hi guys, I saw someting very interesting on Yt and i was thinking about C2 and if it's possible to create something similar to it.

    *I think it's a little hard, maybe impossible to make such an algorithm with C2, maybe just to clone the movements and to transfer them in a algorithm in C2.

    I would like to try to create one, maybe just a clone of it or something similary.

    ** Genetic Algorithm :

    1)

    Subscribe to Construct videos now

    2)

    I would like to make one like the first, more like a physics-based one, not like car, which looks easier.

    I will post here my creations, PM me if you have any ideas for it.

    Thank you

    https://en.wikipedia.org/wiki/Genetic_a ... ialization

    https://en.wikipedia.org/wiki/Evolved_antenna

    Subscribe to Construct videos now
    Subscribe to Construct videos now
  • Nothing is impossible. There isn't a built in way to change the collision shape at runtime though so that may be another issue to tackle. Even that isn't impossible. You could look at yann's polygon plugin or deal with a physics engine directly with JavaScript through the browser plugin. Although I admit the latter is hard to do.

  • If you eliminate some requirements of physics such as weight, and mass, it's not that hard to create your own version of it.

    The platform behavior for example.

    Start by teaching it, and yourself gravity.

  • R0J0hound

    I was thinking about Js, but unfortunately, since I'm a little young i didn't learned Java and I can't deal with it.

    newt

    I tried the version with the care and 4-5 'sensors' of collisions and it worked way better thank i expected, but on the phisics one, I don't know where to start, becouse as i saw, the shapes are kinda modelling to succed jumping, so it's fishy, maybe to hard for me.

    I will definitely try to make one.

  • The algorithm itself looks pretty simple. The hard part would be coming up with how to design the creature so it can do something interesting. One way that seems useful to me is to make one creature and make it player controlled. If you can get it to kind of do what you want you can then take that and come up with a way to automate it.

    With the physics one it looks like torque is being applied at the joints. I'm guessing its properties are when to apply the torque and the amount of torque to apply. That is probably per joint.

    The initial values for the properties would be some reasonable random value. Like if it takes 1 second before the ball hits the creature then for the time to apply torque a value of random(0, 2) could be reasonable.

    There are probably more complex ways to model the creature. Some ideas that comes to mind could be to only start the timer when the obstacle gets close, or somehow take into account the orientation of the creature. Giving the creature some sensory cues could be useful too.

    I think it basically amounts to a bunch of tinkering and creativity.

  • A nice challenge - thank you!

    this is my approach... (platformer behavior but can changed to physic behavior)

    This balls try to evaluate the perfect jump strength not to collide with the wafes.

    They do not calculate but set the jump strength related to their success.

    (no ball interaction so far).

    (each ball can have different start values)

    If you 'connect' the balls you get a more komplex looking object.

    demo

    http://www.gameus.de/c2/learnjump

    source

    http://www.gameus.de/c2/learnjump/lrn2jmp.capx

    the math of cause can be optimized to optimize the learning graph...

    with the 'perfect' math it will result in a type of swarm intelligence

  • mercuryus

    Nice one, I really liked it, I've tried 2 things, one with a car (which needs more work) and one with a 'phisics-worm',

    you have the projects below.

    I tried to make them more inteligent but I didn't had time, the one with the car I did it very interesting, adding some points to trace the first car, and the second car would go on these points but unfortunatelly i forgot to save.... so i let it unfinished <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad">

    PROJECTS BELOW

    R0J0hound

    I don't know nothing about joints in C2 but it sounds very interesting.

    https://drive.google.com/file/d/0B2orsd ... sp=sharing

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I don't think any of those are an application of the genetic algorithm. Mercuryus's example tweaks the jump as it goes but it's not following the algorithm. Radulepy's are more like ai examples.

    I tried my hand at the algorithm and came up with this:

    https://dl.dropboxusercontent.com/u/542 ... netic.capx

    It does this:

    1. simulates 100 objects moving with 5 seconds worth of random input

    2. scores them

    3. kills the lower 50

    4. creates 50 new objects by combining two of the survivors and adding some random mutation

    5. and finally repeat.

    It doesn't converge very fast but given enough time it will converge on the objects moving as far along the path as possible. I imagine the scoring could be improved to help it converge faster but I'm probably done with this.

  • R0J0hound

    Very nice concept, i like it.

    I read the code some times, but I didn't understant it's movement 100%.

    It's very interesting, but it takes looong way until it hits the third or second goal ( + 30 gen).

    Still awesome, Good Job !

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)