{"id":17004863,"url":"https://github.com/clickermonkey/gamesol","last_synced_at":"2025-03-22T10:39:23.900Z","repository":{"id":6816441,"uuid":"8064467","full_name":"ClickerMonkey/Gamesol","owner":"ClickerMonkey","description":"A Generic Game Solving Library in Java. You define the state of a game, possible moves, and gamesol will find the first solution, all solutions, the path to those solutions, anything you want!","archived":false,"fork":false,"pushed_at":"2015-09-04T21:04:15.000Z","size":298,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-27T10:23:15.538Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"osl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ClickerMonkey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-07T01:52:50.000Z","updated_at":"2024-03-12T19:05:54.000Z","dependencies_parsed_at":"2022-09-16T21:50:45.912Z","dependency_job_id":null,"html_url":"https://github.com/ClickerMonkey/Gamesol","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClickerMonkey%2FGamesol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClickerMonkey%2FGamesol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClickerMonkey%2FGamesol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClickerMonkey%2FGamesol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ClickerMonkey","download_url":"https://codeload.github.com/ClickerMonkey/Gamesol/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244945597,"owners_count":20536295,"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-10-14T04:44:38.491Z","updated_at":"2025-03-22T10:39:23.882Z","avatar_url":"https://github.com/ClickerMonkey.png","language":"Java","readme":"gamesol\n=======\n\n![Stable](http://i4.photobucket.com/albums/y123/Freaklotr4/stage_stable.png)\n\nA generic game solving library in Java.\n\nThese Games are included as example:\n- Sudoku [wiki](http://en.wikipedia.org/wiki/Sudoku)\n- Mazes [wiki](http://en.wikipedia.org/wiki/Maze)\n- Tetravex [wiki](http://en.wikipedia.org/wiki/Tetravex)\n- N-Puzzle [wiki](http://en.wikipedia.org/wiki/15_puzzle)\n- Peg Solitaire [wiki](http://en.wikipedia.org/wiki/Peg_solitaire)\n\nSO, How do you use gamesol to solve your game?\n\nThere are two classes to implement: Move and State.\n\n\u003cb\u003eState\u003c/b\u003e is the state of your game at some point in time. Your implementation must determine the list of possible moves from that state as well as be able to apply those moves to the current state to generate a new state. If the state of your game can be repeatable (you could reach the exact same state in the future) you must return a hash so states are not repeated.\n\n```java\npublic interface State\u003cM\u003e\n{\n  public boolean isSolution();\n  public Iterator\u003cM\u003e getMoves();\n  public State\u003cM\u003e getCopy();\n  public void addMove( M move );\n  public void setParent( State\u003cM\u003e parent );\n  public State\u003cM\u003e getParent();\n  public void setDepth( int depth );\n  public int getDepth();\n  public Object getHash();\n}\n```\n\n\u003cb\u003eMove\u003c/b\u003e is a possible move that can be made in your game and has no predefined interface, a Move can be anything chosen by the State implementation.\n\n\u003cb\u003eLinks\u003c/b\u003e:\n- [Documentation](http://gh.magnos.org/?r=http://clickermonkey.github.com/Gamesol/)\n- [Builds](http://gh.magnos.org/?r=https://github.com/ClickerMonkey/Gamesol/blob/master/build)\n- [Examples](Examples//org/magnos/solver)\n\n\n\u003cb\u003eNOTICE\u003c/b\u003e\nIt is important to understand that gamesol is simply a tree traversing utility that performs either a depth or breadth first search, optionally saves move history through parent references, and can avoid duplicate states. \n\u003ci\u003eThe efficiency of the Solver is fully dependent on how you save your state, moves, and how you determine your next moves (the fewer and more precise moves the better)\u003c/i\u003e\n\nSudoku Example [Full Code](Examples/org/magnos/solver/sudoku/Sudoku.java)\n\n```java\n// solve a 3-grid (9x9) puzzle\nboard = new short[][] {\n    {0, 0, 0,/**/ 0, 5, 3,/**/ 6, 0, 0},\n\t{0, 3, 0,/**/ 1, 0, 0,/**/ 0, 0, 0},\n\t{1, 0, 5,/**/ 0, 7, 0,/**/ 0, 9, 0},\n\t/* ****************************** */\n\t{0, 0, 0,/**/ 2, 0, 0,/**/ 7, 5, 0},\n\t{0, 8, 0,/**/ 0, 0, 0,/**/ 0, 3, 0},\n\t{0, 5, 4,/**/ 0, 0, 1,/**/ 0, 0, 0},\n\t/* ****************************** */\n\t{0, 6, 0,/**/ 0, 2, 0,/**/ 5, 0, 8},\n\t{0, 0, 0,/**/ 0, 0, 6,/**/ 0, 2, 0},\n\t{0, 0, 3,/**/ 4, 1, 0,/**/ 0, 0, 0}\n};\nSudokuBoard sudoku = new SudokuBoard(3, board);\n\nSolver\u003cSudokuMove\u003e solver = new Solver\u003cSudokuMove\u003e();\nsolver.setInitialState(sudoku);\nsolver.setRevisitStates(true);    // True since there can never be duplicate states\nsolver.setSaveParent(true);       // If you want a move-by-move history saved for each solution\nsolver.solve();\n\n// All possible solutions for the given board\nList\u003cSudokuBoard\u003e solutions = solver.getSolutions();\n\n// If you provide an empty board, all possible Sudoku boards will be created... I can't promise it will ever finish.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclickermonkey%2Fgamesol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclickermonkey%2Fgamesol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclickermonkey%2Fgamesol/lists"}