{"id":43711603,"url":"https://github.com/s2t2/tic-tac-toe-py","last_synced_at":"2026-02-05T06:33:57.504Z","repository":{"id":43773145,"uuid":"440674851","full_name":"s2t2/tic-tac-toe-py","owner":"s2t2","description":"a basic adversarial game","archived":false,"fork":false,"pushed_at":"2024-07-25T21:25:14.000Z","size":264,"stargazers_count":30,"open_issues_count":2,"forks_count":175,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-07-26T00:03:14.044Z","etag":null,"topics":["ai","alpha-beta-pruning","game","minimax-algorithm","tic-tac-toe"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/s2t2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-21T23:14:52.000Z","updated_at":"2024-07-25T21:25:17.000Z","dependencies_parsed_at":"2023-01-20T03:46:39.336Z","dependency_job_id":null,"html_url":"https://github.com/s2t2/tic-tac-toe-py","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/s2t2/tic-tac-toe-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s2t2%2Ftic-tac-toe-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s2t2%2Ftic-tac-toe-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s2t2%2Ftic-tac-toe-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s2t2%2Ftic-tac-toe-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s2t2","download_url":"https://codeload.github.com/s2t2/tic-tac-toe-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s2t2%2Ftic-tac-toe-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29114910,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T05:31:32.482Z","status":"ssl_error","status_checked_at":"2026-02-05T05:31:29.075Z","response_time":65,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["ai","alpha-beta-pruning","game","minimax-algorithm","tic-tac-toe"],"created_at":"2026-02-05T06:33:56.938Z","updated_at":"2026-02-05T06:33:57.491Z","avatar_url":"https://github.com/s2t2.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# Tic Tac Toe\n\nAn adversarial game.\n\n[![Maintainability](https://api.codeclimate.com/v1/badges/23f08f09e8f419f21df0/maintainability)](https://codeclimate.com/github/s2t2/tic-tac-toe-py/maintainability)\n\n![Tests](https://github.com/s2t2/tic-tac-toe-py/actions/workflows/python-app.yml/badge.svg)\n\n## Prerequisites\n\n  + Anaconda 3.7+\n  + Python 3.7+\n  + Pip\n\n## Setup\n\nOptionally fork this [remote repository](https://github.com/s2t2/tic-tac-toe-py), to create a copy under your own control. Then \"clone\" or download the remote repository (or your forked copy) onto your local computer, for example to your Desktop. Then navigate to wherever you downloaded the repo:\n\n```sh\ncd ~/Desktop/tic-tac-toe-py\n```\n\nCreate a virtual environment:\n\n```sh\nconda create -n tictactoe-env python=3.11\n```\n\nActivate the virtual environment:\n\n```sh\nconda activate tictactoe-env\n```\n\nInstall package dependencies within the virtual environment:\n\n```sh\npip install -r requirements.txt\n```\n\n## Player Types\n\nWhen you play games, you'll be able to select any of the following combinations of players:\n\nplayer type(s) | description\n--- | ---\n`HUMAN` | A human player who will input their selections.\n`COMPUTER-EASY` or `RANDOM` | A computer player which makes random selections. Easy to beat.\n`COMPUTER-HARD` or `MINIMAX` | A computer player which thinks ahead to make optimal selections. Uses the \"minimax\" algorithm to simulate moves and evaluate all possible game states. Impossible to beat.\n`MINIMAX-AB` | A much faster version of the hard computer player. Uses \"alpha-beta\" pruning to skip evaluations of unnecessary game states.\n\n## Usage\n\n### Game Play\n\nPlay a game (human vs human, human vs computer, computer vs computer):\n\n```sh\npython -m app.game\n```\n\n\n### Game Simulation\n\nPlay many games (computer vs computer), saves results to CSV file in \"data\" directory. Optionally pass the game count and/or player strategies as environment variables:\n\n```sh\npython -m app.jobs.play_games\n\n# alternatively:\nGAME_COUNT=3 python -m app.jobs.play_games\n\n# alternatively:\nX_STRATEGY=\"COMPUTER-HARD\" O_STRATEGY=\"COMPUTER-EASY\" GAME_COUNT=100 python -m app.jobs.play_games\n```\n\n\n## Testing\n\nRun automated tests, to know whether the app is working as expected:\n\n```sh\npytest\n```\n\n\n## Demo\n\nHere is a demonstration of gameplay between computer players:\n\n```\nSELECT X PLAYER TYPE ('HUMAN' / 'COMPUTER-EASY' / 'COMPUTER-HARD'): COMPUTER-HARD\nSELECT O PLAYER TYPE ('HUMAN' / 'COMPUTER-EASY' / 'COMPUTER-HARD'): COMPUTER-HARD\nWould you like to use a pre-saved game state? (Y/N): n\n\n                A   B   C\n\n            1     |   |\n               -----------\n            2     |   |\n               -----------\n            3     |   |\n\n\nPLAYER X THINKING...\n\n                A   B   C\n\n            1     |   |\n               -----------\n            2     |   |\n               -----------\n            3   X |   |\n\n\nPLAYER O THINKING...\n... \u003cSquare A1\u003e -3\n... \u003cSquare B1\u003e -3\n... \u003cSquare C1\u003e -3\n... \u003cSquare A2\u003e -3\n... \u003cSquare B2\u003e 0\n... \u003cSquare C2\u003e -3\n... \u003cSquare B3\u003e -3\n... \u003cSquare C3\u003e -3\n\n                A   B   C\n\n            1     |   |\n               -----------\n            2     | O |\n               -----------\n            3   X |   |\n\n\nPLAYER X THINKING...\n... \u003cSquare A1\u003e 0\n... \u003cSquare B1\u003e 0\n... \u003cSquare C1\u003e 0\n... \u003cSquare A2\u003e 0\n... \u003cSquare C2\u003e 0\n... \u003cSquare B3\u003e 0\n... \u003cSquare C3\u003e 0\n\n                A   B   C\n\n            1   X |   |\n               -----------\n            2     | O |\n               -----------\n            3   X |   |\n\n\nPLAYER O THINKING...\n... \u003cSquare B1\u003e -5\n... \u003cSquare C1\u003e -5\n... \u003cSquare A2\u003e 0\n... \u003cSquare C2\u003e -5\n... \u003cSquare B3\u003e -5\n... \u003cSquare C3\u003e -5\n\n                A   B   C\n\n            1   X |   |\n               -----------\n            2   O | O |\n               -----------\n            3   X |   |\n\n\nPLAYER X THINKING...\n... \u003cSquare B1\u003e -4\n... \u003cSquare C1\u003e -4\n... \u003cSquare C2\u003e 0\n... \u003cSquare B3\u003e -4\n... \u003cSquare C3\u003e -4\n\n                A   B   C\n\n            1   X |   |\n               -----------\n            2   O | O | X\n               -----------\n            3   X |   |\n\n\nPLAYER O THINKING...\n... \u003cSquare B1\u003e 0\n... \u003cSquare C1\u003e 0\n... \u003cSquare B3\u003e 0\n... \u003cSquare C3\u003e 0\n\n                A   B   C\n\n            1   X | O |\n               -----------\n            2   O | O | X\n               -----------\n            3   X |   |\n\n\nPLAYER X THINKING...\n... \u003cSquare C1\u003e -2\n... \u003cSquare B3\u003e 0\n... \u003cSquare C3\u003e -2\n\n                A   B   C\n\n            1   X | O |\n               -----------\n            2   O | O | X\n               -----------\n            3   X | X |\n\n\nPLAYER O THINKING...\n... \u003cSquare C1\u003e -1\n... \u003cSquare C3\u003e 0\n\n                A   B   C\n\n            1   X | O |\n               -----------\n            2   O | O | X\n               -----------\n            3   X | X | O\n\n\nPLAYER X THINKING...\n... \u003cSquare C1\u003e 0\n\n                A   B   C\n\n            1   X | O | X\n               -----------\n            2   O | O | X\n               -----------\n            3   X | X | O\n\n\n{'winner': None, 'reason': 'NO_MORE_SQUARES', 'message': 'TIE GAME'}\n```\n\n## [License](/LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs2t2%2Ftic-tac-toe-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs2t2%2Ftic-tac-toe-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs2t2%2Ftic-tac-toe-py/lists"}