{"id":23119539,"url":"https://github.com/programmerdan/tic-tac-toe-golf","last_synced_at":"2025-04-04T02:41:32.699Z","repository":{"id":14636996,"uuid":"17354589","full_name":"ProgrammerDan/tic-tac-toe-golf","owner":"ProgrammerDan","description":"Tic-Tac-Toe, solved as minimally as possible yet still playable.","archived":false,"fork":false,"pushed_at":"2014-03-05T06:14:36.000Z","size":168,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T14:24:09.842Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ProgrammerDan.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":"2014-03-03T03:55:54.000Z","updated_at":"2014-03-05T06:14:37.000Z","dependencies_parsed_at":"2022-09-12T10:11:19.414Z","dependency_job_id":null,"html_url":"https://github.com/ProgrammerDan/tic-tac-toe-golf","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/ProgrammerDan%2Ftic-tac-toe-golf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProgrammerDan%2Ftic-tac-toe-golf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProgrammerDan%2Ftic-tac-toe-golf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProgrammerDan%2Ftic-tac-toe-golf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ProgrammerDan","download_url":"https://codeload.github.com/ProgrammerDan/tic-tac-toe-golf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247112728,"owners_count":20885605,"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":[],"created_at":"2024-12-17T05:39:12.738Z","updated_at":"2025-04-04T02:41:32.680Z","avatar_url":"https://github.com/ProgrammerDan.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Tic-Tac-Toe Golf\n================\n\nSolution to [Noughts and Crosses (aka Tic-Tac-Toe)](http://codegolf.stackexchange.com/questions/1054/noughts-and-crosses-aka-tic-tac-toe).\n\nTrying to see how minimally I can make a playable Tic-Tac-Toe. In Java for now.\n\nBuilding un-golfed version:\n\n    javac TicTacToeGolf.java\n    java TicTacToeGolf\n\nBuilding equivalent golfed version (at time of writing, 1801 characters):\n\n    javac T.java\n    java T\n\nBuilding optimized golfed version (at time of writing, 1690 characters):\n\n    javac W.java\n    java W\n\n**Some usage notes:**\n\n* 50/50 chance for who takes first turn. \n* Move of \"X\" or \"O\" announced before displaying the game board. \n* Choice of cell is specified as column, then row, indexed from 0. \n* Entering something outside `[0,2]` will cause a index exception and end the game.\n* If computer goes first, takes a random move (no preference for any board location).\n* Computer will take one move wins, block one move losses, plays conservatively (prefers center if available), tries to set up a two-turn win (hope other player doesn't block), and if that fails? Picks a random spot. So doesn't play a perfect game, but plays a great game. I can force a win due to the random start possibilities, but computer will force a win as well if I start badly. \n* Wins are detected immediately. \n* Impossible-to-win is *not* detected; you must play every game to the end or let the other player win. \n* At the end of each game, a new game begins, again with a randomly chosen starting player.\n* Use `Ctrl+c` to end.\n\nThere's definitely room for improvement. One place is likely replacing the multi-dimensional array with a one-dimensional array, and replacing the more complex decision logic with either a reduced form of the same, or a more concise best-choice solver.\n\nPlay around with it and let me know what you think. Feel free to fork, or recommend improvements via pull requests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogrammerdan%2Ftic-tac-toe-golf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprogrammerdan%2Ftic-tac-toe-golf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogrammerdan%2Ftic-tac-toe-golf/lists"}