-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameSolver.js
45 lines (41 loc) · 1.03 KB
/
GameSolver.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import Solver3X from "./Solver3X";
export default class GameSolver {
solverSize = 3;
/** @type Game*/
game;
/** @type BaseSolver */
solver;
constructor(game) {
this.game = game;
this.#init();
}
#init() {
switch (this.solverSize) {
case 3:
this.solver = new Solver3X(this.game);
break;
}
/** @type GameListener */
let gameListener = {
OnSolvingStart: () => {
console.log('Start solving');
},
OnSolvingEnd: () => {
console.log('End solving');
},
OnSolvingSuccess: (moves) => {
console.log('Solving success', moves);
},
OnSolvingFailed: () => {
console.log('Solving fail');
}
}
if (typeof this.solver === 'undefined') {
return;
}
this.solver.gameListener = gameListener;
}
start() {
this.solver.solve();
}
}