-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.html
736 lines (623 loc) · 28.3 KB
/
main.html
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
* {
margin: 0;
padding: 0;
}
body {
margin: 1em;
display: flex;
flex-direction: column;
font-size: 5vh;
}
.board {
display: grid;
grid-template-rows: 12vh 12vh 12vh;
grid-template-columns: 12vh 12vh 12vh;
justify-self: center; /* 横方向中央揃え */
align-self: center; /* 縦方向中央揃え */
}
.cell {
position: relative;
background-size: cover;
background-position: center;
font-size: 0;
border: 0.1px solid black;
}
.btn {
display: flex;
align-items: center;
justify-content: center;
}
#btnStart,
#btnManualStart {
font-family: 'Courier Prime', monospace;
width: 36vh;
padding: 1em;
font-size: 2vh;
visibility: visible;
font-weight: bold;
}
#btnAuto,
#btnAutoAStar,
#btnStop,
#btnReturn,
#btnAutoBFS,
#btnAutoDFS {
font-family: 'Courier Prime', monospace;
width: 36vh;
padding: 1em;
font-size: 2vh;
visibility: hidden;
font-weight: bold;
}
.message {
display: flex;
align-items: center;
justify-content: center;
}
.highlight {
border: 2px solid red;
}
</style>
<script>
let cells = null; // セル配列
let mode;
let autoInterval; // Autoボタン用のインターバル
const WAIT = Symbol(); // 待機
const GAME = Symbol(); // ゲーム中
let ManualFlag = false;
// ヒューリスティック値を計算する関数
function calculateHeuristicForBoard(board) {
let heuristic = 0;
for (let i = 0; i < board.length; i++) {
const tile = board[i];
const targetPosition = (tile === 0) ? board.length - 1 : tile - 1;
const currentRow = Math.floor(i / 3);
const currentCol = i % 3;
const targetRow = Math.floor(targetPosition / 3);
const targetCol = targetPosition % 3;
heuristic += Math.abs(currentRow - targetRow) + Math.abs(currentCol - targetCol);
}
return heuristic;
}
// ヒューリスティック値に基づいてタイルをハイライトする関数
function highlightBestMove() {
const emptyIndex = Array.from(cells).findIndex(cell => cell.textContent === "");
const edgeLength = Math.sqrt(cells.length);
const emptyI = Math.floor(emptyIndex / edgeLength);
const emptyJ = emptyIndex % edgeLength;
let minHeuristic = Infinity;
let bestMoveIndex = -1;
cells.forEach((cell, index) => {
cell.classList.remove("highlight");
const tileValue = parseInt(cell.textContent) || 0;
const currentI = Math.floor(index / edgeLength);
const currentJ = index % edgeLength;
// 空白セルの隣接セルのみチェック
if ((Math.abs(currentI - emptyI) === 1 && currentJ === emptyJ) ||
(Math.abs(currentJ - emptyJ) === 1 && currentI === emptyI)) {
let newBoard = Array.from(cells, c => parseInt(c.textContent) || 0);
newBoard[emptyIndex] = tileValue;
newBoard[index] = 0;
const heuristicValue = calculateHeuristicForBoard(newBoard);
if (heuristicValue < minHeuristic) {
minHeuristic = heuristicValue;
bestMoveIndex = index;
}
}
});
if (bestMoveIndex !== -1) {
cells[bestMoveIndex].classList.add("highlight");
}
}
// セルを入れ替える
function swapCell(x, y) {
console.log("入れ替え.");
[cells[x].textContent, cells[y].textContent] = [cells[y].textContent, cells[x].textContent];
[cells[x].style.backgroundImage, cells[y].style.backgroundImage] = [cells[y].style.backgroundImage, cells[x].style.backgroundImage];
// クリアしたか?
checkClear();
}
// セルを入れ替える
function swapCellManual(x, y) {
console.log("入れ替え.");
[cells[x].textContent, cells[y].textContent] = [cells[y].textContent, cells[x].textContent];
[cells[x].style.backgroundImage, cells[y].style.backgroundImage] = [cells[y].style.backgroundImage, cells[x].style.backgroundImage];
// クリアしたか?
highlightBestMove();
checkClear();
}
// セルが入れ替え可能かチェックする
function checkCell(number) {
console.log(ManualFlag)
if (number >= 3 && cells[number - 3].textContent === "") { // 上と入れ替え
if (ManualFlag) {
swapCellManual(number, number - 3);
} else {
swapCell(number, number - 3);
}
}
if (number <= 5 && cells[number + 3].textContent === "") { // 下と入れ替え
if (ManualFlag) {
swapCellManual(number, number + 3);
} else {
swapCell(number, number + 3);
}
}
if (number % 3 !== 2 && cells[number + 1].textContent === "") { // 右と入れ替え
if (ManualFlag) {
swapCellManual(number, number + 1);
} else {
swapCell(number, number + 1);
}
}
if (number % 3 !== 0 && cells[number - 1].textContent === "") { // 左と入れ替え
if (ManualFlag) {
swapCellManual(number, number - 1);
} else {
swapCell(number, number - 1);
}
}
}
// クリアしたか?
function checkClear() {
if (mode === GAME) {
// 1~8に並んでいるか?
let i = 0;
for (; i < cells.length; i++) {
let value = Number(cells[i].textContent);
console.log("textContent: " + value);
if (value !== (i + 1)) break;
}
// 並んでいればクリア!
if (i === 8) {
mode = WAIT;
document.querySelector(".message").textContent = "CLEAR!!";
clearInterval(autoInterval); // クリア時にAutoの動作を停止
clearHighlights(); // ハイライトを消す
}
}
}
// ハイライトをクリアする関数
function clearHighlights() {
cells.forEach(cell => {
cell.classList.remove("highlight");
});
}
// 起動時の処理
window.addEventListener("load", () => {
// ゲームの状態
mode = WAIT;
// 9つのセルを取得
cells = document.querySelectorAll(".cell");
// セルのイベントを設定
for (let cell of cells) {
cell.addEventListener("click", (e) => {
// セルの番号を取得(data-numberプロパティ)
const number = Number(e.currentTarget.dataset.number);
console.log("cells[" + number + "] Click.");
// セルが入れ替え可能か?
checkCell(number);
}, false);
}
// スタートボタン
const btnStart = document.getElementById("btnStart");
const btnManualStart = document.getElementById("btnManualStart");
// Autoボタン
const btnAuto = document.getElementById("btnAuto");
// AutoAStarボタン
const btnAutoAStar = document.getElementById("btnAutoAStar");
const btnStop = document.getElementById("btnStop");
const btnReturn = document.getElementById("btnReturn");
const btnAutoBFS = document.getElementById("btnAutoBFS");
const btnAutoDFS = document.getElementById("btnAutoDFS");
btnManualStart.addEventListener("click", () => {
const shuffleOption = confirm("このまま始めますか?\n「OK」で現在の盤面から、キャンセルでシャッフルして始めます。");
document.querySelector(".message").textContent = shuffleOption ? "現在の盤面から開始" : "シャッフルして開始";
// シャッフルまたは現在の盤面からゲームを開始
startGame(!shuffleOption);
ManualFlag = true;
console.log(ManualFlag)
btnReturn.style.visibility = "visible";
btnStart.style.visibility = "hidden";
btnManualStart.style.visibility = "hidden";
highlightBestMove();
checkClear();
}, false);
btnAutoBFS.addEventListener("click", () => {
document.querySelector(".message").textContent = "BFS"
autoSolveBFS()
});
btnAutoDFS.addEventListener("click", () => {
document.querySelector(".message").textContent = "DFS"
autoSolveDFS()
});
btnReturn.addEventListener("click", () => {
document.querySelector(".message").textContent = ""
btnStart.style.visibility = "visible";
btnManualStart.style.visibility = "visible";
btnAuto.style.visibility = "hidden";
btnAutoAStar.style.visibility = "hidden";
btnStop.style.visibility = "hidden";
btnReturn.style.visibility = "hidden";
btnAutoDFS.style.visibility = "hidden";
btnAutoBFS.style.visibility = "hidden";
ManualFlag = false;
clearInterval(autoInterval);
clearHighlights(); // ハイライトを消す
});
btnStop.addEventListener("click", () => {
document.querySelector(".message").textContent = "Stop";
clearInterval(autoInterval); //動作を停止
});
btnAutoAStar.addEventListener("click", () => {
document.querySelector(".message").textContent = "AutoAStar";
autoSolveAStar();
});
btnAuto.addEventListener("click", () => {
document.querySelector(".message").textContent = "Auto";
// インターバル設定
autoInterval = setInterval(() => {
const r = Math.floor(Math.random() * 9);
checkCell(r);
checkClear();
}, 200);
});
btnStart.addEventListener("click", () => {
const shuffleOption = confirm("このまま始めますか?\n「OK」で現在の盤面から、キャンセルでシャッフルして始めます。");
document.querySelector(".message").textContent = shuffleOption ? "現在の盤面から開始" : "シャッフルして開始";
// シャッフルまたは現在の盤面からゲームを開始
startGame(!shuffleOption);
btnStart.style.visibility = "hidden";
btnManualStart.style.visibility = "hidden";
btnAuto.style.visibility = "visible";
btnAutoAStar.style.visibility = "visible";
btnStop.style.visibility = "visible";
btnReturn.style.visibility = "visible";
btnAutoBFS.style.visibility = "visible";
btnAutoDFS.style.visibility = "visible";
checkClear();
}, false);
});
// ゲーム開始処理
function startGame(shuffle) {
// シャッフルする場合
if (shuffle) {
shuffleBoard();
}
// ゲーム開始
mode = GAME;
}
// シャッフル処理
function shuffleBoard() {
// シャッフル
for (let i = 0; i < 1000; i++) {
const r = Math.floor(Math.random() * 9);
checkCell(r);
}
}
function AStarSolver(initialState) {
class Node {
constructor(board, pre = null, action = null) {
this.board = board;
this.edgeLength = Math.sqrt(board.length);
this.pre = pre;
this.action = action;
this.cost = pre ? pre.cost + 1 : 0;
this.heuristic = this.getHeuristic();
this.score = this.cost + this.heuristic;
}
getHeuristic() {
let ret = 0;
for (let i = 0; i < this.edgeLength; i++) {
for (let j = 0; j < this.edgeLength; j++) {
const t = this.board[i * this.edgeLength + j] - 1;
const target = t === -1 ? this.board.length - 1 : t;
const targetI = Math.floor(target / this.edgeLength);
const targetJ = target % this.edgeLength;
ret += Math.abs(i - targetI) + Math.abs(j - targetJ);
}
}
return ret;
}
}
function isSameBoard(board1) {
// 解の配置を定義
const solution = [1, 2, 3, 4, 5, 6, 7, 8, 0]; // 0 は空白として扱う
// ソートして比較
return board1.join() === solution.join();
}
function isBoardInClosedList(board, closedList) {
return closedList.some(node => isSameBoard(node.board, board));
}
function isBoardInOpenList(board, openList) {
return openList.some(node => isSameBoard(node.board, board));
}
function getNodeWithLowestScore(openList) {
return openList.reduce((minNode, currentNode) => (currentNode.score < minNode.score ? currentNode : minNode), openList[0]);
}
function getNeighbors(node) {
const neighbors = [];
const emptyIndex = node.board.indexOf(0);
console.log(emptyIndex)
function isValidMove(i, j) {
return i >= 0 && i < node.edgeLength && j >= 0 && j < node.edgeLength;
}
const emptyI = Math.floor(emptyIndex / node.edgeLength);
const emptyJ = emptyIndex % node.edgeLength;
const directions = [
{ di: -1, dj: 0 }, // 上
{ di: 1, dj: 0 }, // 下
{ di: 0, dj: -1 }, // 左
{ di: 0, dj: 1 } // 右
];
for (const dir of directions) {
const newI = emptyI + dir.di;
const newJ = emptyJ + dir.dj;
if (isValidMove(newI, newJ)) {
const neighborBoard = [...node.board];
const newIndex = newI * node.edgeLength + newJ;
[neighborBoard[emptyIndex], neighborBoard[newIndex]] = [neighborBoard[newIndex], neighborBoard[emptyIndex]];
neighbors.push(new Node(neighborBoard, node, dir));
}
}
return neighbors;
}
const startNode = new Node(initialState);
const openList = [startNode];
console.log(openList[0])
const closedList = [];
let searchCount = 0;
while (openList.length > 0) {
const currentNode = getNodeWithLowestScore(openList);
if (isSameBoard(currentNode.board)) {
// 解が見つかった
const actions = [];
let backtraceNode = currentNode;
console.log(backtraceNode.pre);
while (backtraceNode.pre) {
actions.unshift(backtraceNode.action);
console.log(actions);
backtraceNode = backtraceNode.pre;
}
return { solved: true, actions, searchCount };
}
openList.splice(openList.indexOf(currentNode), 1);
console.log(openList)
closedList.push(currentNode);
console.log(closedList)
if (searchCount > 10000) {
// サーチ回数が閾値を超えた場合、解が見つからないことを示すために変更
return { solved: false, actions: [], searchCount };
}
const neighbors = getNeighbors(currentNode);
for (const neighbor of neighbors) {
searchCount++;
if (isBoardInClosedList(neighbor.board, closedList)) {
continue;
}
const existingNode = openList.find(node => isSameBoard(node.board, neighbor.board));
if (!existingNode || neighbor.cost < existingNode.cost) {
openList.push(neighbor);
}
}
}
return { solved: false, actions: [], searchCount };
}
// Function to perform a sequence of actions on the puzzle
function performActions(actions) {
actions.forEach(action => {
const emptyCellIndex = Array.from(cells).findIndex(cell => cell.textContent === "");
const targetIndex = getTargetIndex(emptyCellIndex, action);
swapCell(emptyCellIndex, targetIndex);
});
}
// Function to get the target index based on the action
function getTargetIndex(emptyIndex, action) {
const edgeLength = Math.sqrt(cells.length);
const [i, j] = [Math.floor(emptyIndex / edgeLength), emptyIndex % edgeLength];
if (action.di === -1) return (i - 1) * edgeLength + j; // Up
if (action.di === 1) return (i + 1) * edgeLength + j; // Down
if (action.dj === -1) return i * edgeLength + (j - 1); // Left
if (action.dj === 1) return i * edgeLength + (j + 1); // Right
return emptyIndex; // Should not happen
}
function autoSolveAStar() {
clearInterval(autoInterval); // 他の自動動作が実行中であれば停止
const initialState = Array.from(cells, cell => parseInt(cell.textContent) || 0);
const { solved, actions, searchCount } = AStarSolver(initialState);
if (solved) {
mode = WAIT;
document.querySelector(".message").textContent = `A* ${searchCount}手で解けました!!`;
console.log(`A* found a solution in ${searchCount} steps.`);
let step = 0;
autoInterval = setInterval(() => {
if (step < actions.length) {
const action = actions[step];
const emptyCellIndex = Array.from(cells).findIndex(cell => cell.textContent === "");
const targetIndex = getTargetIndex(emptyCellIndex, action);
swapCell(emptyCellIndex, targetIndex);
step++;
} else {
clearInterval(autoInterval); // Stop the interval when all steps are completed
}
}, 500);
} else {
document.querySelector(".message").textContent = `この盤面は解けません`;
console.log(`A* did not find a solution after ${searchCount} steps.`);
}
}
function autoSolveBFS() {
clearInterval(autoInterval); // 他の自動動作が実行中であれば停止
const initialState = Array.from(cells, cell => parseInt(cell.textContent) || 0);
const { solved, actions, searchCount } = breadthFirstSearch(initialState);
if (solved) {
mode = WAIT;
document.querySelector(".message").textContent = `BFS ${searchCount}手で解けました!!`;
console.log(`BFS found a solution in ${searchCount} steps.`);
let step = 0;
autoInterval = setInterval(() => {
if (step < actions.length) {
const action = actions[step];
const emptyCellIndex = Array.from(cells).findIndex(cell => cell.textContent === "");
const targetIndex = getTargetIndex(emptyCellIndex, action);
swapCell(emptyCellIndex, targetIndex);
step++;
} else {
clearInterval(autoInterval); // Stop the interval when all steps are completed
}
}, 500);
} else {
document.querySelector(".message").textContent = `この盤面は解けません`;
console.log(`BFS did not find a solution after ${searchCount} steps.`);
}
}
function breadthFirstSearch(initialState) {
const queue = [{ board: initialState, actions: [] }];
const visited = new Set([initialState.toString()]);
let searchCount = 0;
while (queue.length > 0) {
const currentNode = queue.shift(); // キューからノードを取り出す
const currentBoard = currentNode.board;
if (isSameBoard(currentBoard)) {
// 解が見つかった場合
return { solved: true, actions: currentNode.actions, searchCount };
}
const emptyIndex = currentBoard.indexOf(0);
const neighbors = getNeighbors(currentNode);
if (searchCount > 20000) {
// サーチ回数が閾値を超えた場合、解が見つからないことを示すために変更
return { solved: false, actions: [], searchCount };
}
for (const neighbor of neighbors) {
const neighborBoard = neighbor.board;
const neighborActions = [...currentNode.actions, neighbor.action];
if (!visited.has(neighborBoard.toString())) {
visited.add(neighborBoard.toString());
queue.push({ board: neighborBoard, actions: neighborActions });
}
}
searchCount++;
}
// キューが空になり、解が見つからなかった場合
return { solved: false, actions: [], searchCount };
}
function getNeighbors(node) {
const neighbors = [];
const emptyIndex = node.board.indexOf(0);
const edgeLength = Math.sqrt(node.board.length);
function isValidMove(i, j) {
return i >= 0 && i < edgeLength && j >= 0 && j < edgeLength;
}
const emptyI = Math.floor(emptyIndex / edgeLength);
const emptyJ = emptyIndex % edgeLength;
const directions = [
{ di: -1, dj: 0 }, // 上
{ di: 1, dj: 0 }, // 下
{ di: 0, dj: -1 }, // 左
{ di: 0, dj: 1 } // 右
];
for (const dir of directions) {
const newI = emptyI + dir.di;
const newJ = emptyJ + dir.dj;
if (isValidMove(newI, newJ)) {
const neighborBoard = [...node.board];
const newIndex = newI * edgeLength + newJ;
[neighborBoard[emptyIndex], neighborBoard[newIndex]] = [neighborBoard[newIndex], neighborBoard[emptyIndex]];
neighbors.push({ board: neighborBoard, action: dir });
}
}
return neighbors;
}
function isSameBoard(board) {
// 解の配置を定義
const solution = [1, 2, 3, 4, 5, 6, 7, 8, 0]; // 0 は空白として扱う
// ソートして比較
return board.join() === solution.join();
}
function autoSolveDFS() {
clearInterval(autoInterval); // 他の自動動作が実行中であれば停止
const initialState = Array.from(cells, cell => parseInt(cell.textContent) || 0);
const { solved, actions, searchCount } = depthFirstSearch(initialState);
if (solved) {
mode = WAIT;
document.querySelector(".message").textContent = `DFS ${searchCount}手で解けました!!`;
console.log(`DFS found a solution in ${searchCount} steps.`);
let step = 0;
autoInterval = setInterval(() => {
if (step < actions.length) {
const action = actions[step];
const emptyCellIndex = Array.from(cells).findIndex(cell => cell.textContent === "");
const targetIndex = getTargetIndex(emptyCellIndex, action);
swapCell(emptyCellIndex, targetIndex);
step++;
} else {
clearInterval(autoInterval); // Stop the interval when all steps are completed
}
}, 500);
} else {
document.querySelector(".message").textContent = `この盤面は解けません`;
console.log(`DFS did not find a solution after ${searchCount} steps.`);
}
}
function depthFirstSearch(initialState) {
const stack = [{ board: initialState, actions: [] }];
const visited = new Set([initialState.toString()]);
let searchCount = 0;
while (stack.length > 0) {
const currentNode = stack.pop(); // スタックからノードを取り出す
const currentBoard = currentNode.board;
if (isSameBoard(currentBoard)) {
// 解が見つかった場合
return { solved: true, actions: currentNode.actions, searchCount };
}
const emptyIndex = currentBoard.indexOf(0);
const neighbors = getNeighbors(currentNode);
if (searchCount > 30000) {
// サーチ回数が閾値を超えた場合、解が見つからないことを示すために変更
return { solved: false, actions: [], searchCount };
}
for (const neighbor of neighbors) {
const neighborBoard = neighbor.board;
const neighborActions = [...currentNode.actions, neighbor.action];
if (!visited.has(neighborBoard.toString())) {
visited.add(neighborBoard.toString());
stack.push({ board: neighborBoard, actions: neighborActions });
}
}
searchCount++;
}
// スタックが空になり、解が見つからなかった場合
return { solved: false, actions: [], searchCount };
}
</script>
<title>8puzzle</title>
</head>
<body>
<div class="board">
<div class="cell" data-number="0" style="background-image: url('penguin-9.jpg');">1</div>
<div class="cell" data-number="1" style="background-image: url('penguin-8.jpg');">2</div>
<div class="cell" data-number="2" style="background-image: url('penguin-7.jpg');">3</div>
<div class="cell" data-number="3" style="background-image: url('penguin-6.jpg');">4</div>
<div class="cell" data-number="4" style="background-image: url('penguin-5.jpg');">5</div>
<div class="cell" data-number="5" style="background-image: url('penguin-4.jpg');">6</div>
<div class="cell" data-number="6" style="background-image: url('penguin-3.jpg');">7</div>
<div class="cell" data-number="7" style="background-image: url('penguin-2.jpg');">8</div>
<div class="cell" data-number="8" style="background-image: url('black.jpg');"></div>
</div>
<div class="btn"><button id="btnStart">AUTO START</button></div>
<div class="btn"><button id="btnManualStart">Manual START</button></div>
<div class="btn"><button id="btnReturn">Return StartScreen</button></div>
<div class="btn"><button id="btnAuto">RANDOM</button></div>
<div class="btn"><button id="btnAutoAStar">AStar</button></div>
<div class="btn"><button id="btnAutoBFS">BFS</button></div>
<div class="btn"><button id="btnAutoDFS">DFS</button></div>
<div class="btn"><button id="btnStop">Stop</button></div>
<div class="message"></div>
</body>
</html>