{"id":28602849,"url":"https://github.com/rpggio/goban","last_synced_at":"2025-08-08T08:54:08.766Z","repository":{"id":143998611,"uuid":"99166688","full_name":"rpggio/goban","owner":"rpggio","description":"Go game example implementation","archived":false,"fork":false,"pushed_at":"2017-08-02T22:47:56.000Z","size":79,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-11T16:27:51.524Z","etag":null,"topics":["csharp","design-patterns","game"],"latest_commit_sha":null,"homepage":"","language":"C#","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/rpggio.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,"zenodo":null}},"created_at":"2017-08-02T22:36:32.000Z","updated_at":"2021-06-21T22:08:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"754ab9c3-9193-4dc7-b375-62d518c6348b","html_url":"https://github.com/rpggio/goban","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rpggio/goban","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpggio%2Fgoban","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpggio%2Fgoban/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpggio%2Fgoban/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpggio%2Fgoban/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rpggio","download_url":"https://codeload.github.com/rpggio/goban/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpggio%2Fgoban/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269393636,"owners_count":24409755,"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-08-08T02:00:09.200Z","response_time":72,"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":["csharp","design-patterns","game"],"created_at":"2025-06-11T16:12:26.544Z","updated_at":"2025-08-08T08:54:08.741Z","avatar_url":"https://github.com/rpggio.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# goban\nGo game example implementation\n\nThis game was created to demonstrate object-oriented design to a friend of mine who was new to programming and was a fan of Go. There is no deep Go strategy included in the game so far. The computer-controlled black player attempts to surround the group that is closest to being surrounded, or to defend its own group in the same situation. The game recognizes groups of surrounded pieces and removes them from the board. You can try surrounding some black pieces to see it at work.\n\n![board](/board.jpg?raw=true \"board\")\n\n### Design\nThe interface IGroup is used to represent groups of stones.\n\n```\n/// \u003csummary\u003e\n/// Represents a logical group of positions. Provides operations for making calculations\n/// based on contained and adjacent positions.\n/// \u003c/summary\u003e\npublic interface IGroup\n{\n\tbool Contains(Position position);\n\tbool CanSurround { get; }\n\tStone Stone { get; }\n\tbool Bounds(Position pos);\n\tvoid Accept(IPositionVisitor visitor);\n\tSet\u003cPosition\u003e GetNeighbors();\n\tSet\u003cPosition\u003e Union(IEnumerable\u003cPosition\u003e positions);\n}\n```\nThe same interface is also used to represent the boundary of the board and empty board spaces, which makes the bounding calculations simple:\n\n```\n/// \u003csummary\u003e\n/// Determine if the group is currently enclosed.\n/// \u003c/summary\u003e\nprotected bool IsEnclosed(IGroup group)\n{\n\tforeach(Position p in group.GetNeighbors())\n\t{\n\t\t// Stones and borders can surround a group; empty spaces cannot.\n\t\tif (!FindGroup(p).CanSurround) return false;\n\t}\n\treturn true;\n}\n```\nThe implementation of the computer-controlled player is surprisingly simple (~15 lines).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frpggio%2Fgoban","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frpggio%2Fgoban","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frpggio%2Fgoban/lists"}