{"id":22104842,"url":"https://github.com/nemeslaszlo/tictactoe_ai_minimax","last_synced_at":"2025-03-24T02:43:38.388Z","repository":{"id":117466612,"uuid":"233207929","full_name":"NemesLaszlo/TicTacToe_AI_Minimax","owner":"NemesLaszlo","description":"Simple Tic Tac Toe game on 3x3 table with a Minimax algorithm implementation. Using Vanilla Javascript and p5.js for visualization and practise.","archived":false,"fork":false,"pushed_at":"2020-01-11T09:42:58.000Z","size":596,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-29T08:44:08.388Z","etag":null,"topics":["minimax-algorithm","tic-tac-toe","visualization"],"latest_commit_sha":null,"homepage":"https://nemeslaszlo.github.io/TicTacToe_AI_Minimax/","language":"JavaScript","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/NemesLaszlo.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}},"created_at":"2020-01-11T09:35:55.000Z","updated_at":"2020-10-04T09:43:42.000Z","dependencies_parsed_at":"2023-07-17T13:03:21.711Z","dependency_job_id":null,"html_url":"https://github.com/NemesLaszlo/TicTacToe_AI_Minimax","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/NemesLaszlo%2FTicTacToe_AI_Minimax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NemesLaszlo%2FTicTacToe_AI_Minimax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NemesLaszlo%2FTicTacToe_AI_Minimax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NemesLaszlo%2FTicTacToe_AI_Minimax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NemesLaszlo","download_url":"https://codeload.github.com/NemesLaszlo/TicTacToe_AI_Minimax/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245200670,"owners_count":20576673,"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":["minimax-algorithm","tic-tac-toe","visualization"],"created_at":"2024-12-01T06:35:30.828Z","updated_at":"2025-03-24T02:43:38.364Z","avatar_url":"https://github.com/NemesLaszlo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TicTacToe_AI_Minimax\nSimple Tic Tac Toe game on 3x3 table with a Minimax algorithm implementation. Using Vanilla Javascript and p5.js for visualization and practise.\n\n#### Source links and others:\nhttps://en.wikipedia.org/wiki/Minimax\n\nhttps://www.ntu.edu.sg/home/ehchua/programming/java/JavaGame_TicTacToe_AI.html\n\n\n##### Minimax function:\n\n```javascript\nfunction minimax(board, depth, isMaximizing) {\n  let result = checkWinner();\n  if (result !== null) {\n    return scores[result];\n  }\n\n  if (isMaximizing) {\n    let bestScore = -Infinity;\n    for (let i = 0; i \u003c 3; i++) {\n      for (let j = 0; j \u003c 3; j++) {\n        // Is the spot available?\n        if (board[i][j] == '') {\n          board[i][j] = ai;\n          let score = minimax(board, depth + 1, false);\n          board[i][j] = '';\n          bestScore = max(score, bestScore);\n        }\n      }\n    }\n    return bestScore;\n  } else {\n    let bestScore = Infinity;\n    for (let i = 0; i \u003c 3; i++) {\n      for (let j = 0; j \u003c 3; j++) {\n        // Is the spot available?\n        if (board[i][j] == '') {\n          board[i][j] = human;\n          let score = minimax(board, depth + 1, true);\n          board[i][j] = '';\n          bestScore = min(score, bestScore);\n        }\n      }\n    }\n    return bestScore;\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnemeslaszlo%2Ftictactoe_ai_minimax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnemeslaszlo%2Ftictactoe_ai_minimax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnemeslaszlo%2Ftictactoe_ai_minimax/lists"}