Show HN: Procedurally Generated Artificial Life
In brief: this is a 2d genetic algorithm &#x2F; alife simulation that runs in a browser.<p>note: I have mostly tested it with Chrome and briefly with Firefox so there might be problems with other browsers although the code is plain javascript without  anything too special.<p>The colored pixels&#x2F;boxes are the &quot;creatures&quot; which are basically virtual CPUs that run code in a custom assembler-like programming language. I just did an improvement so now the code is a tree-like structure.<p>The code evolves with mutations, there are various different mutations that modify the structure.<p>The green dots are &quot;food&quot; that the creatures can and must eat to survive. The food is distributed in patterns that vary over time to make the landscape &quot;interesting&quot; and to facilitate improvement in the creatures.<p>Each food gives X amount of energy, when the energy runs out or the creature gets too old (currently at 2000 command executions) it dies.<p>Running in a browser opens a lot of possibilities - for example I&#x27;m planning to set up a server to connect the world on different computers. I think I&#x27;ll set up a possibility to open portals between worlds or something similar - I don&#x27;t have the details though in detail yet.<p>Instructions for the buttons:<p><pre><code>    Brush - this defines what mouse does. There are different modes 
        Inspect - shows the creature you click
        Food - plots food
        Create - creates new random creatures
        Kill - kills creatures
        Mutate - mutates creatures that brush touches
        kill-and-create - first kills creatures under the brush, then generates random new creatures

    Redraw every: After how many rounds is the screen redrawn. Faster redraw rate slows down the system. Good compromise is 100 but if you want to really see what&#x27;s happening, you might want to use 5 or 10 rounds.
        Now button redraws the screen immediately.

    Mutation %  - when the creature multiplies, at what % is the creature mutated 
        Mutation deletes command, creates command, switches command to new random command or mutates a parameter.

    Food model selector: 
        Random areas - random areas that grow food at different intervals and formations.
        Islands - 9 islands containing food spread across the screen. No food elsewhere
        Full map - randomized fixed size areas of food.
        Isolated grid - similar to islands, lots of non-connected boxes of food that grow on different rates.

    Number after food model - how often is the food model changed. This randomizes food areas based on selected model.
        Now button - randomizes the food areas when clicked

    Buttons:
        Pause - pauses the simulation
        + creates 100 creaturs
        - kills approximately 10% of creatures in random
        M mutates approximately 10% of creatures in random
        Save - saves current world (locally to browser)
        Load - loads the saved world (locally from browser)
</code></pre>
Here is an example of a program from a live session:<p><pre><code>    if r0 &gt; r1
      if r0 &lt; r2
        set_reg r6 = 86
        copy_reg r2 = r1
        subtract_reg ro -= r5
        inc_reg r0 += r5
      push_stack 2
      if r0 &gt; r8
        if r0 &gt; r7
          set_signal 1 r1
          wait
          get_creautre_reg r0 =&gt; r0
          attack
        push_stack 4
        copy_reg r3 = r0
        if r0 &gt; r4
          get_energy r0
        get_creautre_reg r5 =&gt; r0
        attack
      wait
    multiply
    get_signal 0 r0
    turn_left
    get_signal 0 r0
    eat
</code></pre>
I do have plans to publish the details of the (experimental) programming language and maybe let the users to create programs. I think that would be very interesting.