Skip to content

Commit 2d47a19

Browse files
small changes
1 parent fbdc519 commit 2d47a19

File tree

7 files changed

+36
-21
lines changed

7 files changed

+36
-21
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66
## [1.X.X] - 2020-XX-XX
77
### Added
88
### Changed
9+
- Introduce const for let where possible
10+
- Small changes in LICENSE and README
11+
912
### Fixed
1013

1114
---

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 digitsensitive
3+
Copyright (c) 2017 - 2020 digitsensitive <digit.sensitivee@gmail.com>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,22 @@ More informations about the format options can be found [here](https://prettier.
195195

196196
[MIT License](https://opensource.org/licenses/mit-license.php)
197197

198-
© 2017-2020 digitsensitive <digit.sensitivee@gmail.com>
199-
200-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
201-
202-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
203-
204-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
198+
Copyright (c) 2017 - 2020 digitsensitive <digit.sensitivee@gmail.com>
199+
200+
Permission is hereby granted, free of charge, to any person obtaining a copy
201+
of this software and associated documentation files (the "Software"), to deal
202+
in the Software without restriction, including without limitation the rights
203+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
204+
copies of the Software, and to permit persons to whom the Software is
205+
furnished to do so, subject to the following conditions:
206+
207+
The above copyright notice and this permission notice shall be included in all
208+
copies or substantial portions of the Software.
209+
210+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
211+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
212+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
213+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
214+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
215+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
216+
SOFTWARE.

lib/core/grid.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class Grid {
4444
height: number,
4545
densityOfObstacles?: number
4646
): Node[][] {
47-
let newGrid: Node[][] = [];
47+
const newGrid: Node[][] = [];
4848
let id: number = 0;
4949

5050
// Generate an empty matrix
@@ -67,7 +67,7 @@ export class Grid {
6767
if (matrix === undefined) {
6868
for (let y = 0; y < height; y++) {
6969
for (let x = 0; x < width; x++) {
70-
let rndNumber = Math.floor(Math.random() * 10) + 1;
70+
const rndNumber = Math.floor(Math.random() * 10) + 1;
7171
if (rndNumber > 10 - densityOfObstacles) {
7272
newGrid[y][x].setIsWalkable(false);
7373
} else {
@@ -135,7 +135,7 @@ export class Grid {
135135
currentPosition: IPoint,
136136
diagnonalMovementAllowed: boolean
137137
): Node[] {
138-
let surroundingNodes: Node[] = [];
138+
const surroundingNodes: Node[] = [];
139139

140140
for (var y = currentPosition.y - 1; y <= currentPosition.y + 1; y++) {
141141
for (var x = currentPosition.x - 1; x <= currentPosition.x + 1; x++) {
@@ -189,7 +189,7 @@ export class Grid {
189189
* Get a clone of the grid
190190
*/
191191
public clone(): Node[][] {
192-
let cloneGrid: Node[][] = [];
192+
const cloneGrid: Node[][] = [];
193193
let id: number = 0;
194194

195195
for (let y = 0; y < this.height; y++) {

lib/core/heuristic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export function calculateHeuristic(
2323
pos1,
2424
weight
2525
): number {
26-
let dx = Math.abs(pos1.x - pos0.x);
27-
let dy = Math.abs(pos1.y - pos0.y);
26+
const dx = Math.abs(pos1.x - pos0.x);
27+
const dy = Math.abs(pos1.y - pos0.y);
2828

2929
switch (heuristicFunction) {
3030
case 'Manhatten':

lib/core/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function backtrace(
1111
includeEndNode: boolean
1212
): number[][] {
1313
// Init empty path
14-
let path: number[][] = [];
14+
const path: number[][] = [];
1515

1616
let currentNode: Node;
1717
if (includeEndNode) {

lib/finders/astar-finder.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ export class AStarFinder {
6565
// Reset grid
6666
this.grid.resetGrid();
6767

68-
let startNode = this.grid.getNodeAt(startPosition);
69-
let endNode = this.grid.getNodeAt(endPosition);
68+
const startNode = this.grid.getNodeAt(startPosition);
69+
const endNode = this.grid.getNodeAt(endPosition);
7070

7171
// Break if start and/or end position is/are not walkable
7272
if (
@@ -112,7 +112,7 @@ export class AStarFinder {
112112
// As long the open list is not empty, continue searching a path
113113
while (this.openList.length !== 0) {
114114
// Get node with lowest f value
115-
let currentNode = _.minBy(this.openList, (o) => {
115+
const currentNode = _.minBy(this.openList, (o) => {
116116
return o.getFValue();
117117
});
118118

@@ -129,22 +129,22 @@ export class AStarFinder {
129129
}
130130

131131
// Get neighbors
132-
let neighbors = this.grid.getSurroundingNodes(
132+
const neighbors = this.grid.getSurroundingNodes(
133133
currentNode.position,
134134
this.diagonalAllowed
135135
);
136136

137137
// Loop through all the neighbors
138138
for (let i in neighbors) {
139-
let neightbor = neighbors[i];
139+
const neightbor = neighbors[i];
140140

141141
// Continue if node on closed list
142142
if (neightbor.getIsOnClosedList()) {
143143
continue;
144144
}
145145

146146
// Calculate the g value of the neightbor
147-
let nextGValue =
147+
const nextGValue =
148148
currentNode.getGValue() +
149149
(neightbor.position.x !== currentNode.position.x ||
150150
neightbor.position.y! == currentNode.position.y

0 commit comments

Comments
 (0)