Skip to content

Commit 836f53d

Browse files
committed
formatted files
1 parent 076efe6 commit 836f53d

17 files changed

+84
-126
lines changed

src/Maze.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
dx,
3-
dy,
4-
opposite,
5-
} from "./directions.js";
1+
import { dx, dy, opposite } from "./directions.js";
62

73
import mazeString from "./print.js";
84
import display from "./display.js";
@@ -15,7 +11,7 @@ import seedrandom from "./seedrandom.js";
1511

1612
class Maze {
1713
constructor(mazeSettings) {
18-
this.seed = mazeSettings.seed ?? Date.now()
14+
this.seed = mazeSettings.seed ?? Date.now();
1915
this.random = mazeSettings.prng ?? seedrandom(this.seed);
2016
this.width = mazeSettings.width ||
2117
mazeSettings.xSize || mazeSettings.size || mazeSettings.height ||
@@ -367,7 +363,7 @@ class Maze {
367363
}
368364

369365
braid(settings) {
370-
return braid({maze: this });
366+
return braid({ maze: this });
371367
}
372368

373369
getSolution(

src/algorithms/10Print.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import Maze from "../Maze.js";
2-
import {
3-
opposite,
4-
dx,
5-
dy,
6-
} from "../directions.js";
2+
import { dx, dy, opposite } from "../directions.js";
73

84
class TenPrint extends Maze {
95
resetVariables() {

src/algorithms/AldousBroder.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import Maze from "../Maze.js";
2-
import {
3-
dx,
4-
dy,
5-
} from "../directions.js";
2+
import { dx, dy } from "../directions.js";
63

74
class AldousBroder extends Maze {
85
//called when the maze is intitalized

src/algorithms/HuntAndKill.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import Maze from "../Maze.js";
2-
import {
3-
dx,
4-
dy,
5-
} from "../directions.js";
2+
import { dx, dy } from "../directions.js";
63

74
class HuntAndKill extends Maze {
85
resetVariables() {

src/algorithms/Kruskals.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import Maze from "../Maze.js";
2-
import {
3-
dx,
4-
dy,
5-
} from "../directions.js";
2+
import { dx, dy } from "../directions.js";
63

74
class Kruskals extends Maze {
85
resetVariables() {

src/algorithms/ModifiedPrims.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import Maze from "../Maze.js";
2-
import {
3-
dx,
4-
dy,
5-
directions,
6-
} from "../directions.js";
2+
import { directions, dx, dy } from "../directions.js";
73

84
class ModifiedPrims extends Maze {
95
resetVariables() {

src/algorithms/RecursiveBacktracker.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import Maze from "../Maze.js";
2-
import {
3-
dx,
4-
dy,
5-
directions,
6-
} from "../directions.js";
2+
import { directions, dx, dy } from "../directions.js";
73

84
class RecursiveBacktracker extends Maze {
95
resetVariables() {

src/algorithms/RecursiveDivision.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,9 @@ class RecursiveDivision extends Maze {
116116
// where will the passage through the wall exist?
117117
let passage = {
118118
x: (this.wallStartCell.x +
119-
(this.horizontal
120-
? Math.floor(this.random() * this.region.width)
121-
: 0)),
119+
(this.horizontal ? Math.floor(this.random() * this.region.width) : 0)),
122120
y: (this.wallStartCell.y +
123-
(this.horizontal ? 0
124-
: Math.floor(this.random() * this.region.height))),
121+
(this.horizontal ? 0 : Math.floor(this.random() * this.region.height))),
125122
};
126123

127124
this.removeWall(passage, this.dir);

src/algorithms/Sidewinder.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ class Sidewinder extends Maze {
2828

2929
//carve north
3030
} else {
31-
let cell =
32-
this.runSet[Math.floor(this.random() * this.runSet.length)];
31+
let cell = this.runSet[Math.floor(this.random() * this.runSet.length)];
3332
this.removeWall(cell, "N");
3433
this.runSet = [];
3534
}

src/algorithms/SimplifiedPrims.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import Maze from "../Maze.js";
2-
import {
3-
dx,
4-
dy,
5-
directions,
6-
} from "../directions.js";
2+
import { directions, dx, dy } from "../directions.js";
73

84
class SimplifiedPrims extends Maze {
95
resetVariables() {

src/algorithms/TruePrims.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import Maze from "../Maze.js";
2-
import {
3-
dx,
4-
dy,
5-
directions,
6-
opposite,
7-
} from "../directions.js";
2+
import { directions, dx, dy, opposite } from "../directions.js";
83

94
class TruePrims extends Maze {
105
resetVariables() {

src/algorithms/Wilsons.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import Maze from "../Maze.js";
2-
import {
3-
dx,
4-
dy,
5-
opposite,
6-
directions,
7-
} from "../directions.js";
2+
import { directions, dx, dy, opposite } from "../directions.js";
83

94
class Wilsons extends Maze {
105
resetVariables() {

src/analyze.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { opposite, directions, fullNames } from "./directions.js";
1+
import { directions, fullNames, opposite } from "./directions.js";
22

33
export default function analyze(maze) {
44
let solution = maze.getSolution();

src/braid.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
import {
2-
opposite,
3-
directions,
4-
fullNames,
5-
dx,
6-
dy
7-
} from "./directions.js";
1+
import { directions, dx, dy, fullNames, opposite } from "./directions.js";
82

93
export default function braid({
10-
maze
4+
maze,
115
}) {
12-
136
let deadEnds = [];
147
maze.walls.forEach((row, y) => {
158
row.forEach((cell, x) => {
@@ -21,8 +14,8 @@ export default function braid({
2114
deadEnds.push({
2215
x,
2316
y,
24-
direction: opposite[connectedDirections[0]]
25-
})
17+
direction: opposite[connectedDirections[0]],
18+
});
2619
}
2720
});
2821
});
@@ -41,19 +34,25 @@ export default function braid({
4134
for (let direction of directions) {
4235
let neighbor = {
4336
x: deadEnd.x + dx[direction],
44-
y: deadEnd.y + dy[direction]
45-
}
46-
if (direction != opposite[deadEnd.direction] && maze.cellIsInMaze(neighbor)) {
37+
y: deadEnd.y + dy[direction],
38+
};
39+
if (
40+
direction != opposite[deadEnd.direction] &&
41+
maze.cellIsInMaze(neighbor)
42+
) {
4743
unconnectedNeighbors.push({
4844
...neighbor,
49-
direction
45+
direction,
5046
});
5147
}
5248
}
5349

54-
let chosenNeighbor = unconnectedNeighbors[Math.floor(maze.random() * unconnectedNeighbors.length)];
50+
let chosenNeighbor =
51+
unconnectedNeighbors[
52+
Math.floor(maze.random() * unconnectedNeighbors.length)
53+
];
5554
maze.removeWall(deadEnd, chosenNeighbor.direction);
5655
}
5756
}
5857
return maze;
59-
}
58+
}

src/distances.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
dx,
3-
dy,
4-
} from "./directions.js";
1+
import { dx, dy } from "./directions.js";
52

63
export default function calculateDistances(distanceFrom) {
74
let Q = []; //queue

src/seedrandom.js

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,37 @@ const global = globalThis;
2727
const pool = []; //entropy pool starts empty
2828
const math = Math; //package containing random, pow, and seedrandom
2929

30-
3130
// The following constants are related to IEEE 754 limits.
3231
const width = 256, // each RC4 output is 0 <= x < 256
3332
chunks = 6, // at least six RC4 outputs for each double
3433
digits = 52, // there are 52 significant digits in a double
35-
rngname = 'random', // rngname: name for Math.random and Math.seedrandom
34+
rngname = "random", // rngname: name for Math.random and Math.seedrandom
3635
startdenom = math.pow(width, chunks),
3736
significance = math.pow(2, digits),
3837
overflow = significance * 2,
3938
mask = width - 1;
40-
//nodecrypto; // node.js crypto module, initialized at the bottom.
39+
//nodecrypto; // node.js crypto module, initialized at the bottom.
4140

4241
function seedrandom(seed, options, callback) {
4342
const key = [];
44-
options = (options == true) ? {
45-
entropy: true
46-
} : (options || {});
43+
options = (options == true)
44+
? {
45+
entropy: true,
46+
}
47+
: (options || {});
4748

4849
// Flatten the seed string or build one from local entropy if needed.
49-
const shortseed = mixkey(flatten(
50-
options.entropy ? [seed, tostring(pool)] :
51-
(seed == null) ? autoseed() : seed, 3), key);
50+
const shortseed = mixkey(
51+
flatten(
52+
options.entropy
53+
? [seed, tostring(pool)]
54+
: (seed == null)
55+
? autoseed()
56+
: seed,
57+
3,
58+
),
59+
key,
60+
);
5261

5362
// Use the seed to initialize an ARC4 generator.
5463
const arc4 = new ARC4(key);
@@ -74,10 +83,10 @@ function seedrandom(seed, options, callback) {
7483

7584
prng.int32 = function () {
7685
return arc4.g(4) | 0;
77-
}
86+
};
7887
prng.quick = function () {
7988
return arc4.g(4) / 0x100000000;
80-
}
89+
};
8190
prng.double = prng;
8291

8392
// Mix the randomness into accumulated entropy.
@@ -94,24 +103,23 @@ function seedrandom(seed, options, callback) {
94103
// Only provide the .state method if requested via options.state.
95104
prng.state = function () {
96105
return copy(arc4, {});
97-
}
106+
};
98107
}
99108

100109
/* If called as a method of Math (Math.seedrandom()), mutate
101110
Math.random because that is how seedrandom.js has worked since v1.0. */
102111
if (is_math_call) {
103112
math[rngname] = prng;
104113
return seed;
105-
}
106-
107-
/* Otherwise, it is a newer calling convention, so return the
114+
} /* Otherwise, it is a newer calling convention, so return the
108115
prng directly. */
109116
else return prng;
110117
})(
111-
prng,
112-
shortseed,
113-
'global' in options ? options.global : (this == math),
114-
options.state);
118+
prng,
119+
shortseed,
120+
"global" in options ? options.global : (this == math),
121+
options.state,
122+
);
115123
}
116124

117125
/*
@@ -175,24 +183,23 @@ function copy(f, t) {
175183
t.j = f.j;
176184
t.S = f.S.slice();
177185
return t;
178-
};
179-
180-
//
186+
}//
181187
// flatten()
182188
// Converts an object tree to nested arrays of strings.
183189
//
190+
184191
function flatten(obj, depth) {
185192
const result = [],
186193
typ = (typeof obj);
187194
let prop;
188-
if (depth && typ == 'object') {
195+
if (depth && typ == "object") {
189196
for (prop in obj) {
190197
try {
191198
result.push(flatten(obj[prop], depth - 1));
192199
} catch (e) {}
193200
}
194201
}
195-
return (result.length ? result : typ == 'string' ? obj : obj + '\0');
202+
return (result.length ? result : typ == "string" ? obj : obj + "\0");
196203
}
197204

198205
//
@@ -204,8 +211,8 @@ function mixkey(seed, key) {
204211
const stringseed = String(seed);
205212
let smear, j = 0;
206213
while (j < stringseed.length) {
207-
key[mask & j] =
208-
mask & ((smear ^= key[mask & j] * 19) + stringseed.charCodeAt(j++));
214+
key[mask & j] = mask &
215+
((smear ^= key[mask & j] * 19) + stringseed.charCodeAt(j++));
209216
}
210217
return tostring(key);
211218
}
@@ -229,7 +236,7 @@ function autoseed() {
229236
} catch (e) {
230237
const browser = global.navigator,
231238
plugins = browser && browser.plugins;
232-
return [+new Date, global, plugins, global.screen, tostring(pool)];
239+
return [+new Date(), global, plugins, global.screen, tostring(pool)];
233240
}
234241
}
235242

@@ -241,7 +248,6 @@ function tostring(a) {
241248
return String.fromCharCode.apply(0, a);
242249
}
243250

244-
245251
/*
246252
When seedrandom.js is loaded, we immediately mix a few bits
247253
from the built-in RNG into the entropy pool. Because we do
@@ -251,5 +257,4 @@ function tostring(a) {
251257
*/
252258
mixkey(math.random(), pool);
253259

254-
255-
export default seedrandom;
260+
export default seedrandom;

0 commit comments

Comments
 (0)