{"id":15648148,"url":"https://github.com/noracodes/evolve_bf","last_synced_at":"2025-06-20T04:07:00.172Z","repository":{"id":84925688,"uuid":"46203999","full_name":"NoraCodes/evolve_bf","owner":"NoraCodes","description":"A Python module for evolving and evaluating BF code.","archived":false,"fork":false,"pushed_at":"2016-03-26T16:27:50.000Z","size":29,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T23:28:53.269Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NoraCodes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2015-11-15T04:17:56.000Z","updated_at":"2017-03-16T18:20:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"194c34c3-f397-4bae-bd1e-1f6955caa393","html_url":"https://github.com/NoraCodes/evolve_bf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/NoraCodes/evolve_bf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoraCodes%2Fevolve_bf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoraCodes%2Fevolve_bf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoraCodes%2Fevolve_bf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoraCodes%2Fevolve_bf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NoraCodes","download_url":"https://codeload.github.com/NoraCodes/evolve_bf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoraCodes%2Fevolve_bf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260878331,"owners_count":23075959,"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":[],"created_at":"2024-10-03T12:23:44.973Z","updated_at":"2025-06-20T04:06:55.154Z","avatar_url":"https://github.com/NoraCodes.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# evolve_bf\nA program for evolving BF code given a list of inputs and their corresponding outputs.\n\n### Usage\n\nIn the simplest form, we can evolve a Hello, world! program with one line (not counting imports).\n\n```\nfrom evolve_bf.evolve import supervised_evolve\n\n# Input: none\n# Output: Hello, world!\nsupervised_evolve([''], ['Hello, world!'])\n```\n\nOr, for somewhat more advanced usage:\n\n```\nfrom evolve_bf.evolve import *\n\n# Set verbose mode, but otherwise use the defaults\nevolve_options = default_evolve_options._replace(verbose=True)\n\n# Define a spec for adding A to an input string\ninputs  = ['',  'Hello, world!',  'Foo']\noutputs = ['A', 'Hello, world!A', 'FooA']\n\nsupervised_evolve(inputs, outputs, evolve_options)\n```\nIn the course of 26 generations, this created the program:\n```\n+[,[.,],+++++\u003c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.-,\n```\nWhich is the correct way to write the program, with some minor cruft around the edges.\n### Options\n\nAll options are carried in namedtuples.\n\n```\n# in evolve_bf.evolve\ndefault_evolve_options = EvolveOptions(\n                                       cull_ratio = 0.5,  # Out of 1, how many of the weakest per generation to kill.\n                                       population_size = 1000,  # The size of the population. Enforced after crossing.\n                                       initial_program_size = 8,  # The length of the programs created for the initial population.\n                                       program_timeout = 20,  # How many milliseconds a program can run before being declared inviable\n                                       generation_limit = 10000,  # How many generations to run before giving up\n                                       verbose = False,  # Whether to print reports every generation. Useful during development.\n                                       cost_options = cost.default_cost_options,  # For advanced users only\n                                       mutate_options = mutate.default_mutate_options,  # For advanced users only\n                                       stagnation_generations = 10,  # After this many generations of no progress, kick in anti-stagnation measures.\n                                      )\n```\n\n## How it Works\n\n### The short version\nThe program generates a set of organisms in BF and evaluates them, using the difference between the inputs and expected outputs to assign a 'cost' to each organism. It then takes the 'best', those with the lowest cost, and mutates them, then crosses the mutated versions with the non-mutated ones. Then it evaluates those, mutates and crosses those, et cetera. Eventually, a program that satisfies the criteria is found, and its cost is 0. That's the result.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoracodes%2Fevolve_bf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoracodes%2Fevolve_bf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoracodes%2Fevolve_bf/lists"}