Spaces:
Sleeping
Sleeping
Delete front.html
Browse files- front.html +0 -79
front.html
DELETED
@@ -1,79 +0,0 @@
|
|
1 |
-
<!-- templates/index.html -->
|
2 |
-
|
3 |
-
<!DOCTYPE html>
|
4 |
-
<html lang="en">
|
5 |
-
<head>
|
6 |
-
<meta charset="UTF-8">
|
7 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
8 |
-
<title>Maze Navigation</title>
|
9 |
-
<style>
|
10 |
-
.maze {
|
11 |
-
display: grid;
|
12 |
-
grid-template-columns: repeat(5, 50px);
|
13 |
-
grid-template-rows: repeat(5, 50px);
|
14 |
-
gap: 2px;
|
15 |
-
}
|
16 |
-
.cell {
|
17 |
-
width: 50px;
|
18 |
-
height: 50px;
|
19 |
-
background-color: white;
|
20 |
-
border: 1px solid black;
|
21 |
-
}
|
22 |
-
.wall {
|
23 |
-
background-color: black;
|
24 |
-
}
|
25 |
-
.agent {
|
26 |
-
background-color: blue;
|
27 |
-
}
|
28 |
-
.target {
|
29 |
-
background-color: green;
|
30 |
-
}
|
31 |
-
</style>
|
32 |
-
</head>
|
33 |
-
<body>
|
34 |
-
<div class="maze" id="maze"></div>
|
35 |
-
<button id="step-button">Take a Step</button>
|
36 |
-
<script>
|
37 |
-
const mazeElement = document.getElementById('maze');
|
38 |
-
const stepButton = document.getElementById('step-button');
|
39 |
-
|
40 |
-
let maze = [];
|
41 |
-
let agentPosition = [0, 0];
|
42 |
-
let target = [4, 4];
|
43 |
-
|
44 |
-
function drawMaze() {
|
45 |
-
mazeElement.innerHTML = '';
|
46 |
-
maze.forEach((row, y) => {
|
47 |
-
row.forEach((cell, x) => {
|
48 |
-
const cellElement = document.createElement('div');
|
49 |
-
cellElement.classList.add('cell');
|
50 |
-
if (cell === 1) {
|
51 |
-
cellElement.classList.add('wall');
|
52 |
-
}
|
53 |
-
if (x === agentPosition[0] && y === agentPosition[1]) {
|
54 |
-
cellElement.classList.add('agent');
|
55 |
-
}
|
56 |
-
if (x === target[0] && y === target[1]) {
|
57 |
-
cellElement.classList.add('target');
|
58 |
-
}
|
59 |
-
mazeElement.appendChild(cellElement);
|
60 |
-
});
|
61 |
-
});
|
62 |
-
}
|
63 |
-
|
64 |
-
async function fetchMaze() {
|
65 |
-
const response = await fetch('/step');
|
66 |
-
const data = await response.json();
|
67 |
-
maze = data.maze;
|
68 |
-
agentPosition = data.agent_position;
|
69 |
-
target = data.target;
|
70 |
-
drawMaze();
|
71 |
-
}
|
72 |
-
|
73 |
-
stepButton.addEventListener('click', fetchMaze);
|
74 |
-
|
75 |
-
// Initial draw
|
76 |
-
fetchMaze();
|
77 |
-
</script>
|
78 |
-
</body>
|
79 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|