From b8f6c68f042622ff1b73807f1ef990f8f608b667 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Mon, 6 Jul 2020 21:38:06 -0300 Subject: [PATCH] Update README (add methods section) --- README.md | 38 +++++++++++++++++++++++++++++++++++++- images/goal-state.jpg | Bin 0 -> 13707 bytes 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 images/goal-state.jpg diff --git a/README.md b/README.md index 1edbade..c010cce 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A TypeScript lib that solves Puzzle Game problem using the A* Algorithm Use the package manager [npm](https://www.npmjs.com/) to install A* Puzzle Solver. ```bash -npm install a-star-puzzle-solver-ts +npm install a-star-puzzle-solver ``` ## How to use @@ -47,6 +47,42 @@ const aStar = AStarPuzzleSolver; const solution = aStar.solvePuzzle(state); ``` +## Methods +> This library provides only one method: + +### solvePuzzle(initialState) +> Solves the 8 Puzzle Game with provided initial state. + +**Arguments** + +| Argument | Type | Options | +|----------|---------|-------------------| +|`initialState`|*Array of Arrays of Number* | 'Any state possible'| + +**Example** + +```js +const state = [ + [1, 2, 3], + [4, 5, 6], + [7, 0, 8] +]; + +const solution = AStar.solvePuzzle(state); +``` + +**Return** +> This method return an object with: +> - 'state' property: last state visited (the goal state) +> - 'evaluationFunctionValue': an object (wich you can use to access property 'g' that represents the depth traveled) +> - 'previousNode': another Node object with same properties (that you can use to see expanded nodes and operations applied) + +**Obs:** +- For more examples of how to use, see './examples' folder +- The goalState considered by the algorithm is: + +![](./images/goal-state.jpg) + ## Contributing Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. diff --git a/images/goal-state.jpg b/images/goal-state.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1caf4129a2cc3b361ac9335c3243493f8f45dd05 GIT binary patch literal 13707 zcmeHM2{@E%`+vsL$dVKpS;iW17;D0eA))0sp+)wFLC9`0M;J>aSwd72rBkUaN790f z5~CHREG>+sY+-~3W8UwbI$!6c@4CMFmj8AAug~jxdEVFk-p~E}-S>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