html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Maze Generator</title>
<link rel="stylesheet" href="style.css">
<script src="Cell.js"></script>
<script src="Seeker.js"></script>
<script src="script.js"></script>
</head>
<body>
<div id="mazeContainer">
<h3>Create a Maze!</h3>
<button onclick="startMazeAlgorithm('depthsFirstBacktracker')">Depth-First Backtracker</button>
<button onclick="startMazeAlgorithm('primsAlgorithm')">Prim's Algorithm</button>
<button onclick="startMazeAlgorithm('kruskalsAlgorithm')">Kruskal's Algorithm</button>
<button onclick="startMazeAlgorithm('recursiveBisection',false)">Recursive Bisection</button>
</div>
<div id="pathContainer">
<h3>Get it solved!</h3>
<button onclick="startPathAlgorithm('randomMouse')">Random Mouse</button>
<button onclick="startPathAlgorithm('wallFollower')">Wall Follower</button>
<button onclick="startPathAlgorithm('splittingAlgorithm')">Splitting Algorithm</button>
</div>
<div id="canvasContainer">
<canvas id="path"></canvas>
<canvas id="maze"></canvas>
</div>
Enter to Rename, Shift+Enter to Preview
css
css
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
body {
background-color: #272822;
color: white;
font-family: Consolas;
font-size: 13px;
margin: 0;
padding: 10px;
}
#canvasContainer{
position: relative;
}
canvas {
/*position: absolute;*/
position: absolute;
top: 0;
left: 0
}
#maze{
}
#path{
background-color: black;
}
Enter to Rename, Shift+Enter to Preview
js
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
function Seeker(startX,startY,targetX,targetY,direction="up"){
this.pos = {
x: startX,
y: startY
}
this.target = {
x: targetX,
y: targetY
}
this.direction = direction;
}
prototype:{
Seeker.prototype.possibleWays = function(){
var ways = 4;
var walls = grid[index(this.pos.x,this.pos.y)].walls;
if(walls.up){
ways--;
}
if(walls.right){
ways--;
}
if(walls.down){
ways--;
}
if(walls.left){
ways--;
}
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run