{"id":15557185,"url":"https://github.com/414owen/life-hs","last_synced_at":"2025-03-29T03:40:19.244Z","repository":{"id":131089415,"uuid":"105716076","full_name":"414owen/life-hs","owner":"414owen","description":"Conway's Game of Life in Haskell","archived":false,"fork":false,"pushed_at":"2017-10-06T11:06:18.000Z","size":23,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-03T13:27:09.803Z","etag":null,"topics":["functional-programming","game-of-life","haskell"],"latest_commit_sha":null,"homepage":null,"language":"Haskell","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/414owen.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":"2017-10-04T00:03:34.000Z","updated_at":"2020-03-31T20:12:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"8b0f5e01-6f10-4ceb-b247-eeb944a8d687","html_url":"https://github.com/414owen/life-hs","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/414owen%2Flife-hs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/414owen%2Flife-hs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/414owen%2Flife-hs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/414owen%2Flife-hs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/414owen","download_url":"https://codeload.github.com/414owen/life-hs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246135749,"owners_count":20729056,"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":["functional-programming","game-of-life","haskell"],"created_at":"2024-10-02T15:16:33.311Z","updated_at":"2025-03-29T03:40:19.212Z","avatar_url":"https://github.com/414owen.png","language":"Haskell","readme":"# Life-HS\n\nMy implementation of Conway's Game of Life in Haskell\n\n## To Use\n\n```\nstack build\nstack exec Life \u003cprogram/path\u003e\n```\n\nTwo example programs are included in the `programs/` folder. You can also\nappend a custom paint delay (in microseconds) to the run command. The default\npaint delay is 100000.\n\n## How It Works\n\n### Test Board\n\n```\n-------------------------\n| . | . | . | . | . | . |\n-------------------------\n| . | . | x | . | . | . |\n-------------------------\n| . | . | x | . | . | . |\n-------------------------\n| . | . | x | . | . | . |\n-------------------------\n| . | . | . | . | . | . |\n-------------------------\n| . | . | . | . | . | . |\n-------------------------\n```\n\n### Step One\n\nInsert the rightmost column to the left\n\n```\n-------------------------------------------\n| `.` |  .  |  .  |  .  |  .  |  .  |  .  |\n-------------------------------------------\n| `.` |  .  |  .  |  x  |  .  |  .  |  .  |\n-------------------------------------------\n| `.` |  .  |  .  |  x  |  .  |  .  |  .  |\n-------------------------------------------\n| `.` |  .  |  .  |  x  |  .  |  .  |  .  |\n-------------------------------------------\n| `.` |  .  |  .  |  .  |  .  |  .  |  .  |\n-------------------------------------------\n| `.` |  .  |  .  |  .  |  .  |  .  |  .  |\n-------------------------------------------\n   ^                                   |\n   |                                   |\n   -------------------------------------\n```\n\n### Step Two\n\nInsert the bottommost row at the top\n\n```\n-------------------------------------------\n| `.` | `.` | `.` | `.` | `.` | `.` | `.` | \u003c-|\n-------------------------------------------   |\n| `.` |  .  |  .  |  .  |  .  |  .  |  .  |   |\n-------------------------------------------   |\n| `.` |  .  |  .  |  x  |  .  |  .  |  .  |   |\n-------------------------------------------   |\n| `.` |  .  |  .  |  x  |  .  |  .  |  .  |   |\n-------------------------------------------   |\n| `.` |  .  |  .  |  x  |  .  |  .  |  .  |   |\n-------------------------------------------   |\n| `.` |  .  |  .  |  .  |  .  |  .  |  .  |   |\n-------------------------------------------   |\n| `.` |  .  |  .  |  .  |  .  |  .  |  .  | --|\n-------------------------------------------\n```\n\n### Step Three\n\nFor every row except the last, get chunks of two, and count the amount of 'x'\ncharacters in the two characters.\n\nFor a row that looks like this:\n\n```\n-------------------------------------------\n| `.` |  .  |  .  |  x  |  .  |  .  |  .  |\n-------------------------------------------\n```\n\nWe obtain this new list:\n\n```\n---------------------------------\n| 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 |\n---------------------------------\n```\n\nWhat we produce is actually the number of the 'x' characters occurring in the\ncells above and to the top left of a cell.\n\nWe end up with a grid representing every cell's top and top-left neighbour count.\n\n### Step Four\n\nRotate the original grid 90 degrees, and perform steps one to three on the\nrotated grid. When you rotate the top-left neighbour grid back, you can add it\nto the last rotations'. This will cover all of a cell's neighbours, even though\nwe've only coded a pattern for the top and top-left neighbours.\n\n### Step Five\n\nNow with the original grid and the grid representing the cells' neighbour\ncounts, apply the rules of the game to each cell to produce the next state.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F414owen%2Flife-hs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F414owen%2Flife-hs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F414owen%2Flife-hs/lists"}