{"id":23280940,"url":"https://github.com/claby2/gol","last_synced_at":"2025-10-29T17:44:20.063Z","repository":{"id":112527087,"uuid":"276010710","full_name":"claby2/gol","owner":"claby2","description":"C++ header-only Game of Life library ","archived":false,"fork":false,"pushed_at":"2020-07-02T10:45:36.000Z","size":94,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T19:47:59.061Z","etag":null,"topics":["cellular-automata","cpp","game-of-life","header-only","run-length-decoding","run-length-encoding","single-file"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/claby2.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-06-30T05:56:06.000Z","updated_at":"2020-09-18T11:05:23.000Z","dependencies_parsed_at":"2023-04-10T00:34:45.224Z","dependency_job_id":null,"html_url":"https://github.com/claby2/gol","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claby2%2Fgol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claby2%2Fgol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claby2%2Fgol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claby2%2Fgol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/claby2","download_url":"https://codeload.github.com/claby2/gol/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247489300,"owners_count":20947086,"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":["cellular-automata","cpp","game-of-life","header-only","run-length-decoding","run-length-encoding","single-file"],"created_at":"2024-12-19T23:39:40.385Z","updated_at":"2025-10-29T17:44:19.984Z","avatar_url":"https://github.com/claby2.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gol (Game of Life)\ngol is a [Game of Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life) library for C++.\n\nWith gol, you can easily simulate Conway's Game of Life cellular automaton in C++.\ngol is a single-file include which means you only need one header file to use it.\n\n## Features\n\n- A board class to iterate through and store a Conway's Game of Life simulation\n- Custom rule strings, wrapping, and neighborhood types\n- File parsing and saving (including support for run-length encoding)\n- [Documentation](DOCUMENTATION.md)\n\n## Installation\n1. Download the latest [single header version](https://raw.githubusercontent.com/claby2/gol/master/single_include/gol/gol.hpp).\n2. Either put the header file in a central location (with a specified path) or directly in your project tree.\n\n## Examples\n\nTo compile all the examples:\n```\n$ make example-compile\n```\n\n### Blinker Oscillator\n\nHere is an implementation that prints a blinker oscillator and steps 4 times:\n```cpp\n// Implements a blinker oscillator and steps 4 times\n// blinker oscillators have a period of 2 \n\n#include \u003cgol/gol.hpp\u003e\n\n#include \u003ciostream\u003e\n\ngol::Board board(10, 10);\n\n// Prints the board and then updates with next step\nvoid printAndStep() {\n    std::cout \u003c\u003c \"\\n\";\n    for(int i = 0; i \u003c board.height(); i++) {\n        for(int j = 0; j \u003c board.width(); j++) {\n            std::cout \u003c\u003c board[i][j] \u003c\u003c \" \";\n        }\n        std::cout \u003c\u003c \"\\n\";\n    }\n    board.nextStep(); // Update with next step with rule_string B3/S23\n}\n\nint main() {\n    for(int i = 0; i \u003c board.height(); i++) {\n        for(int j = 0; j \u003c board.width(); j++) {\n            board[i][j] = false;\n        }\n    }\n\n    // Make blinker oscillator\n    board[2][2] = true;\n    board[2][3] = true;\n    board[2][4] = true;\n\n    for(int i = 0; i \u003c 4; i++) {\n        printAndStep();\n    }\n}\n```\n\nThis will print the following twice:\n```\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 \n0 0 1 1 1 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 \n\n0 0 0 0 0 0 0 0 0 0\n0 0 0 1 0 0 0 0 0 0\n0 0 0 1 0 0 0 0 0 0\n0 0 0 1 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 \n```\n\n## Preview\n\nPreviewing requires [SDL2](https://libsdl.org/download-2.0.php).\n\nRefer to the `/preview` directory to see how gol can be used with SDL2 to preview simulations graphically.\n\nCompile the previewer with:\n```\n$ make preview-compile\n```\n\nRun the previewer with:\n```\n$ make preview\n```\n\n## Testing\n\nTesting requires [Catch2](https://github.com/catchorg/Catch2/).\n\nCompile with:\n```\n$ make test-compile\n```\nRun the tests with:\n```\n$ make test\n```\n\n## Reference\n\n[Documentation](DOCUMENTATION.md)\n\n### Functions\n\n| Function                                                | Use\n|---------------------------------------------------------|------------------------------------------------------|\n| [initRandom](DOCUMENTATION.md#initRandom)               | Initialize random seed                               |\n| [getRandomBool](DOCUMENTATION.md#getRandomBool)         | Return a random bool                                 |\n| [getBirthValues](DOCUMENTATION.md#getBirthValues)       | Return birth values from B/S notation rule string    |\n| [getSurvivalValues](DOCUMENTATION.md#getSurvivalValues) | Return survival values from B/S notation rule string |\n| [isValidRuleString](DOCUMENTATION.md#isValidRuleString) | Test whether rule string is valid                    |\n\n### Board Member Functions\n\n| Function                                                        | Use\n|-----------------------------------------------------------------|----------------------------------------------------------|\n| [(constructor)](DOCUMENTATION.md#(constructor))                 | Construct Game of Life board                             |\n| [operator[]](DOCUMENTATION.md#operator[])                       | Access element                                           |\n| [height](DOCUMENTATION.md#height)                               | Return the number of rows                                |\n| [width](DOCUMENTATION.md#width)                                 | Return the number of columns                             |\n| [countNeighborsMoore](DOCUMENTATION.md#countNeighborsMoore)     | Return number of true cells in Moore neighborhood        |\n| [countNeighborsNeumann](DOCUMENTATION.md#countNeighborsNeumann) | Return number of true cells in von Neumann neighborhood  |\n| [nextStep](DOCUMENTATION.md#nextStep)                           | Iterate to next time step                                |\n| [setWrap](DOCUMENTATION.md#setWrap)                             | Set to toggle wrapping for counting neighbors            |\n| [getWrap](DOCUMENTATION.md#getWrap)                             | Return the current wrap state                            |\n| [getNeighborhoodType](DOCUMENTATION.md#getNeighborhoodType)     | Return current neighborhood type                         |\n| [setFromFile](DOCUMENTATION.md#setFromFile)                     | Set values of board from given file                      |\n| [getLiveCount](DOCUMENTATION.md#getLiveCount)                   | Return the number of true elements                       |\n| [getDeadCount](DOCUMENTATION.md#getDeadCount)                   | Return the number of false elements                      |\n| [setFromRLEFile](DOCUMENTATION.md#setFromRLEFile)               | Set values of board from given RLE file                  |\n| [setRuleString](DOCUMENTATION.md#setRuleString)                 | Set rule string                                          |\n| [getRuleString](DOCUMENTATION.md#getRuleString)                 | Return current rule string                               |\n| [saveAsFile](DOCUMENTATION.md#saveAsFile)                       | Save board as file                                       |\n| [saveAsRLEFile](DOCUMENTATION.md#saveAsRLEFile)                 | Save board as RLE file                                   |","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclaby2%2Fgol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclaby2%2Fgol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclaby2%2Fgol/lists"}