{"id":20489233,"url":"https://github.com/opensourcetreasure/ai-tic-tac-toe","last_synced_at":"2026-02-05T00:34:51.385Z","repository":{"id":262973180,"uuid":"888944398","full_name":"OpenSourceTreasure/ai-tic-tac-toe","owner":"OpenSourceTreasure","description":"Tic tac toe on a simple html page with powerful AI, zero dependencies","archived":false,"fork":false,"pushed_at":"2024-11-17T08:45:07.000Z","size":90,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-05T17:17:02.676Z","etag":null,"topics":["ai","ai-game","dark-mode","game","html","js","tic-tac-toe"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenSourceTreasure.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":"2024-11-15T09:59:28.000Z","updated_at":"2025-01-06T11:20:17.000Z","dependencies_parsed_at":"2024-11-15T11:18:11.899Z","dependency_job_id":"1107902a-0e2b-4171-8431-a59e8162cddd","html_url":"https://github.com/OpenSourceTreasure/ai-tic-tac-toe","commit_stats":null,"previous_names":["opensourcetreasure/ai-tic-tac-toe"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenSourceTreasure%2Fai-tic-tac-toe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenSourceTreasure%2Fai-tic-tac-toe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenSourceTreasure%2Fai-tic-tac-toe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenSourceTreasure%2Fai-tic-tac-toe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenSourceTreasure","download_url":"https://codeload.github.com/OpenSourceTreasure/ai-tic-tac-toe/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242067713,"owners_count":20066751,"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":["ai","ai-game","dark-mode","game","html","js","tic-tac-toe"],"created_at":"2024-11-15T17:11:49.427Z","updated_at":"2026-02-05T00:34:51.338Z","avatar_url":"https://github.com/OpenSourceTreasure.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":" ✔ AI Tic Tac Toe\n\n💡 Run Tic-Tac-Toe.html (simple!)\n\n✅ Zero dependencies\n\n✅ Minimax Algorithm guarantees its not easy to win!\n\n🎤 My goal is to demonstrate how easy it is to create an AI game in html-javascript.\n\n🍷 There is a second Tic Tac Toe game that utilizes the Q Learning Algorithm. I noticed a difference in the playing style. I hope you do too. In this version, the AI uses a combination of Minimax for immediate decision-making but with an added layer of Q-learning. This means it doesn't just play optimally each time. Instead, it learns from previous games and adjusts its strategy over time based on the Q-values of moves that have been successful (win/loss). The file named Tic-Tac-Toe-Q-Learning-Reset.html has a button that lets you reset the Q-Learning AI!\n\n🥁 The Minimax algorithm is a decision-making algorithm typically used in game theory for two-player turn-based games like Tic-Tac-Toe, Chess, and Checkers. It works by recursively evaluating all possible moves and selecting the optimal move based on the current state of the game board.\n\n🎷 The algorithm explores all possible board states (all possible moves for both the AI and the player) in a tree-like structure. Each node represents a potential board configuration, and each move corresponds to a branch in the tree.\n\n🎸 The algorithm evaluates all possible moves at each level, choosing the best move for the AI and the best move for the player in the recursive tree. The AI moves to maximize its score, and the player moves to minimize the AI's score.\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://github.com/OpenSourceTreasure/ai-tic-tac-toe/blob/main/tic-tac-toe.png\"\u003e\u003c/p\u003e\n\n\n💬 For those interested, here is more detailed info:\n\nSteps of the Minimax Algorithm in the Game:\nAI Move: The AI evaluates all possible moves on the board and calculates the best move using Minimax.\n\nMinimax Calculation:\n\nFor every empty spot on the board, the AI \"places\" its symbol (O) and recursively calculates the best possible score.\nIt then \"un-places\" the symbol and moves to the next empty spot, continuing the process.\nThe move with the highest score is chosen as the AI's move.\nPlayer Move: The player chooses a spot, and the AI responds based on the evaluation from Minimax.\n\nWhy is Minimax Effective Here?\nOptimal Strategy: For Tic-Tac-Toe, which is a small game with a limited number of possible moves, Minimax can evaluate all possible moves in a reasonable amount of time and select the optimal move. This guarantees that the AI never loses and can either win or force a tie, depending on the player's moves.\nTie or Win: Since Tic-Tac-Toe is a solved game, the AI will never lose if it uses the Minimax algorithm correctly.\nHow It Works in the Game:\nIn the provided code:\n\nThe getBestMove function computes the best possible move using Minimax.\nThe minimax function evaluates the board recursively, applying the logic described above.\nThis is a simple AI implementation, and while it works well for a small game like Tic-Tac-Toe, more complex games would require more advanced AI techniques, such as Alpha-Beta Pruning, which optimizes the Minimax algorithm by cutting off branches that don’t need to be explored.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopensourcetreasure%2Fai-tic-tac-toe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopensourcetreasure%2Fai-tic-tac-toe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopensourcetreasure%2Fai-tic-tac-toe/lists"}