Platformer Learning A.I. 

Instructions: This is a simple A.I. I made as a test to see if it was possible. \nHow it works: \n1. Each clone creates a random string of numbers 0-3 that is as long as you tell it at the beginning\n2. The main clone tells them to start moving\n3. Instead of using the arrow keys like in a normal platformer, each clone runs through their number string, jumping if the current number is a 1, moving right if it's a 2, and so on.\n4. Throughout the run, each clone updates it's score based on how far across the screen it is and how long it took to get to that point. \n5. At the end the main clone figures out what the best score is and then checks if it is higher than the best run for all generations. If it is that is the new base for all the new clones\n6. The new clones now have a string of numbers that is just a version of the best run with some modifications. \n7. This cycle repeats over and over until the A.I. starts to get further and further along the level.

@Stage\n\n@Player 1\n\nwhen flag clicked\ngo to x: (0) y: (0)\nset [best run code v] to [0]\nset [best run v] to [-1000]\nset [generation v] to [1]\ndelete all of [options v]\ndelete all of [distances v]\nask [Players\(10 works best\)] and wait\nset [players v] to (answer)\nset [moves v] to [10]\nset [personal score v] to [-1000]\nforever\n    change [moves v] by (10)\n    repeat (5)\n        set [aa v] to [0]\n        show\n        set [void v] to [0]\n        set [personal best v] to [-1000]\n        reset timer\n        plan (moves)\n        clone ((players) - (1))\n        go to x: (-200) y: (-100)\n        set size to (50) %\n        set [yv v] to [0]\n        set [xv v] to [0]\n        set [tick v] to [1]\n        broadcast (reset laser v)\n        repeat (moves)\n            change [yv v] by (-0.5)\n            if <(letter (tick) of (random test movement)) = [3]> then\n                switch costume to (costume1 v)\n                change [xv v] by (0.7)\n            end\n            if <(letter (tick) of (random test movement)) = [2]> then\n                switch costume to (costume2 v)\n                change [xv v] by (-0.7)\n            end\n            set [xv v] to ((Xv) * (0.9))\n            change x by (Xv)\n            if <touching (spri3te3 v)?> then\n                change y by (1)\n                if <touching (spri3te3 v)?> then\n                    change y by (1)\n                    if <touching (spri3te3 v)?> then\n                        change y by (1)\n                        if <touching (spri3te3 v)?> then\n                            change y by (1)\n                            if <touching (spri3te3 v)?> then\n                                change y by (1)\n                                if <touching (spri3te3 v)?> then\n                                    change x by ((Xv) * (-1))\n                                    change x by (-1)\n                                    change y by (-5)\n                                    if <touching (null v)?> then\n                                        change x by (10)\n                                    end\n                                    change x by (1)\n                                    if <(letter (tick) of (random test movement)) = [1]> then\n                                        if <not <touching color (#00ff55)?>> then\n                                            if <(Xv) > [0]> then\n                                                set [xv v] to [-8]\n                                            else\n                                                set [xv v] to [8]\n                                            end\n                                            set [yv v] to [10]\n                                        end\n                                    else\n                                        set [xv v] to [0]\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n            change y by (Yv)\n            if <touching (spri3te3 v)?> then\n                change y by ((Yv) * (-1))\n                set [yv v] to [0]\n            end\n            change y by (-1)\n            if <touching (null v)?> then\n                change x by (10)\n            end\n            if <touching (spri3te3 v)?> then\n                if <(letter (tick) of (random test movement)) = [1]> then\n                    if <not <touching color (#00ff55)?>> then\n                        set [yv v] to [10]\n                    end\n                end\n            end\n            if <touching color (#2aff00)?> then\n                go to x: (-188) y: (-146)\n                set [xv v] to [0]\n                set [yv v] to [0]\n                point in direction (90)\n            end\n            if <touching color (#003fff)?> then\n                set [yv v] to [15]\n            end\n            change y by (1)\n            set [personal score v] to (x position)\n            if <(personal score) > (personal best)> then\n                set [personal best v] to (personal score)\n            end\n            if <(x position) < (personal best)> then\n                change [aa v] by (0.33)\n            end\n            if <touching color (#ff0000)?> then\n                set [void v] to [1]\n                hide\n            end\n            change [tick v] by (1)\n        end\n        if <(void) = [0]> then\n            replace item (id) of [distances v] with (((personal best) - (aa)) - (timer))\n            replace item (id) of [options v] with (random test movement)\n        end\n        set [check v] to [1]\n        repeat (players)\n            if <(item (check) of [distances v]) > (best run)> then\n                set [best run v] to (item (check) of [distances v])\n                set [best run code v] to (item (check) of [options v])\n            end\n            change [check v] by (1)\n        end\n        change [generation v] by (1)\n    end\nend\n\nwhen I start as a clone\nset [personal best v] to [-1000]\nset [personal score v] to [-1000]\nset [aa v] to [0]\nplan (moves)\ngo to x: (-200) y: (-100)\nset size to (50) %\nset [yv v] to [0]\nset [xv v] to [0]\nrepeat (moves)\n    change [yv v] by (-0.5)\n    if <(letter (tick) of (random test movement)) = [3]> then\n        switch costume to (costume1 v)\n        change [xv v] by (0.7)\n    end\n    if <(letter (tick) of (random test movement)) = [2]> then\n        switch costume to (costume2 v)\n        change [xv v] by (-0.7)\n    end\n    set [xv v] to ((Xv) * (0.9))\n    change x by (Xv)\n    if <touching (spri3te3 v)?> then\n        change y by (1)\n        if <touching (spri3te3 v)?> then\n            change y by (1)\n            if <touching (spri3te3 v)?> then\n                change y by (1)\n                if <touching (spri3te3 v)?> then\n                    change y by (1)\n                    if <touching (spri3te3 v)?> then\n                        change y by (1)\n                        if <touching (spri3te3 v)?> then\n                            change x by ((Xv) * (-1))\n                            change x by (-1)\n                            change y by (-5)\n                            if <touching (null v)?> then\n                                change x by (10)\n                            end\n                            change x by (1)\n                            if <(letter (tick) of (random test movement)) = [1]> then\n                                if <not <touching color (#00ff55)?>> then\n                                    if <(Xv) > [0]> then\n                                        set [xv v] to [-8]\n                                    else\n                                        set [xv v] to [8]\n                                    end\n                                    set [yv v] to [10]\n                                end\n                            else\n                                set [xv v] to [0]\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\n    change y by (Yv)\n    if <touching (spri3te3 v)?> then\n        change y by ((Yv) * (-1))\n        set [yv v] to [0]\n    end\n    change y by (-1)\n    if <touching (null v)?> then\n        change x by (10)\n    end\n    if <touching (spri3te3 v)?> then\n        if <(letter (tick) of (random test movement)) = [1]> then\n            if <not <touching color (#00ff55)?>> then\n                set [yv v] to [10]\n            end\n        end\n    end\n    if <touching color (#2aff00)?> then\n        go to x: (-188) y: (-146)\n        set [xv v] to [0]\n        set [yv v] to [0]\n        point in direction (90)\n    end\n    if <touching color (#ff0000)?> then\n        delete this clone\n    end\n    change y by (1)\n    set [personal score v] to (x position)\n    if <(personal score) > (personal best)> then\n        set [personal best v] to (personal score)\n    end\n    if <(x position) < (personal best)> then\n        change [aa v] by (0.33)\n    end\nend\nreplace item (id) of [distances v] with (((personal best) - (timer)) - (aa))\nreplace item (id) of [options v] with (random test movement)\ndelete this clone\n\ndefine clone (#)\nset [id v] to [1]\nrepeat (#)\n    create clone of (_myself_ v)\n    change [id v] by (1)\n    add [] to [options v]\n    add [] to [distances v]\nend\nadd [] to [options v]\nadd [] to [distances v]\n\ndefine plan (lol)\nif <(Generation) > [1]> then\n    set [ahhhhhhh v] to [1]\n    set [random test movement v] to (lol)\n    repeat ((moves) - (25))\n        set [random test movement v] to (join (random test movement) (letter (ahhhhhhh) of (best run code)))\n        change [ahhhhhhh v] by (1)\n    end\n    repeat ((moves) - ((moves) - (25)))\n        if <(pick random (1) to (5)) = [4]> then\n            set [random test movement v] to (join (random test movement) (pick random (0) to (3)))\n        else\n            if <not <(letter (ahhhhhhh) of (best run code)) = []>> then\n                set [random test movement v] to (join (random test movement) (letter (ahhhhhhh) of (best run code)))\n            else\n                set [random test movement v] to (join (random test movement) (pick random (0) to (3)))\n            end\n        end\n        change [ahhhhhhh v] by (1)\n    end\nelse\n    set [random test movement v] to []\n    repeat (lol)\n        set [random test movement v] to (join (random test movement) (pick random (0) to (3)))\n    end\nend\n\nreplace item (id) of [distances v] with (personal best)\nreplace item (id) of [options v] with (random test movement)\n\nwhen [s v] key pressed\ndelete all of [saves v]\nadd (best run code) to [saves v]\n\nadd (best run code) to [saves v]\n\nset [generation v] to [350]\nset [best run code v] to (item (7) of [saves v])\nset [best run v] to [232]\n\nif <(x position) < (personal best)> then\n    change [aa v] by (1)\nend\n\n@Spri3te3\n\nwhen flag clicked\ngo to x: (0) y: (0)\nset [level v] to (pick random (1) to (5))\nswitch costume to (level)\n\n@Sprite1\n\nwhen I receive [reset laser v]\nset y to (0)\nset x to (-240)\nrepeat ((Generation) * (20))\n    change x by (1)\n    wait ((1) / ((Generation) * (7))) seconds\nend\n\n@Player 2\n\nwhen [space v] key pressed\nshow\nforever\n    set [tick v] to [1]\n    go to x: (-148) y: (-33)\n    set size to (50) %\n    set [yv v] to [0]\n    set [xv v] to [0]\n    repeat (answer)\n        change [yv v] by (-0.5)\n        if <(letter (tick) of (best run code)) = [3]> then\n            switch costume to (costume1 v)\n            change [xv v] by (0.7)\n        end\n        if <(letter (tick) of (best run code)) = [2]> then\n            switch costume to (costume2 v)\n            change [xv v] by (-0.7)\n        end\n        set [xv v] to ((Xv) * (0.9))\n        change x by (Xv)\n        if <touching (spri3te3 v)?> then\n            change y by (1)\n            if <touching (spri3te3 v)?> then\n                change y by (1)\n                if <touching (spri3te3 v)?> then\n                    change y by (1)\n                    if <touching (spri3te3 v)?> then\n                        change y by (1)\n                        if <touching (spri3te3 v)?> then\n                            change y by (1)\n                            if <touching (spri3te3 v)?> then\n                                change x by ((Xv) * (-1))\n                                change x by (-1)\n                                change y by (-5)\n                                if <touching (null v)?> then\n                                    change x by (10)\n                                end\n                                change x by (1)\n                                if <(letter (tick) of (best run code)) = [1]> then\n                                    if <not <touching color (#00ff55)?>> then\n                                        if <(Xv) > [0]> then\n                                            set [xv v] to [-8]\n                                        else\n                                            set [xv v] to [8]\n                                        end\n                                        set [yv v] to [10]\n                                    end\n                                else\n                                    set [xv v] to [0]\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n        change y by (Yv)\n        if <touching (spri3te3 v)?> then\n            change y by ((Yv) * (-1))\n            set [yv v] to [0]\n        end\n        change y by (-1)\n        if <touching (null v)?> then\n            change x by (10)\n        end\n        if <touching (spri3te3 v)?> then\n            if <(letter (tick) of (best run code)) = [1]> then\n                if <not <touching color (#00ff55)?>> then\n                    set [yv v] to [10]\n                end\n            end\n        end\n        if <touching color (#2aff00)?> then\n            go to x: (-188) y: (-146)\n            set [xv v] to [0]\n            set [yv v] to [0]\n            point in direction (90)\n        end\n        if <touching color (#003fff)?> then\n            set [yv v] to [15]\n        end\n        change y by (1)\n        change [tick v] by (1)\n    end\nend\n\nwhen flag clicked\nhide\n\n@Spri3te2\n\nwhen flag clicked\ngo to [back v] layer\ngo to x: (0) y: (0)\nwait (0.5) seconds\nswitch costume to (level)\n\n