Skip to content

Commit

Permalink
Update README (add methods section)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreKavalerski committed Jul 7, 2020
1 parent 4543a14 commit b8f6c68
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
Binary file added images/goal-state.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b8f6c68

Please sign in to comment.