The World of Bots and Genetic Algorithms
About half a year ago, I stumbled upon a video where someone created artificial intelligence. This video completely changed my understanding of what can be achieved with AI.
Recently, I fell ill and decided to create something similar. So, I made little blue bots that will survive on their own in the world. The bots have a brain—a micro-program that serves as the bot's genome, which will be created and evolve on its own. The brain consists of 64 memory cells (numbers). Each number is a command.
Commands:
- move,
- turn,
- grab food or convert poison into food,
- check what’s in the neighboring cell,
- unconditional jump,
- added long-range vision (to check a cell farther than the neighboring ones).
In the beginning, all cells are filled with random numbers, then the bots are placed in the world, where they can perform one movement command and up to 10 other commands per turn.
If a bot steps on food, it gains 10 health points; if it steps on poison, it dies. Each turn, the bot loses 1 health point. When the health drops to 0, the bot dies.
After each simulation of the world’s life, the new generation is composed of only the best bots from the previous simulation, and mutations are added (random changes to a few memory cells).
As a result, the bots start evolving, and with each generation, they become smarter.
If you let a few generations (a few thousand) pass, the bots become quite capable of surviving. For fast simulation of many generations, press the "Fast by Generations" button. You can then switch back to "Slow by Step."
Overall, the idea was inspired by the video and developed a bit further. The code is written in TypeScript/JS and posted on GitHub.
Demo link: SamProfAI Demo