-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
106 lines (95 loc) · 4.77 KB
/
index.html
File metadata and controls
106 lines (95 loc) · 4.77 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Snake Evolution</title>
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;700&display=swap" rel="stylesheet">
</head>
<body>
<div class="container">
<header>
<h2>Snake Genetics Algorithm</h1>
<p>Genetic Algorithm Neural Network learning to play Snake</p>
<a href="https://github.com/BinaryMasc/Snake_GeneticsAlgorithm"
style="color: white; text-decoration: none;">Code on Github</a>
</header>
<div class="main-content">
<div class="canvas-container">
<canvas id="gameCanvas" width="600" height="600"></canvas>
<div class="panel network">
<h2>Best Brain</h2>
<canvas id="nnCanvas" width="200" height="200"
style="width:100%; background:var(--canvas-bg); border-radius: 8px;"></canvas>
</div>
</div>
<div class="sidebar">
<div class="panel controls">
<h2>Controls</h2>
<button id="btn-run" class="btn primary">Run / Pause</button>
<!-- <button id="btn-next" class="btn secondary">Next Generation</button> -->
<div class="slider-group">
<label for="speed-slider">Simulation Speed: <span id="speed-val">1x</span></label>
<input type="range" id="speed-slider" min="1" max="100" value="1">
</div>
<div class="input-group checkbox-group"
style="margin-top: 15px; display: flex; align-items: center;">
<input type="checkbox" id="check-only-best" style="width: auto; margin-right: 8px;">
<label for="check-only-best" style="margin-bottom: 0; cursor: pointer;">Only show best
snake</label>
</div>
</div>
<div class="panel settings">
<h2>Settings</h2>
<div class="input-group">
<label for="input-pop">Population Size:</label>
<input type="number" id="input-pop" min="10" max="1000" value="100" readonly>
</div>
<div class="input-group">
<label for="input-mut">Mutation Rate (%):</label>
<input type="number" id="input-mut" min="1" max="100" value="5">
</div>
<div class="input-group">
<label for="input-hidden">Number of Neurons by hidden layer:</label>
<input type="number" id="input-hidden" min="4" max="64" value="20">
</div>
<div class="input-group">
<label for="select-crossover">Crossover Type:</label>
<select id="select-crossover" style="width: 100%; padding: 8px; border: 1px solid var(--border-color); border-radius: 4px; background: var(--panel-bg); color: var(--text-color);">
<option value="weight">By Weight</option>
<option value="neuron">By Neuron</option>
</select>
</div>
<button id="btn-restart" class="btn danger" style="margin-top: 10px;">Restart Simulation</button>
</div>
<div class="panel stats">
<h2>Statistics</h2>
<div class="stat-row">
<span class="label">Generation:</span>
<span class="value" id="stat-gen">1</span>
</div>
<div class="stat-row">
<span class="label">Alive:</span>
<span class="value" id="stat-alive">0 / 0</span>
</div>
<div class="stat-row">
<span class="label">Best Fitness:</span>
<span class="value" id="stat-fitness">0</span>
</div>
<div class="stat-row">
<span class="label">Global Best Fitness:</span>
<span class="value" id="stat-global-fitness">0</span>
</div>
</div>
</div>
</div>
</div>
<!-- Scripts -->
<script src="matrix.js"></script>
<script src="nn.js"></script>
<script src="snake.js"></script>
<script src="population.js"></script>
<script src="main.js"></script>
</body>
</html>