Город МОСКОВСКИЙ
00:15:39

Self-replicating Brainfuck programs

Аватар
Кодовое Перо
Просмотры:
30
Дата загрузки:
02.12.2023 22:01
Длительность:
00:15:39
Категория:
Технологии и интернет

Описание

In general this is just a Brainfuck Virtual Machines. But there are some differences to Urban Müller's Brainfuck:
* Von-Neumann architecture: Code and Data reside in same memory
* Multi-threading: This Brainfuck VM supports multi-threading (command 'Y' forks)
* Stack: I've added commands to push ('^') and pop ('V') data from a stack (command '$' sets stack pointer to current data pointer)
* Memory is simulated to be endless in both directions. Therefore there is a command to terminate a thread ('*')
* I've also added statistical errors (mutations):
1) Cosmic-ray mutation: Random bits in memory are mutated
2) Instruction error: Some instructions are ignored
(but errors/mutations are of course very rare)
* Command ',' doesn't read from keyboard, but from a random number generator
* Also note that all memory is initialized randomly (except for locations where a program is loaded)

Then I wrote some basic programs, which were able to reproduce and started the Virtual Machines. It's quite interesting to see how programs compete while overwriting each other. The random mutations then are a motor for evolution and some different programs evolve. Sometimes two programs reproduce to the same location and therefore do secual reproduction. If the resulting program is able to reproduce itself, a new species evolved, and I viewed a lot of newly-evolved species.

Source code is now available at GitHub:
https://github.com/jgraef/replifuck

Рекомендуемые видео