generated from darkaqua/node-with-typescript
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
6,417 additions
and
932 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,61 @@ | ||
# node with typescript | ||
# pathfinding.ts | ||
|
||
## How to: | ||
1. **Download the zip** or execute `git clone https://github.com/darkaqua/node-with-typescript` in the terminal | ||
2. Run `npm install` in the **/node-with-typescript** directory | ||
3. Run `npm start` and test if the hello world works. | ||
4. Remove this shit and start your project with ts! :3 | ||
Finders: | ||
- [x] Jump Point - No Diagonal Movement | ||
|
||
### Grid example | ||
Jump point: 10 | ||
```ts | ||
const grid = new Grid([ | ||
[50, 55, 60, 65, 70], | ||
[45, 0, 0, 0, 75], | ||
[40, 0, 0, 0, 1 ],//x4y2 | ||
[35, 0, 0, 0, 5 ], | ||
[30, 25, 20, 15, 10], | ||
]); | ||
``` | ||
#### PF example 1 | ||
```ts | ||
grid.findPath( | ||
{ x: 4, y: 2 }, | ||
{ x: 4, y: 1 }, | ||
10, | ||
FinderEnum.JUMP_POINT | ||
); | ||
``` | ||
```js | ||
[ | ||
{ x: 4, y: 2 }, | ||
{ x: 4, y: 4 }, | ||
{ x: 0, y: 4 }, | ||
{ x: 0, y: 0 }, | ||
{ x: 4, y: 0 }, | ||
{ x: 4, y: 1 } | ||
] | ||
|
||
``` | ||
#### PF example 2 | ||
```ts | ||
grid.findPath( | ||
{ x: 4, y: 2 }, | ||
{ x: 4, y: 1 }, | ||
1 | ||
); | ||
``` | ||
```js | ||
[ ] | ||
``` | ||
#### PF example 3 | ||
```ts | ||
grid.findPath( | ||
{ x: 4, y: 2 }, | ||
{ x: 4, y: 1 }, | ||
85 | ||
); | ||
``` | ||
```js | ||
[ | ||
{ x: 4, y: 2 }, | ||
{ x: 4, y: 1 } | ||
] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import {Grid} from "../src"; | ||
|
||
describe('test path finding', () => { | ||
|
||
const grid = new Grid([ | ||
[50, 55, 60, 65, 70], | ||
[45, 0, 0, 0, 75], | ||
[40, 0, 0, 0, 1 ], | ||
[35, 0, 0, 0, 5 ], | ||
[30, 25, 20, 15, 10], | ||
]); | ||
|
||
it('validates pf {test 1}', () => { | ||
const path = grid.findPath( | ||
{ x: 4, y: 2 }, | ||
{ x: 4, y: 1 } | ||
) | ||
expect(path).toEqual([ | ||
{x: 4, y: 2}, | ||
{x: 4, y: 4}, | ||
{x: 0, y: 4}, | ||
{x: 0, y: 0}, | ||
{x: 4, y: 0}, | ||
{x: 4, y: 1} | ||
]); | ||
}); | ||
|
||
it('validates pf {test 2}', () => { | ||
const path = grid.findPath( | ||
{ x: 4, y: 2 }, | ||
{ x: 4, y: 1 }, | ||
10 | ||
) | ||
expect(path).toEqual([ | ||
{x: 4, y: 2}, | ||
{x: 4, y: 4}, | ||
{x: 0, y: 4}, | ||
{x: 0, y: 0}, | ||
{x: 4, y: 0}, | ||
{x: 4, y: 1} | ||
]); | ||
}); | ||
|
||
it('validates pf {test 3}', () => { | ||
const path = grid.findPath( | ||
{ x: 4, y: 2 }, | ||
{ x: 4, y: 1 }, | ||
100 | ||
) | ||
expect(path).toEqual([ | ||
{ x: 4, y: 2 }, | ||
{ x: 4, y: 1 } | ||
]); | ||
}); | ||
|
||
it('validates pf {test 4}', () => { | ||
const path = grid.findPath( | ||
{ x: 4, y: 2 }, | ||
{ x: 4, y: 1 }, | ||
1 | ||
) | ||
expect(path).toEqual([]); | ||
}); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module.exports = { | ||
presets: [ | ||
[ | ||
'@babel/env', | ||
{ | ||
targets: { | ||
node: 'current' | ||
} | ||
} | ||
], | ||
'@babel/typescript' | ||
], | ||
plugins: [ | ||
["@babel/plugin-transform-typescript", { "allowNamespaces": true }] | ||
] | ||
}; |
Oops, something went wrong.