Phone AI (no libraries) · Part 4 · HTML + JavaScript
My phone AI taught ITSELF to dodgePRO
Part 4: 50 players with their own tiny brains. No teacher, no data: the 5 best survive each round and the rest are mutated copies. Watch each generation last longer.
<meta name="viewport" content="width=device-width, user-scalable=no">
<style>body { margin: 0; background: #0b0f17; }</style>
<canvas id="c"></canvas>
<script>
// a fixed seed: the same evolution every time you run it (change 51 to watch a different one)
let sd = 51;
Math.random = () => (sd = (sd * 16807) % 2147483647) / 2147483647;
const c = document.getElementById("c");
const g = c.getContext("2d");
const S = innerWidth, D = Math.min(devicePixelRatio, 1.5);
c.width = c.height = S * D;
c.style.width = S + "px";
g.scale(D, D);
// 50 players. Each one has its OWN tiny brain.
const N = 50, H = 6, ROCKS = 3, IN = 5;
+ 97 more lines in the app (Pro)
Open code AI4 in Pocket Compiler
Download the Pocket Compiler app — free
No app yet? Install it, then open the app and type the code AI4 in Code Library.