{"id":23394821,"url":"https://github.com/dineshgowda24/tic-tac-toe","last_synced_at":"2025-04-11T12:54:12.776Z","repository":{"id":140254149,"uuid":"606293365","full_name":"dineshgowda24/tic-tac-toe","owner":"dineshgowda24","description":"🎮 Tic Tac Toe implementation over network 🌐","archived":false,"fork":false,"pushed_at":"2023-02-25T13:15:18.000Z","size":3512,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T09:11:58.777Z","etag":null,"topics":["golang","network","tic-tac-toe"],"latest_commit_sha":null,"homepage":"","language":"Go","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/dineshgowda24.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":"2023-02-25T03:54:08.000Z","updated_at":"2023-03-01T14:52:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"9897eada-e855-4ef1-a54a-435f1514c374","html_url":"https://github.com/dineshgowda24/tic-tac-toe","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/dineshgowda24%2Ftic-tac-toe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dineshgowda24%2Ftic-tac-toe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dineshgowda24%2Ftic-tac-toe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dineshgowda24%2Ftic-tac-toe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dineshgowda24","download_url":"https://codeload.github.com/dineshgowda24/tic-tac-toe/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248403918,"owners_count":21097616,"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":["golang","network","tic-tac-toe"],"created_at":"2024-12-22T06:18:17.539Z","updated_at":"2025-04-11T12:54:12.752Z","avatar_url":"https://github.com/dineshgowda24.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tic Tac Toe\n\n## Features\n\n- Game can be extended to NxN board\n- Game can be played by 2 players:\n    1. Human vs Dumb Computer\n    2. Human vs Human\n    3. Human vs Smart Computer\n- Game can be played over the network.\n\n\n## Components\n\n### Player\n\n```go\ntype Player interface {\n    Play(*board.Board) int\n    Notify(data string) error\n    Move() Move\n    Name() string\n    Exit() error\n}\n```\n\nPlayer is an interface who can play.\n\n- Concrete implementations include `Human`, `RandomComputer`\n    1. `Human` - Takes input from STDIN\n    2. `RandomComputer` - Generates a random input.\n    3. `SmartComputer` - Generates input based on context of the game. It Makes decisions to win\n\nFor SmartComputer implementations, I had look at references for [minimax algorithms](https://www.youtube.com/watch?v=trKjYdBASyQ\u0026t=772s\u0026ab_channel=TheCodingTrain)\n\n### Board\n\nBoard stores all the use inputs, validates if the input is valid.\nInternally it stores a one dimensional array of `integer`.\n\n```go\ntype Board struct {\n    moves int          // moves represents the total number of valid moves made on board\n    size  int          // size of NxN matrix, represents N\n    grid  []int        // one dimensional array representing NxN matrix\n}\n```\n\n### Game\n\nGame has the context of board and players. It drives the whole tic-tac-toe game.\nIt validates when the game is completed and returns.\n\n```go\ntype Game struct {\n    board     *board.Board // tic tak toe board\n    playerOne player.Player\n    playerTwo player.Player\n}\n```\n\n## Set up\n\n### Requirements\n\n- [Golang](https://golang.org/dl/)\n\nOnce `Go` is installed run the below command\n\n```go\nmake build\n./play\n```\n\n### Playing over the network\n\n1. Start the server.\n\n```shell\ngo run main.go server\n```\n\n2. Connect to the server.\n\n```shell\nnc 127.0.0.1 8080\n```\n\nIt needs to players to connect, so run the `nc` command twice in different terminal session.\n\n### Running the cli\n\n```shell\ngo run main.go cli\n```\n\n## Demo\n\n### Smart Computer\n\n\u003cimg src=\"smart_computer.svg\"/\u003e\n\n\n### Starting the server\n\n\u003cimg src=\"server_startup.svg\"/\u003e\n\n\n### Connecting to the server\n\n\u003cimg src=\"network_play.svg\"/\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdineshgowda24%2Ftic-tac-toe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdineshgowda24%2Ftic-tac-toe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdineshgowda24%2Ftic-tac-toe/lists"}