{"id":34501581,"url":"https://github.com/dpm76/gameoflife","last_synced_at":"2026-06-07T09:31:42.044Z","repository":{"id":324882688,"uuid":"1097675670","full_name":"dpm76/GameOfLife","owner":"dpm76","description":"Game of Life simulator in Python featuring clean architecture, unit testing, and graphical visualization.","archived":false,"fork":false,"pushed_at":"2025-11-18T10:24:20.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-18T13:10:58.394Z","etag":null,"topics":["cellularautomata","clean-architecture","console-app","conway","design-patterns","gameoflife","gameoflifesimulation","infinitegrid","portfolio","python","python-3","simulation","software-architecture","tkinter","tkinter-python","ui","unittest"],"latest_commit_sha":null,"homepage":"","language":"Python","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/dpm76.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-16T16:21:16.000Z","updated_at":"2025-11-18T10:46:18.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/dpm76/GameOfLife","commit_stats":null,"previous_names":["dpm76/gameoflife"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/dpm76/GameOfLife","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpm76%2FGameOfLife","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpm76%2FGameOfLife/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpm76%2FGameOfLife/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpm76%2FGameOfLife/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dpm76","download_url":"https://codeload.github.com/dpm76/GameOfLife/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpm76%2FGameOfLife/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27992996,"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","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cellularautomata","clean-architecture","console-app","conway","design-patterns","gameoflife","gameoflifesimulation","infinitegrid","portfolio","python","python-3","simulation","software-architecture","tkinter","tkinter-python","ui","unittest"],"created_at":"2025-12-24T02:02:51.626Z","updated_at":"2025-12-24T02:03:06.823Z","avatar_url":"https://github.com/dpm76.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🧬 Game of Life – Python Implementation\n\nA **Python implementation** of Conway’s **Game of Life** simulating the evolution of cellular automata through standard rules.\nThe initial state is defined in a file and the simulation can be visualized:\n\n* in the **console**, or\n* in a **GUI window** (requires `tkinter`)\n\n---\n\n## 📂 Project Structure\n\n```\nGameOfLife/\n│\n├── game/               # Core Game of Life logic\n├── ui/                 # User interfaces (console / GUI)\n├── initial_states/     # Sample initial state input files\n├── test/               # Unit tests\n├── main.py             # Application entry point\n├── LICENSE\n└── README.md\n```\n\nGame logic and user interface are cleanly separated across modules.\n\n---\n\n## 🧩 Software Design, Architecture \u0026 Best Practices\n\n### Overview\n\nThis project is structured with a clear separation of concerns:\n\n| Layer                       | Directory | Responsibility                                 |\n| --------------------------- | --------- | ---------------------------------------------- |\n| **Game Logic**              | `/game`   | Cell state management and Conway's rules       |\n| **User Interface**          | `/ui`     | Console and Tkinter GUI visualization          |\n| **Application Entry Point** | `main.py` | Command-line parsing and runtime configuration |\n\nThis modular architecture allows the UI to evolve independently from the game engine—for example, adding a web or mobile UI without modifying the core simulation logic.\n\n---\n\n### 🎯 Domain-Driven Entities\n\nThe simulation is based on two core domain objects:\n\n| Class           | Type                     | Responsibility                                              |\n| --------------- | ------------------------ | ----------------------------------------------------------- |\n| `Cell`          | Value Object             | Represents a living cell in the infinite grid               |\n| `CandidateCell` | Specialized Value Object | Used temporarily during evolution to compute survival/birth |\n\nThe board (`Board`) receives and produces lists of these entities each turn, applying Conway's Game of Life rules.\n\n---\n\n### 🧠 Design Patterns \u0026 Engineering Principles Applied\n\n| Pattern / Principle                | Location                                 | Benefit                                              |\n| ---------------------------------- | ---------------------------------------- | ---------------------------------------------------- |\n| **Value Object Pattern**           | `Cell`                                   | Coordinates define identity; correct equality checks |\n| **Inheritance for Specialization** | `CandidateCell(Cell)`                    | Extends state only when required for evolution       |\n| **Transient Entity Pattern**       | `CandidateCell`                          | Exists only during a single turn → memory efficiency |\n| **Spatial Hashing**                | `Cell.create_hash()`                     | Efficient O(1) lookup in sparse infinite grid        |\n| **Separation of Concerns**         | `/game` vs `/ui`                         | Core logic isolated from rendering concerns          |\n| **Dependency Inversion Principle** | UI depends on interfaces (Board results) | Easy to test and replace UI                          |\n| **Encapsulation**                  | Private attributes                       | Protects internal state from external mutation       |\n| **Command-Line Interface Pattern** | `main.py`                                | Encourages flexible and scriptable usage             |\n\n---\n\n### 🧪 Testing \u0026 Maintainability\n\nUnit tests included in `/test` help ensure reliable behaviors:\n\n* correct cell identity and hashing\n* accurate neighbor generation\n* validated rule execution in `Board`\n\nDesigned for:\n\n* fast execution\n* deterministic output\n* TDD-friendly iteration\n\n---\n\n### ⚙️ Performance Considerations\n\n| Optimization                                  | Result                                      |\n| --------------------------------------------- | ------------------------------------------- |\n| Only living cells are stored between turns    | Takes advantage of sparse grids             |\n| Only neighbors of living cells are considered | Avoids scanning infinite grid               |\n| Spatial hashing for identity                  | Simplifies comparisons and dictionary usage |\n\nThese techniques allow **infinite board simulation** without large memory structures.\n\n---\n\n## ▶️ Running the Application\n\n```bash\npython main.py filename [--mode MODE]\n```\n\n### 📌 Command line arguments\n\n| Argument                    | Description                         |\n| --------------------------- | ----------------------------------- |\n| `filename`                  | Path to the initial state file      |\n| `--mode {console,gui,grid}` | Visualization mode (default: `gui`) |\n| `-h`, `--help`              | Display help                        |\n\nExamples:\n\n```bash\npython main.py initial_states/glider --mode console\npython main.py initial_states/gosper_glider_gun --mode gui\n```\n\n\u003e GUI mode requires the `tkinter` module.\n\n---\n\n## 🧪 Running Unit Tests\n\n```bash\npython -m unittest\n```\n\nVerbose output:\n\n```bash\npython -m unittest -v\n```\n\n---\n\n## 🛠️ Requirements \u0026 Virtual Environment (optional)\n\nOnly **Python standard libraries** are used.\n\nTo create and activate a virtual environment:\n\n```bash\npython -m venv venv\nsource venv/bin/activate   # Linux/macOS\nvenv\\Scripts\\activate      # Windows\n```\n\n---\n\n## 🪟 Installing tkinter\n\nIf GUI mode fails due to missing tkinter, install it using:\n\n### Linux (Debian/Ubuntu/Raspberry Pi OS)\n\n```bash\nsudo apt-get update\nsudo apt-get install python3-tk\n```\n\n### Fedora\n\n```bash\nsudo dnf install python3-tkinter\n```\n\n### Arch Linux\n\n```bash\nsudo pacman -S tk\n```\n\n### macOS \u0026 Windows\n\nUsually included with Python from python.org.\nIf missing, reinstall Python using the official installer.\n\n---\n\n## 📌 Initial State File Format\n\nInitial states are stored in **plain text files**:\n\n1. **First line** → starting board coordinates\n   Format:\n\n   ```\n   x, y\n   ```\n\n   Example:\n\n   ```\n   0, 0\n   ```\n\n2. Starting from the **second line**:\n\n   * `*` → alive cell\n   * space `\" \"` → dead cell\n\nCells are placed **relative to the starting coordinates**.\nAll rows must have the same width.\n\n### Example: Blinker (oscillator)\n\n```\n5, 3\n *\n *\n *\n```\n\nThis places the first cell of the second line at coordinate `(5,3)` and builds the pattern downward.\n\n---\n\n## 🌟 Famous Patterns\n\nSome classic patterns compatible with this format:\n\n| Pattern               | Type       | Description                   |\n| --------------------- | ---------- | ----------------------------- |\n| **Glider**            | Spaceship  | Moves diagonally forever      |\n| **Blinker**           | Oscillator | Alternates between two states |\n| **Toad**              | Oscillator | Period-2 oscillator           |\n| **Gosper Glider Gun** | Gun        | Produces infinite gliders     |\n| **Block**             | Still Life | Stays unchanged               |\n\nMultiple ready-to-use samples are located in the `initial_states/` directory.\n\n---\n\n## 🚀 Possible Future Enhancements\n\n* Support alternative rule sets (e.g., HighLife, Seeds…)\n* Parallelization or chunk-based updates\n* Web or GPU rendering (Canvas / WebGL)\n* Support for RLE pattern format (community standard)\n\n---\n\n## 📚 Additional Resources\n\nLearn more about Conway’s Game of Life:\n\n* Wikipedia — Conway’s Game of Life\n  [https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life)\n* ConwayLife.com — The Life Wiki\n  [https://www.conwaylife.com/wiki/Main_Page](https://www.conwaylife.com/wiki/Main_Page)\n* Play Game of Life online\n  [https://playgameoflife.com/](https://playgameoflife.com/)\n* Coding Train — Game of Life video tutorial\n  [https://www.youtube.com/watch?v=FWSR_7kZuYg](https://www.youtube.com/watch?v=FWSR_7kZuYg)\n* Original 1970 Scientific American article (Martin Gardner)\n  [https://web.archive.org/web/20231101083058/http://www.ibiblio.org/lifepatterns/october1970scientificamerican.pdf](https://web.archive.org/web/20231101083058/http://www.ibiblio.org/lifepatterns/october1970scientificamerican.pdf)\n\n---\n\n## 📜 License\n\nThis project is open-source (under MIT license).\nContributions and improvements are welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdpm76%2Fgameoflife","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdpm76%2Fgameoflife","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdpm76%2Fgameoflife/lists"}