{"id":15519713,"url":"https://github.com/mertyildiran/ldca","last_synced_at":"2025-04-23T03:51:46.711Z","repository":{"id":136533850,"uuid":"304760317","full_name":"mertyildiran/ldca","owner":"mertyildiran","description":"Self-replicating, self-modifying Assembly program that can evolve into every possible computer program in the universe (EXPERIMENTAL)","archived":false,"fork":false,"pushed_at":"2020-11-23T00:18:17.000Z","size":108,"stargazers_count":59,"open_issues_count":0,"forks_count":5,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-17T19:17:36.745Z","etag":null,"topics":["assembly","evolutionary-algorithms","experimental","quine","self-modifying","self-replicating"],"latest_commit_sha":null,"homepage":"","language":"Assembly","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mertyildiran.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-16T23:37:22.000Z","updated_at":"2025-03-26T15:28:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"752cb0a8-dffc-4a89-864d-bb29aea6922d","html_url":"https://github.com/mertyildiran/ldca","commit_stats":{"total_commits":38,"total_committers":2,"mean_commits":19.0,"dds":"0.10526315789473684","last_synced_commit":"4e6bd64bfbd67a502e1109ef6686d3e3d2c172d0"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mertyildiran%2Fldca","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mertyildiran%2Fldca/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mertyildiran%2Fldca/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mertyildiran%2Fldca/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mertyildiran","download_url":"https://codeload.github.com/mertyildiran/ldca/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250366685,"owners_count":21418768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assembly","evolutionary-algorithms","experimental","quine","self-modifying","self-replicating"],"created_at":"2024-10-02T10:22:30.039Z","updated_at":"2025-04-23T03:51:46.693Z","avatar_url":"https://github.com/mertyildiran.png","language":"Assembly","readme":"# Last Digital Common Ancestor (LDCA)\n\nSelf-replicating, self-modifying Assembly program that can evolve into every possible computer program in the universe.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://i.ibb.co/VpYDzYK/demo.gif\" alt=\"LDCA\" height=\"800px\"/\u003e\n\u003c/p\u003e\n\n[NASM](https://www.nasm.us/) is required to compile the Assembly program.\n\n## Compiling \u0026 Running\n\n\u003e **CAUTION:** Since this program executes random CPU instructions, it might run potentialy harmful machine code of any kind. For example: You can accidentally delete a file from your disk or change some configuration in your system. Although it's statistically insignificant, you should still run it in an isolated environment. Also read the NOTICE below.\n\n\u003e **NOTICE:** Program execution (that executes random CPU instructions) is disabled temporarily. To re-enable it, remove `;` before the `call    program` occurences in `ldca.asm` file.\n\nGo into the directory that matches your operating system and CPU architecture combination. For example: `cd linux_x86`\n\nRun: `make`\n\nThe binary should be ready on `outs/0000000000000000000000000000000000000000000000000`\n\nGo into the `outs/` directory and run it:\n\n```bash\ncd outs/\n./0000000000000000000000000000000000000000000000000\ncd ..\n```\n\nNow you should be seeing these three binaries:\n\n```bash\n$ ls outs/\n0000000000000000000000000000000000000000000000000\n0000000000000000000000000000000000000000000000001\n0000000000000000000000000000000000000000000000002\n```\n\nthat means it's replicated and created 2 offsprings.\n\nNow you can run these commands sequentially to achieve the results shown in the animation at the top:\n\n```bash\nclear\nmake clean\nmake\nmake strace\nmake diff\n```\n\nor simply run:\n\n```bash\n./dev.sh\n```\n\n## Development\n\nFor development purposes, it's better to run the program for a brief amount of time like this:\n\n```bash\nclear\nmake clean\nmake\ntimeout 0.2 make strace\nmake diff\n```\n\nso that it will only generate a few hundred programs.\n\n### Where are the descendants?\n\nThe descendants are in the same directory that you run the initial program `0000000000000000000000000000000000000000000000000`.\nDon't try to run `ls` to see the list of files if you run the program for a few minutes. Use `ls --sort=none` instead.\n\n### How do I remove these generated programs?\n\nDo not try to run `rm *` inside the `outs/` because `rm` cannot handle that amount files.\nGo into parent directory `cd ..` and use `rm -f outs/` instead.\n\n### Why is it called Last Digital Common Ancestor?\n\nBecause it's the digital version of [Last Universal Common Ancestor](https://en.wikipedia.org/wiki/Last_universal_common_ancestor).\nIf you look at it from a philosophical point of view, LDCA is actually a descendant of LUCA.\n\n## Algorithm\n\nThe Assembly program first executes the subroutine named `program` which is the section that actually evolves.\nThen the program replicates itself. While replicating, with 50% probability one of the random mutations, that are\nlisted below, happens:\n\n- with 80% probability replace a randomly chosen byte in the `program` section with a random byte.\n- with 5% probability shrink the `program` section randomly by a factor of 1 byte to `program` section's size.\n- with 15% probability grow the `program` section randomly by a factor of 1 byte to 256 bytes and fill it with random bytes.\n\nReplication creates a new binary using system calls by copying the memory region which the program's itself loaded into.\nThen executes the newly created binary by forking using system calls. Replication happens two times for each successful\nprogram execution. So the number of processes increases exponentially.\n\nPrograms that created after a random mutation might fail to reach to `replicate` subroutine. Such programs cannot\nproduce its offsprings.\n\nTo be able to fully understand the algorithm you should go through the lines of [`ldca.asm`](/linux_x86/ldca.asm)\nAssembly code and read the comments.\n\n## Constants\n\nThere are some constants that hard-coded into the Assembly program which are open to optimization:\n\n- Filename length: `49`\n- Body of the subroutine named `program`\n- 50% evolution rate: `rndNum  0, 1`\n- Grow size: Between 1 byte and 256 bytes (`rndNum  1, 256`)\n- 80% random byte mutation chance: `cmp     eax, 80`\n- 5% shrink mutation chance: `cmp     eax, 85`\n- 15% grow mutation chance: `100 - 85`\n\n## License\n\n**Last Digital Common Ancestor** is licensed under the [**GNU General Public License v3.0**](/LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmertyildiran%2Fldca","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmertyildiran%2Fldca","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmertyildiran%2Fldca/lists"}