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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>ANN CHESS RL TRAINER v3.0</title>
|
| 7 |
+
|
| 8 |
+
<!-- TensorFlow.js for real ML -->
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@4.10.0/dist/tf.min.js"></script>
|
| 10 |
+
|
| 11 |
+
<!-- Chess.js for game logic -->
|
| 12 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/chess.js/0.12.0/chess.min.js"></script>
|
| 13 |
+
|
| 14 |
+
<!-- JSZip for export -->
|
| 15 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
|
| 16 |
+
|
| 17 |
+
<!-- Font Awesome -->
|
| 18 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 19 |
+
|
| 20 |
+
<style>
|
| 21 |
+
:root {
|
| 22 |
+
--neon-green: #39FF14;
|
| 23 |
+
--neon-blue: #00F3FF;
|
| 24 |
+
--neon-purple: #aa00ff;
|
| 25 |
+
--neon-red: #ff073a;
|
| 26 |
+
--neon-yellow: #ffd300;
|
| 27 |
+
--dark-bg: #0a0a0a;
|
| 28 |
+
--panel-bg: rgba(15, 15, 15, 0.95);
|
| 29 |
+
--grid-bg: rgba(0, 20, 0, 0.3);
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
* {
|
| 33 |
+
margin: 0;
|
| 34 |
+
padding: 0;
|
| 35 |
+
box-sizing: border-box;
|
| 36 |
+
font-family: 'Courier New', monospace;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
body {
|
| 40 |
+
background: var(--dark-bg);
|
| 41 |
+
color: var(--neon-green);
|
| 42 |
+
overflow: hidden;
|
| 43 |
+
height: 100vh;
|
| 44 |
+
position: relative;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/* Quantum Field Background */
|
| 48 |
+
#quantum-field {
|
| 49 |
+
position: fixed;
|
| 50 |
+
top: 0;
|
| 51 |
+
left: 0;
|
| 52 |
+
width: 100%;
|
| 53 |
+
height: 100%;
|
| 54 |
+
pointer-events: none;
|
| 55 |
+
z-index: -1;
|
| 56 |
+
opacity: 0.3;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/* Loading Screen */
|
| 60 |
+
#loading-screen {
|
| 61 |
+
position: fixed;
|
| 62 |
+
top: 0;
|
| 63 |
+
left: 0;
|
| 64 |
+
width: 100%;
|
| 65 |
+
height: 100%;
|
| 66 |
+
background: var(--dark-bg);
|
| 67 |
+
display: flex;
|
| 68 |
+
flex-direction: column;
|
| 69 |
+
justify-content: center;
|
| 70 |
+
align-items: center;
|
| 71 |
+
z-index: 9999;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
.glitch-text {
|
| 75 |
+
font-size: 3rem;
|
| 76 |
+
font-weight: bold;
|
| 77 |
+
text-transform: uppercase;
|
| 78 |
+
position: relative;
|
| 79 |
+
color: var(--neon-green);
|
| 80 |
+
text-shadow: 0.05em 0 0 var(--neon-green), -0.05em -0.025em 0 var(--neon-purple);
|
| 81 |
+
animation: glitch 1s infinite;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
@keyframes glitch {
|
| 85 |
+
0% { transform: translate(0); }
|
| 86 |
+
20% { transform: translate(-2px, 2px); }
|
| 87 |
+
40% { transform: translate(-2px, -2px); }
|
| 88 |
+
60% { transform: translate(2px, 2px); }
|
| 89 |
+
80% { transform: translate(2px, -2px); }
|
| 90 |
+
100% { transform: translate(0); }
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
.loading-subtitle {
|
| 94 |
+
font-size: 1.2rem;
|
| 95 |
+
margin: 2rem 0;
|
| 96 |
+
color: var(--neon-blue);
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
.loading-progress {
|
| 100 |
+
width: 400px;
|
| 101 |
+
height: 8px;
|
| 102 |
+
background: rgba(57, 255, 20, 0.2);
|
| 103 |
+
border-radius: 4px;
|
| 104 |
+
overflow: hidden;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
.loading-bar {
|
| 108 |
+
height: 100%;
|
| 109 |
+
background: linear-gradient(90deg, var(--neon-green), var(--neon-blue));
|
| 110 |
+
width: 0%;
|
| 111 |
+
transition: width 0.5s;
|
| 112 |
+
box-shadow: 0 0 10px var(--neon-green);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
/* Main Container */
|
| 116 |
+
.container {
|
| 117 |
+
display: flex;
|
| 118 |
+
height: 100vh;
|
| 119 |
+
padding: 10px;
|
| 120 |
+
gap: 10px;
|
| 121 |
+
opacity: 0;
|
| 122 |
+
transition: opacity 1s;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
/* Side Panels */
|
| 126 |
+
.panel {
|
| 127 |
+
flex: 1;
|
| 128 |
+
background: var(--panel-bg);
|
| 129 |
+
border: 1px solid var(--neon-green);
|
| 130 |
+
border-radius: 8px;
|
| 131 |
+
padding: 15px;
|
| 132 |
+
display: flex;
|
| 133 |
+
flex-direction: column;
|
| 134 |
+
min-width: 320px;
|
| 135 |
+
box-shadow: 0 0 20px rgba(0, 255, 0, 0.1);
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
.black-panel {
|
| 139 |
+
border-color: #fff;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
.green-panel {
|
| 143 |
+
border-color: var(--neon-green);
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
.panel-title {
|
| 147 |
+
text-align: center;
|
| 148 |
+
font-size: 1.2rem;
|
| 149 |
+
margin-bottom: 15px;
|
| 150 |
+
color: var(--neon-green);
|
| 151 |
+
text-shadow: 0 0 10px currentColor;
|
| 152 |
+
padding-bottom: 8px;
|
| 153 |
+
border-bottom: 2px solid currentColor;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
.black-panel .panel-title {
|
| 157 |
+
color: #fff;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
.green-panel .panel-title {
|
| 161 |
+
color: var(--neon-green);
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
/* Metric Grids */
|
| 165 |
+
.metric-grid {
|
| 166 |
+
display: grid;
|
| 167 |
+
grid-template-columns: repeat(2, 1fr);
|
| 168 |
+
gap: 10px;
|
| 169 |
+
margin-bottom: 15px;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
.metric-card {
|
| 173 |
+
background: rgba(0, 30, 0, 0.3);
|
| 174 |
+
border: 1px solid rgba(0, 255, 0, 0.2);
|
| 175 |
+
border-radius: 6px;
|
| 176 |
+
padding: 10px;
|
| 177 |
+
transition: all 0.3s;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
.black-panel .metric-card {
|
| 181 |
+
border-color: rgba(255, 255, 255, 0.2);
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
.metric-card:hover {
|
| 185 |
+
border-color: currentColor;
|
| 186 |
+
box-shadow: 0 0 15px rgba(0, 255, 0, 0.3);
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
.metric-label {
|
| 190 |
+
font-size: 0.8rem;
|
| 191 |
+
color: #aaa;
|
| 192 |
+
margin-bottom: 5px;
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
.metric-value {
|
| 196 |
+
font-size: 1.2rem;
|
| 197 |
+
font-weight: bold;
|
| 198 |
+
color: var(--neon-green);
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
.black-panel .metric-value {
|
| 202 |
+
color: #fff;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
.metric-unit {
|
| 206 |
+
font-size: 0.8rem;
|
| 207 |
+
color: var(--neon-blue);
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
/* Training Controllers */
|
| 211 |
+
.training-controller {
|
| 212 |
+
background: rgba(0, 20, 0, 0.3);
|
| 213 |
+
padding: 15px;
|
| 214 |
+
border-radius: 8px;
|
| 215 |
+
border: 1px solid rgba(0, 255, 0, 0.2);
|
| 216 |
+
margin-bottom: 15px;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
.controller-title {
|
| 220 |
+
font-size: 0.9rem;
|
| 221 |
+
color: var(--neon-blue);
|
| 222 |
+
margin-bottom: 10px;
|
| 223 |
+
text-align: center;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
.slider-group {
|
| 227 |
+
margin-bottom: 12px;
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
.slider-label {
|
| 231 |
+
display: block;
|
| 232 |
+
margin-bottom: 5px;
|
| 233 |
+
color: var(--neon-blue);
|
| 234 |
+
font-size: 0.85rem;
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
.black-panel .slider-label {
|
| 238 |
+
color: #aaa;
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
.slider-container {
|
| 242 |
+
display: flex;
|
| 243 |
+
align-items: center;
|
| 244 |
+
gap: 10px;
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
input[type="range"] {
|
| 248 |
+
flex: 1;
|
| 249 |
+
height: 6px;
|
| 250 |
+
background: rgba(0, 255, 0, 0.1);
|
| 251 |
+
border-radius: 3px;
|
| 252 |
+
outline: none;
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
.black-panel input[type="range"] {
|
| 256 |
+
background: rgba(255, 255, 255, 0.1);
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
input[type="range"]::-webkit-slider-thumb {
|
| 260 |
+
appearance: none;
|
| 261 |
+
width: 16px;
|
| 262 |
+
height: 16px;
|
| 263 |
+
border-radius: 50%;
|
| 264 |
+
background: var(--neon-green);
|
| 265 |
+
cursor: pointer;
|
| 266 |
+
box-shadow: 0 0 8px var(--neon-green);
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
.black-panel input[type="range"]::-webkit-slider-thumb {
|
| 270 |
+
background: #fff;
|
| 271 |
+
box-shadow: 0 0 8px #fff;
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
.slider-value {
|
| 275 |
+
min-width: 60px;
|
| 276 |
+
text-align: right;
|
| 277 |
+
color: var(--neon-green);
|
| 278 |
+
font-weight: bold;
|
| 279 |
+
font-size: 0.9rem;
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
.black-panel .slider-value {
|
| 283 |
+
color: #fff;
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
/* Neural Network Visualization */
|
| 287 |
+
.nn-visualization {
|
| 288 |
+
height: 180px;
|
| 289 |
+
background: rgba(0, 0, 0, 0.5);
|
| 290 |
+
border: 1px solid var(--neon-green);
|
| 291 |
+
border-radius: 6px;
|
| 292 |
+
padding: 10px;
|
| 293 |
+
position: relative;
|
| 294 |
+
overflow: hidden;
|
| 295 |
+
margin-bottom: 15px;
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
.black-panel .nn-visualization {
|
| 299 |
+
border-color: #fff;
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
.nn-layer {
|
| 303 |
+
position: absolute;
|
| 304 |
+
top: 10px;
|
| 305 |
+
bottom: 10px;
|
| 306 |
+
display: flex;
|
| 307 |
+
flex-direction: column;
|
| 308 |
+
justify-content: space-around;
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
.neuron {
|
| 312 |
+
width: 10px;
|
| 313 |
+
height: 10px;
|
| 314 |
+
border-radius: 50%;
|
| 315 |
+
background: var(--neon-green);
|
| 316 |
+
margin: 5px auto;
|
| 317 |
+
opacity: 0.8;
|
| 318 |
+
transition: all 0.3s;
|
| 319 |
+
box-shadow: 0 0 5px currentColor;
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
.black-panel .neuron {
|
| 323 |
+
background: #fff;
|
| 324 |
+
box-shadow: 0 0 5px #fff;
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
.neuron.active {
|
| 328 |
+
opacity: 1;
|
| 329 |
+
background: var(--neon-red);
|
| 330 |
+
box-shadow: 0 0 12px var(--neon-red);
|
| 331 |
+
animation: pulse 0.8s infinite;
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
.black-panel .neuron.active {
|
| 335 |
+
background: var(--neon-red);
|
| 336 |
+
box-shadow: 0 0 12px var(--neon-red);
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
@keyframes pulse {
|
| 340 |
+
0%, 100% { transform: scale(1); }
|
| 341 |
+
50% { transform: scale(1.3); }
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
.connection {
|
| 345 |
+
position: absolute;
|
| 346 |
+
background: rgba(0, 255, 0, 0.2);
|
| 347 |
+
transform-origin: 0 0;
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
.black-panel .connection {
|
| 351 |
+
background: rgba(255, 255, 255, 0.2);
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
/* Agent Logs */
|
| 355 |
+
.agent-log {
|
| 356 |
+
background: rgba(0, 20, 0, 0.8);
|
| 357 |
+
border: 1px solid var(--neon-green);
|
| 358 |
+
border-radius: 6px;
|
| 359 |
+
padding: 10px;
|
| 360 |
+
font-family: 'Courier New', monospace;
|
| 361 |
+
font-size: 11px;
|
| 362 |
+
flex: 1;
|
| 363 |
+
min-height: 150px;
|
| 364 |
+
overflow-y: auto;
|
| 365 |
+
margin-top: auto;
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
.black-panel .agent-log {
|
| 369 |
+
border-color: #fff;
|
| 370 |
+
background: rgba(20, 20, 20, 0.8);
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
.log-header {
|
| 374 |
+
display: flex;
|
| 375 |
+
justify-content: space-between;
|
| 376 |
+
margin-bottom: 8px;
|
| 377 |
+
color: var(--neon-green);
|
| 378 |
+
font-weight: bold;
|
| 379 |
+
font-size: 0.9rem;
|
| 380 |
+
padding-bottom: 5px;
|
| 381 |
+
border-bottom: 1px solid rgba(0, 255, 0, 0.3);
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
.black-panel .log-header {
|
| 385 |
+
color: #fff;
|
| 386 |
+
border-bottom: 1px solid rgba(255, 255, 255, 0.3);
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
.log-line {
|
| 390 |
+
margin: 3px 0;
|
| 391 |
+
line-height: 1.3;
|
| 392 |
+
word-wrap: break-word;
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
.log-line.info { color: var(--neon-blue); }
|
| 396 |
+
.log-line.success { color: var(--neon-green); }
|
| 397 |
+
.log-line.warning { color: var(--neon-yellow); }
|
| 398 |
+
.log-line.error { color: var(--neon-red); }
|
| 399 |
+
|
| 400 |
+
.black-panel .log-line.info { color: #aaa; }
|
| 401 |
+
.black-panel .log-line.success { color: #fff; }
|
| 402 |
+
.black-panel .log-line.warning { color: #ffaa00; }
|
| 403 |
+
.black-panel .log-line.error { color: #ff5555; }
|
| 404 |
+
|
| 405 |
+
/* Center Arena */
|
| 406 |
+
.center-arena {
|
| 407 |
+
flex: 2;
|
| 408 |
+
display: flex;
|
| 409 |
+
flex-direction: column;
|
| 410 |
+
gap: 10px;
|
| 411 |
+
min-width: 500px;
|
| 412 |
+
}
|
| 413 |
+
|
| 414 |
+
/* Chess Arena */
|
| 415 |
+
.chess-arena {
|
| 416 |
+
background: var(--panel-bg);
|
| 417 |
+
border: 2px solid var(--neon-green);
|
| 418 |
+
border-radius: 8px;
|
| 419 |
+
padding: 20px;
|
| 420 |
+
display: flex;
|
| 421 |
+
flex-direction: column;
|
| 422 |
+
align-items: center;
|
| 423 |
+
box-shadow: 0 0 30px rgba(0, 255, 0, 0.2);
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
.arena-header {
|
| 427 |
+
width: 100%;
|
| 428 |
+
display: flex;
|
| 429 |
+
justify-content: space-between;
|
| 430 |
+
margin-bottom: 15px;
|
| 431 |
+
color: var(--neon-green);
|
| 432 |
+
font-size: 1.1rem;
|
| 433 |
+
}
|
| 434 |
+
|
| 435 |
+
.chess-board-container {
|
| 436 |
+
display: flex;
|
| 437 |
+
flex-direction: column;
|
| 438 |
+
align-items: center;
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
+
.chess-board {
|
| 442 |
+
display: grid;
|
| 443 |
+
grid-template-columns: repeat(8, 1fr);
|
| 444 |
+
grid-template-rows: repeat(8, 1fr);
|
| 445 |
+
width: 400px;
|
| 446 |
+
height: 400px;
|
| 447 |
+
border: 3px solid var(--neon-green);
|
| 448 |
+
box-shadow: 0 0 25px rgba(0, 255, 0, 0.4);
|
| 449 |
+
}
|
| 450 |
+
|
| 451 |
+
.chess-square {
|
| 452 |
+
display: flex;
|
| 453 |
+
align-items: center;
|
| 454 |
+
justify-content: center;
|
| 455 |
+
font-size: 28px;
|
| 456 |
+
position: relative;
|
| 457 |
+
cursor: default;
|
| 458 |
+
}
|
| 459 |
+
|
| 460 |
+
.chess-square.light {
|
| 461 |
+
background: rgba(30, 40, 30, 0.8);
|
| 462 |
+
}
|
| 463 |
+
|
| 464 |
+
.chess-square.dark {
|
| 465 |
+
background: rgba(10, 20, 10, 0.8);
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
.chess-square.highlight {
|
| 469 |
+
background: rgba(0, 255, 0, 0.3);
|
| 470 |
+
box-shadow: inset 0 0 10px rgba(0, 255, 0, 0.5);
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
/* Controls */
|
| 474 |
+
.controls {
|
| 475 |
+
display: grid;
|
| 476 |
+
grid-template-columns: repeat(5, 1fr);
|
| 477 |
+
gap: 10px;
|
| 478 |
+
padding: 15px;
|
| 479 |
+
background: var(--panel-bg);
|
| 480 |
+
border: 1px solid var(--neon-green);
|
| 481 |
+
border-radius: 8px;
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
.btn {
|
| 485 |
+
padding: 10px;
|
| 486 |
+
border-radius: 6px;
|
| 487 |
+
border: none;
|
| 488 |
+
font-weight: bold;
|
| 489 |
+
cursor: pointer;
|
| 490 |
+
transition: all 0.3s;
|
| 491 |
+
font-size: 0.9rem;
|
| 492 |
+
text-transform: uppercase;
|
| 493 |
+
letter-spacing: 1px;
|
| 494 |
+
}
|
| 495 |
+
|
| 496 |
+
.btn-primary {
|
| 497 |
+
background: rgba(0, 255, 0, 0.1);
|
| 498 |
+
color: var(--neon-green);
|
| 499 |
+
border: 2px solid var(--neon-green);
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
.btn-primary:hover {
|
| 503 |
+
background: rgba(0, 255, 0, 0.3);
|
| 504 |
+
box-shadow: 0 0 20px var(--neon-green);
|
| 505 |
+
transform: translateY(-2px);
|
| 506 |
+
}
|
| 507 |
+
|
| 508 |
+
.btn-blue {
|
| 509 |
+
background: rgba(0, 243, 255, 0.1);
|
| 510 |
+
color: var(--neon-blue);
|
| 511 |
+
border: 2px solid var(--neon-blue);
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
.btn-blue:hover {
|
| 515 |
+
background: rgba(0, 243, 255, 0.3);
|
| 516 |
+
box-shadow: 0 0 20px var(--neon-blue);
|
| 517 |
+
}
|
| 518 |
+
|
| 519 |
+
.btn-red {
|
| 520 |
+
background: rgba(255, 7, 58, 0.1);
|
| 521 |
+
color: var(--neon-red);
|
| 522 |
+
border: 2px solid var(--neon-red);
|
| 523 |
+
}
|
| 524 |
+
|
| 525 |
+
.btn-red:hover {
|
| 526 |
+
background: rgba(255, 7, 58, 0.3);
|
| 527 |
+
box-shadow: 0 0 20px var(--neon-red);
|
| 528 |
+
}
|
| 529 |
+
|
| 530 |
+
.btn-purple {
|
| 531 |
+
background: rgba(170, 0, 255, 0.1);
|
| 532 |
+
color: var(--neon-purple);
|
| 533 |
+
border: 2px solid var(--neon-purple);
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
.btn-purple:hover {
|
| 537 |
+
background: rgba(170, 0, 255, 0.3);
|
| 538 |
+
box-shadow: 0 0 20px var(--neon-purple);
|
| 539 |
+
}
|
| 540 |
+
|
| 541 |
+
/* Progress Section */
|
| 542 |
+
.progress-section {
|
| 543 |
+
display: flex;
|
| 544 |
+
gap: 10px;
|
| 545 |
+
align-items: center;
|
| 546 |
+
padding: 15px;
|
| 547 |
+
background: var(--panel-bg);
|
| 548 |
+
border: 1px solid var(--neon-green);
|
| 549 |
+
border-radius: 8px;
|
| 550 |
+
}
|
| 551 |
+
|
| 552 |
+
.progress-container {
|
| 553 |
+
flex: 1;
|
| 554 |
+
height: 8px;
|
| 555 |
+
background: rgba(0, 255, 0, 0.1);
|
| 556 |
+
border-radius: 4px;
|
| 557 |
+
overflow: hidden;
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
.progress-bar {
|
| 561 |
+
height: 100%;
|
| 562 |
+
background: linear-gradient(90deg, var(--neon-green), var(--neon-blue));
|
| 563 |
+
width: 0%;
|
| 564 |
+
transition: width 0.5s;
|
| 565 |
+
box-shadow: 0 0 10px currentColor;
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
/* Main Terminal */
|
| 569 |
+
.main-terminal {
|
| 570 |
+
flex: 1;
|
| 571 |
+
background: rgba(0, 20, 0, 0.8);
|
| 572 |
+
border: 1px solid var(--neon-green);
|
| 573 |
+
border-radius: 8px;
|
| 574 |
+
padding: 15px;
|
| 575 |
+
font-family: 'Courier New', monospace;
|
| 576 |
+
font-size: 12px;
|
| 577 |
+
display: flex;
|
| 578 |
+
flex-direction: column;
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
.terminal-header {
|
| 582 |
+
display: flex;
|
| 583 |
+
justify-content: space-between;
|
| 584 |
+
margin-bottom: 10px;
|
| 585 |
+
color: var(--neon-green);
|
| 586 |
+
font-weight: bold;
|
| 587 |
+
padding-bottom: 8px;
|
| 588 |
+
border-bottom: 1px solid rgba(0, 255, 0, 0.3);
|
| 589 |
+
}
|
| 590 |
+
|
| 591 |
+
.terminal-content {
|
| 592 |
+
flex: 1;
|
| 593 |
+
overflow-y: auto;
|
| 594 |
+
}
|
| 595 |
+
|
| 596 |
+
.terminal-line {
|
| 597 |
+
margin: 4px 0;
|
| 598 |
+
line-height: 1.4;
|
| 599 |
+
word-wrap: break-word;
|
| 600 |
+
}
|
| 601 |
+
|
| 602 |
+
.terminal-line.info { color: var(--neon-blue); }
|
| 603 |
+
.terminal-line.success { color: var(--neon-green); }
|
| 604 |
+
.terminal-line.warning { color: var(--neon-yellow); }
|
| 605 |
+
.terminal-line.error { color: var(--neon-red); }
|
| 606 |
+
|
| 607 |
+
/* Responsive Design */
|
| 608 |
+
@media (max-width: 1200px) {
|
| 609 |
+
.container {
|
| 610 |
+
flex-direction: column;
|
| 611 |
+
}
|
| 612 |
+
.panel, .center-arena {
|
| 613 |
+
min-width: unset;
|
| 614 |
+
}
|
| 615 |
+
.chess-board {
|
| 616 |
+
width: 300px;
|
| 617 |
+
height: 300px;
|
| 618 |
+
}
|
| 619 |
+
.controls {
|
| 620 |
+
grid-template-columns: repeat(3, 1fr);
|
| 621 |
+
}
|
| 622 |
+
}
|
| 623 |
+
|
| 624 |
+
@media (max-width: 768px) {
|
| 625 |
+
.chess-board {
|
| 626 |
+
width: 250px;
|
| 627 |
+
height: 250px;
|
| 628 |
+
}
|
| 629 |
+
.controls {
|
| 630 |
+
grid-template-columns: repeat(2, 1fr);
|
| 631 |
+
}
|
| 632 |
+
.metric-grid {
|
| 633 |
+
grid-template-columns: 1fr;
|
| 634 |
+
}
|
| 635 |
+
}
|
| 636 |
+
</style>
|
| 637 |
+
</head>
|
| 638 |
+
<body>
|
| 639 |
+
<!-- Loading Screen -->
|
| 640 |
+
<div id="loading-screen">
|
| 641 |
+
<div class="glitch-text">ANN CHESS RL TRAINER v3.0</div>
|
| 642 |
+
<div class="loading-subtitle">Initializing Neural Networks & Training Environment...</div>
|
| 643 |
+
<div class="loading-progress">
|
| 644 |
+
<div class="loading-bar"></div>
|
| 645 |
+
</div>
|
| 646 |
+
<div id="loading-details" style="margin-top: 20px; color: var(--neon-blue); font-size: 0.9rem;"></div>
|
| 647 |
+
</div>
|
| 648 |
+
|
| 649 |
+
<!-- Quantum Background -->
|
| 650 |
+
<canvas id="quantum-field"></canvas>
|
| 651 |
+
|
| 652 |
+
<!-- Main Interface -->
|
| 653 |
+
<div class="container">
|
| 654 |
+
<!-- Left Panel: Black Agent -->
|
| 655 |
+
<div class="panel black-panel">
|
| 656 |
+
<div class="panel-title">BLACK AGENT (Policy Network)</div>
|
| 657 |
+
|
| 658 |
+
<div class="metric-grid">
|
| 659 |
+
<div class="metric-card">
|
| 660 |
+
<div class="metric-label">Win Rate</div>
|
| 661 |
+
<div class="metric-value" id="black-win-rate">0.0<span class="metric-unit">%</span></div>
|
| 662 |
+
</div>
|
| 663 |
+
<div class="metric-card">
|
| 664 |
+
<div class="metric-label">Loss Value</div>
|
| 665 |
+
<div class="metric-value" id="black-loss">0.000</div>
|
| 666 |
+
</div>
|
| 667 |
+
<div class="metric-card">
|
| 668 |
+
<div class="metric-label">Learning Rate</div>
|
| 669 |
+
<div class="metric-value" id="black-lr">0.0010</div>
|
| 670 |
+
</div>
|
| 671 |
+
<div class="metric-card">
|
| 672 |
+
<div class="metric-label">Exploration</div>
|
| 673 |
+
<div class="metric-value" id="black-explore">0.30</div>
|
| 674 |
+
</div>
|
| 675 |
+
<div class="metric-card">
|
| 676 |
+
<div class="metric-label">Games Played</div>
|
| 677 |
+
<div class="metric-value" id="black-games">0</div>
|
| 678 |
+
</div>
|
| 679 |
+
<div class="metric-card">
|
| 680 |
+
<div class="metric-label">Moves Made</div>
|
| 681 |
+
<div class="metric-value" id="black-moves">0</div>
|
| 682 |
+
</div>
|
| 683 |
+
</div>
|
| 684 |
+
|
| 685 |
+
<div class="training-controller">
|
| 686 |
+
<div class="controller-title">NEURAL NETWORK CONTROLS</div>
|
| 687 |
+
<div class="slider-group">
|
| 688 |
+
<label class="slider-label">Learning Rate</label>
|
| 689 |
+
<div class="slider-container">
|
| 690 |
+
<input type="range" min="1" max="100" value="10"
|
| 691 |
+
oninput="updateAgentParam('black', 'learningRate', this.value/10000)">
|
| 692 |
+
<span class="slider-value" id="black-lr-value">0.0010</span>
|
| 693 |
+
</div>
|
| 694 |
+
</div>
|
| 695 |
+
<div class="slider-group">
|
| 696 |
+
<label class="slider-label">Exploration Rate</label>
|
| 697 |
+
<div class="slider-container">
|
| 698 |
+
<input type="range" min="0" max="100" value="30"
|
| 699 |
+
oninput="updateAgentParam('black', 'explorationRate', this.value/100)">
|
| 700 |
+
<span class="slider-value" id="black-explore-value">0.30</span>
|
| 701 |
+
</div>
|
| 702 |
+
</div>
|
| 703 |
+
<div class="slider-group">
|
| 704 |
+
<label class="slider-label">Discount Factor</label>
|
| 705 |
+
<div class="slider-container">
|
| 706 |
+
<input type="range" min="50" max="99" value="95"
|
| 707 |
+
oninput="updateAgentParam('black', 'discountFactor', this.value/100)">
|
| 708 |
+
<span class="slider-value" id="black-discount-value">0.95</span>
|
| 709 |
+
</div>
|
| 710 |
+
</div>
|
| 711 |
+
</div>
|
| 712 |
+
|
| 713 |
+
<div class="nn-visualization" id="black-nn-viz">
|
| 714 |
+
<!-- Neural network visualization -->
|
| 715 |
+
</div>
|
| 716 |
+
|
| 717 |
+
<div class="agent-log">
|
| 718 |
+
<div class="log-header">
|
| 719 |
+
<span>Black Agent Log</span>
|
| 720 |
+
<span id="black-log-count">0</span>
|
| 721 |
+
</div>
|
| 722 |
+
<div id="black-log-content"></div>
|
| 723 |
+
</div>
|
| 724 |
+
</div>
|
| 725 |
+
|
| 726 |
+
<!-- Center Arena -->
|
| 727 |
+
<div class="center-arena">
|
| 728 |
+
<div class="chess-arena">
|
| 729 |
+
<div class="arena-header">
|
| 730 |
+
<span>BLACK</span>
|
| 731 |
+
<span id="current-turn">White to move</span>
|
| 732 |
+
<span>GREEN</span>
|
| 733 |
+
</div>
|
| 734 |
+
<div class="chess-board-container">
|
| 735 |
+
<div class="chess-board" id="chess-board">
|
| 736 |
+
<!-- Chess board will be rendered here -->
|
| 737 |
+
</div>
|
| 738 |
+
<div style="margin-top: 15px; color: var(--neon-blue); font-size: 0.9rem;">
|
| 739 |
+
Game #<span id="current-game">1</span> | Moves: <span id="current-moves">0</span>
|
| 740 |
+
</div>
|
| 741 |
+
</div>
|
| 742 |
+
</div>
|
| 743 |
+
|
| 744 |
+
<div class="controls">
|
| 745 |
+
<button class="btn btn-primary" onclick="startTraining()" id="start-btn">
|
| 746 |
+
<i class="fas fa-play"></i> Start Training
|
| 747 |
+
</button>
|
| 748 |
+
<button class="btn btn-red" onclick="pauseTraining()" id="pause-btn" style="display: none;">
|
| 749 |
+
<i class="fas fa-pause"></i> Pause Training
|
| 750 |
+
</button>
|
| 751 |
+
<button class="btn btn-blue" onclick="exportEverything()" id="export-btn">
|
| 752 |
+
<i class="fas fa-file-export"></i> Export All
|
| 753 |
+
</button>
|
| 754 |
+
<button class="btn btn-purple" onclick="resetTraining()">
|
| 755 |
+
<i class="fas fa-redo"></i> Reset All
|
| 756 |
+
</button>
|
| 757 |
+
<button class="btn btn-primary" onclick="saveState()">
|
| 758 |
+
<i class="fas fa-save"></i> Save State
|
| 759 |
+
</button>
|
| 760 |
+
</div>
|
| 761 |
+
|
| 762 |
+
<div class="progress-section">
|
| 763 |
+
<div class="progress-container">
|
| 764 |
+
<div class="progress-bar" id="training-progress"></div>
|
| 765 |
+
</div>
|
| 766 |
+
<span style="color: var(--neon-green); font-weight: bold; min-width: 200px;">
|
| 767 |
+
Games: <span id="total-games">0</span> | Moves: <span id="total-moves">0</span>
|
| 768 |
+
</span>
|
| 769 |
+
</div>
|
| 770 |
+
|
| 771 |
+
<div class="main-terminal">
|
| 772 |
+
<div class="terminal-header">
|
| 773 |
+
<span>TRAINING CONSOLE</span>
|
| 774 |
+
<span id="training-timer">00:00:00</span>
|
| 775 |
+
</div>
|
| 776 |
+
<div class="terminal-content" id="main-terminal"></div>
|
| 777 |
+
</div>
|
| 778 |
+
</div>
|
| 779 |
+
|
| 780 |
+
<!-- Right Panel: Green Agent -->
|
| 781 |
+
<div class="panel green-panel">
|
| 782 |
+
<div class="panel-title">GREEN AGENT (Value Network)</div>
|
| 783 |
+
|
| 784 |
+
<div class="metric-grid">
|
| 785 |
+
<div class="metric-card">
|
| 786 |
+
<div class="metric-label">Win Rate</div>
|
| 787 |
+
<div class="metric-value" id="green-win-rate">0.0<span class="metric-unit">%</span></div>
|
| 788 |
+
</div>
|
| 789 |
+
<div class="metric-card">
|
| 790 |
+
<div class="metric-label">Loss Value</div>
|
| 791 |
+
<div class="metric-value" id="green-loss">0.000</div>
|
| 792 |
+
</div>
|
| 793 |
+
<div class="metric-card">
|
| 794 |
+
<div class="metric-label">Learning Rate</div>
|
| 795 |
+
<div class="metric-value" id="green-lr">0.0010</div>
|
| 796 |
+
</div>
|
| 797 |
+
<div class="metric-card">
|
| 798 |
+
<div class="metric-label">Exploration</div>
|
| 799 |
+
<div class="metric-value" id="green-explore">0.30</div>
|
| 800 |
+
</div>
|
| 801 |
+
<div class="metric-card">
|
| 802 |
+
<div class="metric-label">Games Played</div>
|
| 803 |
+
<div class="metric-value" id="green-games">0</div>
|
| 804 |
+
</div>
|
| 805 |
+
<div class="metric-card">
|
| 806 |
+
<div class="metric-label">Moves Made</div>
|
| 807 |
+
<div class="metric-value" id="green-moves">0</div>
|
| 808 |
+
</div>
|
| 809 |
+
</div>
|
| 810 |
+
|
| 811 |
+
<div class="training-controller">
|
| 812 |
+
<div class="controller-title">NEURAL NETWORK CONTROLS</div>
|
| 813 |
+
<div class="slider-group">
|
| 814 |
+
<label class="slider-label">Learning Rate</label>
|
| 815 |
+
<div class="slider-container">
|
| 816 |
+
<input type="range" min="1" max="100" value="10"
|
| 817 |
+
oninput="updateAgentParam('green', 'learningRate', this.value/10000)">
|
| 818 |
+
<span class="slider-value" id="green-lr-value">0.0010</span>
|
| 819 |
+
</div>
|
| 820 |
+
</div>
|
| 821 |
+
<div class="slider-group">
|
| 822 |
+
<label class="slider-label">Exploration Rate</label>
|
| 823 |
+
<div class="slider-container">
|
| 824 |
+
<input type="range" min="0" max="100" value="30"
|
| 825 |
+
oninput="updateAgentParam('green', 'explorationRate', this.value/100)">
|
| 826 |
+
<span class="slider-value" id="green-explore-value">0.30</span>
|
| 827 |
+
</div>
|
| 828 |
+
</div>
|
| 829 |
+
<div class="slider-group">
|
| 830 |
+
<label class="slider-label">Discount Factor</label>
|
| 831 |
+
<div class="slider-container">
|
| 832 |
+
<input type="range" min="50" max="99" value="95"
|
| 833 |
+
oninput="updateAgentParam('green', 'discountFactor', this.value/100)">
|
| 834 |
+
<span class="slider-value" id="green-discount-value">0.95</span>
|
| 835 |
+
</div>
|
| 836 |
+
</div>
|
| 837 |
+
</div>
|
| 838 |
+
|
| 839 |
+
<div class="nn-visualization" id="green-nn-viz">
|
| 840 |
+
<!-- Neural network visualization -->
|
| 841 |
+
</div>
|
| 842 |
+
|
| 843 |
+
<div class="agent-log">
|
| 844 |
+
<div class="log-header">
|
| 845 |
+
<span>Green Agent Log</span>
|
| 846 |
+
<span id="green-log-count">0</span>
|
| 847 |
+
</div>
|
| 848 |
+
<div id="green-log-content"></div>
|
| 849 |
+
</div>
|
| 850 |
+
</div>
|
| 851 |
+
</div>
|
| 852 |
+
|
| 853 |
+
<script>
|
| 854 |
+
// Global State Management
|
| 855 |
+
const state = {
|
| 856 |
+
trainingActive: false,
|
| 857 |
+
game: null,
|
| 858 |
+
currentGameNumber: 1,
|
| 859 |
+
trainingStartTime: null,
|
| 860 |
+
trainingTimer: null,
|
| 861 |
+
lastAutoSave: null,
|
| 862 |
+
realTimeInterval: null,
|
| 863 |
+
|
| 864 |
+
// Neural Networks
|
| 865 |
+
neuralNetworks: {
|
| 866 |
+
black: null,
|
| 867 |
+
green: null
|
| 868 |
+
},
|
| 869 |
+
|
| 870 |
+
// RL Agents
|
| 871 |
+
agents: {
|
| 872 |
+
black: null,
|
| 873 |
+
green: null
|
| 874 |
+
},
|
| 875 |
+
|
| 876 |
+
// Agent Statistics
|
| 877 |
+
agentStats: {
|
| 878 |
+
black: {
|
| 879 |
+
wins: 0,
|
| 880 |
+
losses: 0,
|
| 881 |
+
draws: 0,
|
| 882 |
+
totalGames: 0,
|
| 883 |
+
movesMade: 0,
|
| 884 |
+
learningRate: 0.001,
|
| 885 |
+
explorationRate: 0.3,
|
| 886 |
+
discountFactor: 0.95,
|
| 887 |
+
lossHistory: []
|
| 888 |
+
},
|
| 889 |
+
green: {
|
| 890 |
+
wins: 0,
|
| 891 |
+
losses: 0,
|
| 892 |
+
draws: 0,
|
| 893 |
+
totalGames: 0,
|
| 894 |
+
movesMade: 0,
|
| 895 |
+
learningRate: 0.001,
|
| 896 |
+
explorationRate: 0.3,
|
| 897 |
+
discountFactor: 0.95,
|
| 898 |
+
lossHistory: []
|
| 899 |
+
}
|
| 900 |
+
},
|
| 901 |
+
|
| 902 |
+
// Training Data
|
| 903 |
+
dataset: [],
|
| 904 |
+
validGames: 0,
|
| 905 |
+
totalMoves: 0,
|
| 906 |
+
currentGameData: null
|
| 907 |
+
};
|
| 908 |
+
|
| 909 |
+
// Helper functions for reward calculation
|
| 910 |
+
function calculateMaterialAdvantage(game) {
|
| 911 |
+
const pieceValues = { p: 1, n: 3, b: 3, r: 5, q: 9, k: 0 };
|
| 912 |
+
let white = 0, black = 0;
|
| 913 |
+
|
| 914 |
+
game.board().forEach(row => {
|
| 915 |
+
row.forEach(piece => {
|
| 916 |
+
if (piece) {
|
| 917 |
+
const value = pieceValues[piece.type] || 0;
|
| 918 |
+
if (piece.color === 'w') white += value;
|
| 919 |
+
else black += value;
|
| 920 |
+
}
|
| 921 |
+
});
|
| 922 |
+
});
|
| 923 |
+
|
| 924 |
+
return white - black;
|
| 925 |
+
}
|
| 926 |
+
|
| 927 |
+
function calculateCenterControl(game) {
|
| 928 |
+
const center = ['d4', 'd5', 'e4', 'e5'];
|
| 929 |
+
let control = 0;
|
| 930 |
+
|
| 931 |
+
center.forEach(square => {
|
| 932 |
+
const piece = game.get(square);
|
| 933 |
+
if (piece) {
|
| 934 |
+
control += piece.color === 'w' ? 1 : -1;
|
| 935 |
+
}
|
| 936 |
+
});
|
| 937 |
+
|
| 938 |
+
return control;
|
| 939 |
+
}
|
| 940 |
+
|
| 941 |
+
// Normalize game data for export
|
| 942 |
+
function normalizeGameForExport(game) {
|
| 943 |
+
const normalized = {
|
| 944 |
+
id: String(game.id || `game_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`),
|
| 945 |
+
pgn: String(game.pgn || ''),
|
| 946 |
+
moves: Array.isArray(game.moves) ? game.moves.map(m => typeof m === 'object' ? m : {san: String(m)}) : [],
|
| 947 |
+
result: String(game.result || 'draw'),
|
| 948 |
+
positions: Array.isArray(game.positions) ? game.positions : [],
|
| 949 |
+
metadata: typeof game.metadata === 'object' ? game.metadata : {},
|
| 950 |
+
start_time: String(game.start_time || new Date().toISOString()),
|
| 951 |
+
end_time: String(game.end_time || new Date().toISOString()),
|
| 952 |
+
moves_count: Number.isInteger(game.moves_count) ? game.moves_count : (Array.isArray(game.moves) ? game.moves.length : 0),
|
| 953 |
+
final_fen: String(game.final_fen || ''),
|
| 954 |
+
agent_metadata: typeof game.agent_metadata === 'object' ? game.agent_metadata : {}
|
| 955 |
+
};
|
| 956 |
+
|
| 957 |
+
if (isNaN(normalized.moves_count)) normalized.moves_count = 0;
|
| 958 |
+
|
| 959 |
+
return normalized;
|
| 960 |
+
}
|
| 961 |
+
|
| 962 |
+
// TensorFlow.js Neural Network
|
| 963 |
+
class ChessNeuralNetwork {
|
| 964 |
+
constructor(name, color, learningRate = 0.001) {
|
| 965 |
+
this.name = name;
|
| 966 |
+
this.color = color;
|
| 967 |
+
this.learningRate = learningRate;
|
| 968 |
+
this.model = null;
|
| 969 |
+
this.optimizer = tf.train.adam(learningRate);
|
| 970 |
+
this.lossHistory = [];
|
| 971 |
+
this.initializeModel();
|
| 972 |
+
}
|
| 973 |
+
|
| 974 |
+
initializeModel() {
|
| 975 |
+
this.model = tf.sequential();
|
| 976 |
+
|
| 977 |
+
this.model.add(tf.layers.dense({
|
| 978 |
+
units: 128,
|
| 979 |
+
activation: 'relu',
|
| 980 |
+
inputShape: [896]
|
| 981 |
+
}));
|
| 982 |
+
|
| 983 |
+
this.model.add(tf.layers.dense({ units: 64, activation: 'relu' }));
|
| 984 |
+
this.model.add(tf.layers.dropout({ rate: 0.2 }));
|
| 985 |
+
this.model.add(tf.layers.dense({ units: 32, activation: 'relu' }));
|
| 986 |
+
|
| 987 |
+
this.model.add(tf.layers.dense({ units: 1, activation: 'tanh' }));
|
| 988 |
+
|
| 989 |
+
this.model.compile({
|
| 990 |
+
optimizer: this.optimizer,
|
| 991 |
+
loss: 'meanSquaredError',
|
| 992 |
+
metrics: ['accuracy']
|
| 993 |
+
});
|
| 994 |
+
|
| 995 |
+
logAgent(this.color, `Neural network initialized (LR: ${this.learningRate})`, 'success');
|
| 996 |
+
}
|
| 997 |
+
|
| 998 |
+
async predict(boardState) {
|
| 999 |
+
const input = tf.tensor2d([boardState]);
|
| 1000 |
+
const prediction = this.model.predict(input);
|
| 1001 |
+
const value = await prediction.data();
|
| 1002 |
+
tf.dispose([input, prediction]);
|
| 1003 |
+
return value[0];
|
| 1004 |
+
}
|
| 1005 |
+
|
| 1006 |
+
async train(states, targets) {
|
| 1007 |
+
if (states.length === 0) return 0;
|
| 1008 |
+
|
| 1009 |
+
const xs = tf.tensor2d(states);
|
| 1010 |
+
const ys = tf.tensor2d(targets, [targets.length, 1]);
|
| 1011 |
+
|
| 1012 |
+
const history = await this.model.fit(xs, ys, {
|
| 1013 |
+
epochs: 1,
|
| 1014 |
+
batchSize: Math.min(32, states.length),
|
| 1015 |
+
verbose: 0
|
| 1016 |
+
});
|
| 1017 |
+
|
| 1018 |
+
const loss = history.history.loss[0];
|
| 1019 |
+
this.lossHistory.push(loss);
|
| 1020 |
+
|
| 1021 |
+
tf.dispose([xs, ys]);
|
| 1022 |
+
return loss;
|
| 1023 |
+
}
|
| 1024 |
+
|
| 1025 |
+
updateLearningRate(newRate) {
|
| 1026 |
+
this.learningRate = newRate;
|
| 1027 |
+
this.optimizer.setLearningRate(newRate);
|
| 1028 |
+
}
|
| 1029 |
+
|
| 1030 |
+
async getWeightsData() {
|
| 1031 |
+
if (!this.model) return null;
|
| 1032 |
+
|
| 1033 |
+
const weights = this.model.getWeights();
|
| 1034 |
+
const weightsData = [];
|
| 1035 |
+
|
| 1036 |
+
for (const tensor of weights) {
|
| 1037 |
+
const data = await tensor.data();
|
| 1038 |
+
weightsData.push({
|
| 1039 |
+
shape: Array.from(tensor.shape),
|
| 1040 |
+
data: Array.from(data),
|
| 1041 |
+
dtype: tensor.dtype
|
| 1042 |
+
});
|
| 1043 |
+
}
|
| 1044 |
+
|
| 1045 |
+
return weightsData;
|
| 1046 |
+
}
|
| 1047 |
+
}
|
| 1048 |
+
|
| 1049 |
+
// Reinforcement Learning Agent
|
| 1050 |
+
class RLAgent {
|
| 1051 |
+
constructor(color, neuralNetwork) {
|
| 1052 |
+
this.color = color;
|
| 1053 |
+
this.nn = neuralNetwork;
|
| 1054 |
+
this.memory = [];
|
| 1055 |
+
this.experienceSize = 1000;
|
| 1056 |
+
this.batchSize = 32;
|
| 1057 |
+
this.gamma = 0.95;
|
| 1058 |
+
this.lastAction = null;
|
| 1059 |
+
}
|
| 1060 |
+
|
| 1061 |
+
async selectMove(game, explorationRate = 0.3) {
|
| 1062 |
+
const moves = game.moves();
|
| 1063 |
+
if (moves.length === 0) return null;
|
| 1064 |
+
|
| 1065 |
+
if (Math.random() < explorationRate) {
|
| 1066 |
+
const randomMove = moves[Math.floor(Math.random() * moves.length)];
|
| 1067 |
+
logAgent(this.color, `Exploration: ${randomMove}`, 'info');
|
| 1068 |
+
return randomMove;
|
| 1069 |
+
}
|
| 1070 |
+
|
| 1071 |
+
let bestMove = null;
|
| 1072 |
+
let bestValue = -Infinity;
|
| 1073 |
+
|
| 1074 |
+
for (const move of moves) {
|
| 1075 |
+
const testGame = new Chess(game.fen());
|
| 1076 |
+
testGame.move(move);
|
| 1077 |
+
|
| 1078 |
+
const state = encodeBoardState(testGame);
|
| 1079 |
+
const value = await this.nn.predict(state);
|
| 1080 |
+
|
| 1081 |
+
const adjustedValue = this.color === 'green' ? value : -value;
|
| 1082 |
+
|
| 1083 |
+
if (adjustedValue > bestValue) {
|
| 1084 |
+
bestValue = adjustedValue;
|
| 1085 |
+
bestMove = move;
|
| 1086 |
+
}
|
| 1087 |
+
}
|
| 1088 |
+
|
| 1089 |
+
if (bestMove) {
|
| 1090 |
+
logAgent(this.color, `Best move: ${bestMove} (value: ${bestValue.toFixed(3)})`, 'info');
|
| 1091 |
+
}
|
| 1092 |
+
|
| 1093 |
+
return bestMove || moves[0];
|
| 1094 |
+
}
|
| 1095 |
+
|
| 1096 |
+
addExperience(state, action, reward, nextState, done) {
|
| 1097 |
+
this.memory.push({
|
| 1098 |
+
state,
|
| 1099 |
+
action,
|
| 1100 |
+
reward,
|
| 1101 |
+
nextState,
|
| 1102 |
+
done,
|
| 1103 |
+
timestamp: new Date().toISOString()
|
| 1104 |
+
});
|
| 1105 |
+
if (this.memory.length > this.experienceSize) {
|
| 1106 |
+
this.memory.shift();
|
| 1107 |
+
}
|
| 1108 |
+
}
|
| 1109 |
+
|
| 1110 |
+
async trainFromMemory() {
|
| 1111 |
+
if (this.memory.length < this.batchSize) return 0;
|
| 1112 |
+
|
| 1113 |
+
const batch = [];
|
| 1114 |
+
const batchSize = Math.min(this.batchSize, this.memory.length);
|
| 1115 |
+
for (let i = 0; i < batchSize; i++) {
|
| 1116 |
+
const index = Math.floor(Math.random() * this.memory.length);
|
| 1117 |
+
batch.push(this.memory[index]);
|
| 1118 |
+
}
|
| 1119 |
+
|
| 1120 |
+
const states = [];
|
| 1121 |
+
const targets = [];
|
| 1122 |
+
|
| 1123 |
+
for (const exp of batch) {
|
| 1124 |
+
const currentQ = await this.nn.predict(exp.state);
|
| 1125 |
+
let targetQ = exp.reward;
|
| 1126 |
+
|
| 1127 |
+
if (!exp.done) {
|
| 1128 |
+
const nextQ = await this.nn.predict(exp.nextState);
|
| 1129 |
+
targetQ += this.gamma * nextQ;
|
| 1130 |
+
}
|
| 1131 |
+
|
| 1132 |
+
states.push(exp.state);
|
| 1133 |
+
targets.push(targetQ);
|
| 1134 |
+
}
|
| 1135 |
+
|
| 1136 |
+
const loss = await this.nn.train(states, targets);
|
| 1137 |
+
|
| 1138 |
+
if (loss < 10) {
|
| 1139 |
+
state.agentStats[this.color].lossHistory.push(loss);
|
| 1140 |
+
if (state.agentStats[this.color].lossHistory.length > 100) {
|
| 1141 |
+
state.agentStats[this.color].lossHistory.shift();
|
| 1142 |
+
}
|
| 1143 |
+
}
|
| 1144 |
+
|
| 1145 |
+
return loss;
|
| 1146 |
+
}
|
| 1147 |
+
}
|
| 1148 |
+
|
| 1149 |
+
// Board State Encoding
|
| 1150 |
+
function encodeBoardState(game) {
|
| 1151 |
+
const board = game.board();
|
| 1152 |
+
const encoded = new Array(896).fill(0);
|
| 1153 |
+
|
| 1154 |
+
for (let rank = 0; rank < 8; rank++) {
|
| 1155 |
+
for (let file = 0; file < 8; file++) {
|
| 1156 |
+
const piece = board[rank][file];
|
| 1157 |
+
const baseIndex = (rank * 8 + file) * 14;
|
| 1158 |
+
|
| 1159 |
+
if (piece) {
|
| 1160 |
+
const pieceIndex = {
|
| 1161 |
+
'p': 0, 'n': 1, 'b': 2, 'r': 3, 'q': 4, 'k': 5,
|
| 1162 |
+
'P': 6, 'N': 7, 'B': 8, 'R': 9, 'Q': 10, 'K': 11
|
| 1163 |
+
}[piece.type + (piece.color === 'w' ? piece.type.toUpperCase() : piece.type)];
|
| 1164 |
+
|
| 1165 |
+
if (pieceIndex !== undefined) {
|
| 1166 |
+
encoded[baseIndex + pieceIndex] = 1;
|
| 1167 |
+
}
|
| 1168 |
+
encoded[baseIndex + 12] = piece.color === 'w' ? 1 : 0;
|
| 1169 |
+
encoded[baseIndex + 13] = 1;
|
| 1170 |
+
}
|
| 1171 |
+
}
|
| 1172 |
+
}
|
| 1173 |
+
|
| 1174 |
+
return encoded;
|
| 1175 |
+
}
|
| 1176 |
+
|
| 1177 |
+
// Visualization Functions
|
| 1178 |
+
function updateQuantumBackground() {
|
| 1179 |
+
const canvas = document.getElementById('quantum-field');
|
| 1180 |
+
if (!canvas) return;
|
| 1181 |
+
|
| 1182 |
+
const ctx = canvas.getContext('2d');
|
| 1183 |
+
|
| 1184 |
+
canvas.width = window.innerWidth;
|
| 1185 |
+
canvas.height = window.innerHeight;
|
| 1186 |
+
|
| 1187 |
+
function draw() {
|
| 1188 |
+
ctx.fillStyle = 'rgba(10, 10, 10, 0.1)';
|
| 1189 |
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
| 1190 |
+
|
| 1191 |
+
const time = Date.now() * 0.001;
|
| 1192 |
+
const particleCount = 50;
|
| 1193 |
+
|
| 1194 |
+
for (let i = 0; i < particleCount; i++) {
|
| 1195 |
+
const x = (Math.sin(time + i * 0.1) * 0.5 + 0.5) * canvas.width;
|
| 1196 |
+
const y = (Math.cos(time * 0.7 + i * 0.05) * 0.5 + 0.5) * canvas.height;
|
| 1197 |
+
const size = 2 + Math.sin(time + i) * 1;
|
| 1198 |
+
const hue = (i * 3 + time * 50) % 360;
|
| 1199 |
+
|
| 1200 |
+
ctx.beginPath();
|
| 1201 |
+
ctx.arc(x, y, size, 0, Math.PI * 2);
|
| 1202 |
+
ctx.fillStyle = `hsla(${hue}, 100%, 50%, 0.3)`;
|
| 1203 |
+
ctx.fill();
|
| 1204 |
+
}
|
| 1205 |
+
|
| 1206 |
+
requestAnimationFrame(draw);
|
| 1207 |
+
}
|
| 1208 |
+
|
| 1209 |
+
draw();
|
| 1210 |
+
}
|
| 1211 |
+
|
| 1212 |
+
function visualizeNeuralNetwork(containerId, agentColor) {
|
| 1213 |
+
const container = document.getElementById(containerId);
|
| 1214 |
+
if (!container) return;
|
| 1215 |
+
|
| 1216 |
+
container.innerHTML = '';
|
| 1217 |
+
|
| 1218 |
+
const layerSizes = [896, 128, 64, 32, 1];
|
| 1219 |
+
const width = container.clientWidth;
|
| 1220 |
+
const height = container.clientHeight;
|
| 1221 |
+
const layerSpacing = width / (layerSizes.length + 1);
|
| 1222 |
+
|
| 1223 |
+
for (let l = 0; l < layerSizes.length; l++) {
|
| 1224 |
+
const layerDiv = document.createElement('div');
|
| 1225 |
+
layerDiv.className = 'nn-layer';
|
| 1226 |
+
layerDiv.style.left = `${(l + 1) * layerSpacing}px`;
|
| 1227 |
+
|
| 1228 |
+
const neurons = Math.min(layerSizes[l], 12);
|
| 1229 |
+
const neuronSpacing = height / (neurons + 1);
|
| 1230 |
+
|
| 1231 |
+
for (let n = 0; n < neurons; n++) {
|
| 1232 |
+
const neuron = document.createElement('div');
|
| 1233 |
+
neuron.className = 'neuron';
|
| 1234 |
+
neuron.style.top = `${neuronSpacing * (n + 1)}px`;
|
| 1235 |
+
|
| 1236 |
+
if (Math.random() > 0.5) {
|
| 1237 |
+
neuron.classList.add('active');
|
| 1238 |
+
neuron.style.animationDelay = `${Math.random() * 2}s`;
|
| 1239 |
+
}
|
| 1240 |
+
|
| 1241 |
+
layerDiv.appendChild(neuron);
|
| 1242 |
+
}
|
| 1243 |
+
|
| 1244 |
+
container.appendChild(layerDiv);
|
| 1245 |
+
}
|
| 1246 |
+
|
| 1247 |
+
setInterval(() => {
|
| 1248 |
+
const neurons = container.querySelectorAll('.neuron');
|
| 1249 |
+
neurons.forEach(neuron => {
|
| 1250 |
+
if (Math.random() > 0.7) {
|
| 1251 |
+
neuron.classList.toggle('active');
|
| 1252 |
+
neuron.style.animationDelay = `${Math.random() * 2}s`;
|
| 1253 |
+
}
|
| 1254 |
+
});
|
| 1255 |
+
}, 1000);
|
| 1256 |
+
}
|
| 1257 |
+
|
| 1258 |
+
function renderChessBoard() {
|
| 1259 |
+
const board = document.getElementById('chess-board');
|
| 1260 |
+
if (!board || !state.game) return;
|
| 1261 |
+
|
| 1262 |
+
board.innerHTML = '';
|
| 1263 |
+
|
| 1264 |
+
const files = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'];
|
| 1265 |
+
const ranks = [8, 7, 6, 5, 4, 3, 2, 1];
|
| 1266 |
+
|
| 1267 |
+
for (let rank = 0; rank < 8; rank++) {
|
| 1268 |
+
for (let file = 0; file < 8; file++) {
|
| 1269 |
+
const square = files[file] + ranks[rank];
|
| 1270 |
+
const piece = state.game.get(square);
|
| 1271 |
+
|
| 1272 |
+
const div = document.createElement('div');
|
| 1273 |
+
div.className = `chess-square ${(file + rank) % 2 === 0 ? 'light' : 'dark'}`;
|
| 1274 |
+
div.dataset.square = square;
|
| 1275 |
+
|
| 1276 |
+
if (piece) {
|
| 1277 |
+
div.textContent = getPieceSymbol(piece.type, piece.color);
|
| 1278 |
+
}
|
| 1279 |
+
|
| 1280 |
+
board.appendChild(div);
|
| 1281 |
+
}
|
| 1282 |
+
}
|
| 1283 |
+
|
| 1284 |
+
const history = state.game.history();
|
| 1285 |
+
document.getElementById('current-moves').textContent = history.length;
|
| 1286 |
+
|
| 1287 |
+
const turn = state.game.turn() === 'w' ? 'Green' : 'Black';
|
| 1288 |
+
document.getElementById('current-turn').textContent = `${turn} to move`;
|
| 1289 |
+
}
|
| 1290 |
+
|
| 1291 |
+
function getPieceSymbol(type, color) {
|
| 1292 |
+
const symbols = {
|
| 1293 |
+
p: { w: '♙', b: '♟' },
|
| 1294 |
+
n: { w: '♘', b: '♞' },
|
| 1295 |
+
b: { w: '♗', b: '♝' },
|
| 1296 |
+
r: { w: '♖', b: '♜' },
|
| 1297 |
+
q: { w: '♕', b: '♛' },
|
| 1298 |
+
k: { w: '♔', b: '♚' }
|
| 1299 |
+
};
|
| 1300 |
+
return symbols[type][color];
|
| 1301 |
+
}
|
| 1302 |
+
|
| 1303 |
+
// Training Functions
|
| 1304 |
+
async function startTraining() {
|
| 1305 |
+
if (state.trainingActive) return;
|
| 1306 |
+
|
| 1307 |
+
state.trainingActive = true;
|
| 1308 |
+
state.trainingStartTime = Date.now();
|
| 1309 |
+
|
| 1310 |
+
document.getElementById('start-btn').style.display = 'none';
|
| 1311 |
+
document.getElementById('pause-btn').style.display = 'inline-block';
|
| 1312 |
+
|
| 1313 |
+
log('Starting neural network training session...', 'success');
|
| 1314 |
+
log('Two RL agents will play chess against each other', 'info');
|
| 1315 |
+
log('Left: Black Agent (Policy Network)', 'info');
|
| 1316 |
+
log('Right: Green Agent (Value Network)', 'info');
|
| 1317 |
+
|
| 1318 |
+
startTrainingTimer();
|
| 1319 |
+
startNewGame();
|
| 1320 |
+
|
| 1321 |
+
startRealTimeMonitoring();
|
| 1322 |
+
}
|
| 1323 |
+
|
| 1324 |
+
async function trainingStep() {
|
| 1325 |
+
if (!state.trainingActive) return;
|
| 1326 |
+
|
| 1327 |
+
try {
|
| 1328 |
+
if (state.game.game_over()) {
|
| 1329 |
+
saveCurrentGame();
|
| 1330 |
+
updateAllMetrics();
|
| 1331 |
+
startNewGame();
|
| 1332 |
+
return;
|
| 1333 |
+
}
|
| 1334 |
+
|
| 1335 |
+
const currentColor = state.game.turn();
|
| 1336 |
+
const agentColor = currentColor === 'w' ? 'green' : 'black';
|
| 1337 |
+
const agent = state.agents[agentColor];
|
| 1338 |
+
|
| 1339 |
+
const currentState = encodeBoardState(state.game);
|
| 1340 |
+
const explorationRate = state.agentStats[agentColor].explorationRate;
|
| 1341 |
+
const move = await agent.selectMove(state.game, explorationRate);
|
| 1342 |
+
|
| 1343 |
+
if (!move) {
|
| 1344 |
+
log(`No valid moves for ${agentColor}`, 'warning');
|
| 1345 |
+
saveCurrentGame();
|
| 1346 |
+
startNewGame();
|
| 1347 |
+
return;
|
| 1348 |
+
}
|
| 1349 |
+
|
| 1350 |
+
const result = state.game.move(move);
|
| 1351 |
+
if (!result) {
|
| 1352 |
+
log(`Invalid move ${move} from ${agentColor}`, 'error');
|
| 1353 |
+
saveCurrentGame();
|
| 1354 |
+
startNewGame();
|
| 1355 |
+
return;
|
| 1356 |
+
}
|
| 1357 |
+
|
| 1358 |
+
state.agentStats[agentColor].movesMade++;
|
| 1359 |
+
state.totalMoves++;
|
| 1360 |
+
|
| 1361 |
+
const nextState = encodeBoardState(state.game);
|
| 1362 |
+
const gameResult = evaluateGameResult(state.game);
|
| 1363 |
+
|
| 1364 |
+
let reward = 0;
|
| 1365 |
+
|
| 1366 |
+
if (state.game.game_over()) {
|
| 1367 |
+
if (gameResult === agentColor) reward = 1;
|
| 1368 |
+
else if (gameResult === 'draw') reward = 0.1;
|
| 1369 |
+
else if (gameResult && gameResult !== agentColor) reward = -1;
|
| 1370 |
+
} else {
|
| 1371 |
+
const materialDiff = calculateMaterialAdvantage(state.game);
|
| 1372 |
+
reward = materialDiff * 0.01;
|
| 1373 |
+
|
| 1374 |
+
const centerControl = calculateCenterControl(state.game);
|
| 1375 |
+
reward += centerControl * 0.005;
|
| 1376 |
+
|
| 1377 |
+
const mobility = state.game.moves().length;
|
| 1378 |
+
reward += mobility * 0.001;
|
| 1379 |
+
|
| 1380 |
+
if (state.game.in_check()) {
|
| 1381 |
+
reward += (agentColor === 'green' ? 0.05 : -0.05);
|
| 1382 |
+
}
|
| 1383 |
+
}
|
| 1384 |
+
|
| 1385 |
+
agent.addExperience(
|
| 1386 |
+
currentState,
|
| 1387 |
+
move,
|
| 1388 |
+
reward,
|
| 1389 |
+
nextState,
|
| 1390 |
+
state.game.game_over()
|
| 1391 |
+
);
|
| 1392 |
+
|
| 1393 |
+
const loss = await agent.trainFromMemory();
|
| 1394 |
+
if (loss > 0) {
|
| 1395 |
+
logAgent(agentColor, `Trained (loss: ${loss.toFixed(4)})`, 'info');
|
| 1396 |
+
}
|
| 1397 |
+
|
| 1398 |
+
if (state.currentGameData) {
|
| 1399 |
+
state.currentGameData.moves.push({
|
| 1400 |
+
san: move,
|
| 1401 |
+
color: currentColor,
|
| 1402 |
+
turn: state.currentGameData.moves.length + 1,
|
| 1403 |
+
timestamp: new Date().toISOString(),
|
| 1404 |
+
reward: reward,
|
| 1405 |
+
fen: state.game.fen()
|
| 1406 |
+
});
|
| 1407 |
+
state.currentGameData.positions.push(state.game.fen());
|
| 1408 |
+
}
|
| 1409 |
+
|
| 1410 |
+
renderChessBoard();
|
| 1411 |
+
updateAllMetrics();
|
| 1412 |
+
|
| 1413 |
+
setTimeout(trainingStep, 100);
|
| 1414 |
+
|
| 1415 |
+
} catch (error) {
|
| 1416 |
+
console.error("Training error:", error);
|
| 1417 |
+
log(`Training error: ${error.message}`, 'error');
|
| 1418 |
+
pauseTraining();
|
| 1419 |
+
}
|
| 1420 |
+
}
|
| 1421 |
+
|
| 1422 |
+
function startNewGame() {
|
| 1423 |
+
state.game = new Chess();
|
| 1424 |
+
state.currentGameNumber++;
|
| 1425 |
+
|
| 1426 |
+
state.currentGameData = {
|
| 1427 |
+
id: `game_${state.currentGameNumber}_${Date.now()}`,
|
| 1428 |
+
pgn: '',
|
| 1429 |
+
moves: [],
|
| 1430 |
+
positions: [state.game.fen()],
|
| 1431 |
+
start_time: new Date().toISOString(),
|
| 1432 |
+
metadata: {
|
| 1433 |
+
black_lr: state.agentStats.black.learningRate,
|
| 1434 |
+
green_lr: state.agentStats.green.learningRate,
|
| 1435 |
+
black_explore: state.agentStats.black.explorationRate,
|
| 1436 |
+
green_explore: state.agentStats.green.explorationRate,
|
| 1437 |
+
training_iteration: state.currentGameNumber
|
| 1438 |
+
}
|
| 1439 |
+
};
|
| 1440 |
+
|
| 1441 |
+
document.getElementById('current-game').textContent = state.currentGameNumber;
|
| 1442 |
+
renderChessBoard();
|
| 1443 |
+
|
| 1444 |
+
log(`Starting game #${state.currentGameNumber}`, 'info');
|
| 1445 |
+
|
| 1446 |
+
if (state.trainingActive) {
|
| 1447 |
+
setTimeout(trainingStep, 100);
|
| 1448 |
+
}
|
| 1449 |
+
}
|
| 1450 |
+
|
| 1451 |
+
function saveCurrentGame() {
|
| 1452 |
+
if (!state.currentGameData || !state.game) return;
|
| 1453 |
+
|
| 1454 |
+
const history = state.game.history();
|
| 1455 |
+
if (state.currentGameData.moves.length !== history.length) {
|
| 1456 |
+
state.currentGameData.moves = history.map((san, idx) => ({
|
| 1457 |
+
san,
|
| 1458 |
+
color: idx % 2 === 0 ? 'w' : 'b',
|
| 1459 |
+
turn: idx + 1,
|
| 1460 |
+
timestamp: new Date().toISOString(),
|
| 1461 |
+
fen: state.game.fen()
|
| 1462 |
+
}));
|
| 1463 |
+
}
|
| 1464 |
+
|
| 1465 |
+
let result = 'draw';
|
| 1466 |
+
if (state.game.in_checkmate()) {
|
| 1467 |
+
result = state.game.turn() === 'w' ? 'black' : 'green';
|
| 1468 |
+
} else if (state.game.in_draw() || state.game.in_stalemate()) {
|
| 1469 |
+
result = 'draw';
|
| 1470 |
+
} else if (state.game.in_threefold_repetition()) {
|
| 1471 |
+
result = 'draw';
|
| 1472 |
+
} else if (state.game.in_check()) {
|
| 1473 |
+
result = state.game.turn() === 'w' ? 'black' : 'green';
|
| 1474 |
+
}
|
| 1475 |
+
|
| 1476 |
+
state.currentGameData.final_fen = state.game.fen();
|
| 1477 |
+
state.currentGameData.result = result;
|
| 1478 |
+
state.currentGameData.end_time = new Date().toISOString();
|
| 1479 |
+
state.currentGameData.moves_count = state.currentGameData.moves.length;
|
| 1480 |
+
state.currentGameData.pgn = state.game.pgn();
|
| 1481 |
+
|
| 1482 |
+
state.currentGameData.agent_metadata = {
|
| 1483 |
+
black: {
|
| 1484 |
+
learning_rate: state.agentStats.black.learningRate,
|
| 1485 |
+
exploration_rate: state.agentStats.black.explorationRate,
|
| 1486 |
+
loss: state.agentStats.black.lossHistory.slice(-1)[0] || 0,
|
| 1487 |
+
total_moves: state.agentStats.black.movesMade,
|
| 1488 |
+
total_games: state.agentStats.black.totalGames
|
| 1489 |
+
},
|
| 1490 |
+
green: {
|
| 1491 |
+
learning_rate: state.agentStats.green.learningRate,
|
| 1492 |
+
exploration_rate: state.agentStats.green.explorationRate,
|
| 1493 |
+
loss: state.agentStats.green.lossHistory.slice(-1)[0] || 0,
|
| 1494 |
+
total_moves: state.agentStats.green.movesMade,
|
| 1495 |
+
total_games: state.agentStats.green.totalGames
|
| 1496 |
+
}
|
| 1497 |
+
};
|
| 1498 |
+
|
| 1499 |
+
if (validateGameData(state.currentGameData)) {
|
| 1500 |
+
const normalizedGame = normalizeGameForExport(state.currentGameData);
|
| 1501 |
+
state.dataset.push(normalizedGame);
|
| 1502 |
+
state.validGames++;
|
| 1503 |
+
|
| 1504 |
+
if (result === 'green') {
|
| 1505 |
+
state.agentStats.green.wins++;
|
| 1506 |
+
state.agentStats.black.losses++;
|
| 1507 |
+
} else if (result === 'black') {
|
| 1508 |
+
state.agentStats.black.wins++;
|
| 1509 |
+
state.agentStats.green.losses++;
|
| 1510 |
+
} else {
|
| 1511 |
+
state.agentStats.green.draws++;
|
| 1512 |
+
state.agentStats.black.draws++;
|
| 1513 |
+
}
|
| 1514 |
+
|
| 1515 |
+
state.agentStats.green.totalGames++;
|
| 1516 |
+
state.agentStats.black.totalGames++;
|
| 1517 |
+
|
| 1518 |
+
log(`Game ${state.currentGameNumber} completed: ${result} (${state.currentGameData.moves_count} moves)`, 'success');
|
| 1519 |
+
|
| 1520 |
+
if (state.validGames % 10 === 0) {
|
| 1521 |
+
log(`Auto-collected ${state.validGames} games`, 'info');
|
| 1522 |
+
}
|
| 1523 |
+
} else {
|
| 1524 |
+
log(`Game ${state.currentGameNumber} invalid - discarded`, 'warning');
|
| 1525 |
+
}
|
| 1526 |
+
}
|
| 1527 |
+
|
| 1528 |
+
function evaluateGameResult(game) {
|
| 1529 |
+
if (game.in_checkmate()) {
|
| 1530 |
+
return game.turn() === 'w' ? 'black' : 'green';
|
| 1531 |
+
}
|
| 1532 |
+
if (game.in_draw() || game.in_stalemate() || game.in_threefold_repetition()) {
|
| 1533 |
+
return 'draw';
|
| 1534 |
+
}
|
| 1535 |
+
return null;
|
| 1536 |
+
}
|
| 1537 |
+
|
| 1538 |
+
function validateGameData(gameData) {
|
| 1539 |
+
try {
|
| 1540 |
+
if (!gameData || typeof gameData !== 'object') return false;
|
| 1541 |
+
if (!gameData.moves || !Array.isArray(gameData.moves)) return false;
|
| 1542 |
+
if (!gameData.result || !['black', 'green', 'draw'].includes(gameData.result)) return false;
|
| 1543 |
+
|
| 1544 |
+
if (gameData.moves.length > 0) {
|
| 1545 |
+
const testGame = new Chess();
|
| 1546 |
+
|
| 1547 |
+
for (let i = 0; i < gameData.moves.length; i++) {
|
| 1548 |
+
const move = gameData.moves[i];
|
| 1549 |
+
if (!testGame.move(move.san)) {
|
| 1550 |
+
log(`Move ${i+1} invalid: ${move.san}`, 'warning');
|
| 1551 |
+
}
|
| 1552 |
+
}
|
| 1553 |
+
}
|
| 1554 |
+
|
| 1555 |
+
return gameData.moves_count === gameData.moves.length &&
|
| 1556 |
+
gameData.id &&
|
| 1557 |
+
gameData.start_time;
|
| 1558 |
+
} catch (error) {
|
| 1559 |
+
log(`Validation error: ${error.message}`, 'warning');
|
| 1560 |
+
return false;
|
| 1561 |
+
}
|
| 1562 |
+
}
|
| 1563 |
+
|
| 1564 |
+
function pauseTraining() {
|
| 1565 |
+
state.trainingActive = false;
|
| 1566 |
+
document.getElementById('start-btn').style.display = 'inline-block';
|
| 1567 |
+
document.getElementById('pause-btn').style.display = 'none';
|
| 1568 |
+
|
| 1569 |
+
if (state.trainingTimer) {
|
| 1570 |
+
clearInterval(state.trainingTimer);
|
| 1571 |
+
state.trainingTimer = null;
|
| 1572 |
+
}
|
| 1573 |
+
|
| 1574 |
+
stopRealTimeMonitoring();
|
| 1575 |
+
|
| 1576 |
+
log('Training paused', 'warning');
|
| 1577 |
+
}
|
| 1578 |
+
|
| 1579 |
+
function resetTraining() {
|
| 1580 |
+
if (state.trainingActive) {
|
| 1581 |
+
pauseTraining();
|
| 1582 |
+
}
|
| 1583 |
+
|
| 1584 |
+
state.game = new Chess();
|
| 1585 |
+
state.currentGameNumber = 1;
|
| 1586 |
+
state.dataset = [];
|
| 1587 |
+
state.validGames = 0;
|
| 1588 |
+
state.totalMoves = 0;
|
| 1589 |
+
state.currentGameData = null;
|
| 1590 |
+
state.lastAutoSave = null;
|
| 1591 |
+
|
| 1592 |
+
state.agentStats = {
|
| 1593 |
+
black: {
|
| 1594 |
+
wins: 0,
|
| 1595 |
+
losses: 0,
|
| 1596 |
+
draws: 0,
|
| 1597 |
+
totalGames: 0,
|
| 1598 |
+
movesMade: 0,
|
| 1599 |
+
learningRate: 0.001,
|
| 1600 |
+
explorationRate: 0.3,
|
| 1601 |
+
discountFactor: 0.95,
|
| 1602 |
+
lossHistory: []
|
| 1603 |
+
},
|
| 1604 |
+
green: {
|
| 1605 |
+
wins: 0,
|
| 1606 |
+
losses: 0,
|
| 1607 |
+
draws: 0,
|
| 1608 |
+
totalGames: 0,
|
| 1609 |
+
movesMade: 0,
|
| 1610 |
+
learningRate: 0.001,
|
| 1611 |
+
explorationRate: 0.3,
|
| 1612 |
+
discountFactor: 0.95,
|
| 1613 |
+
lossHistory: []
|
| 1614 |
+
}
|
| 1615 |
+
};
|
| 1616 |
+
|
| 1617 |
+
initializeNeuralNetworks();
|
| 1618 |
+
|
| 1619 |
+
renderChessBoard();
|
| 1620 |
+
updateAllMetrics();
|
| 1621 |
+
|
| 1622 |
+
document.getElementById('current-game').textContent = '1';
|
| 1623 |
+
document.getElementById('current-moves').textContent = '0';
|
| 1624 |
+
document.getElementById('training-timer').textContent = '00:00:00';
|
| 1625 |
+
|
| 1626 |
+
log('Training completely reset - all data cleared', 'success');
|
| 1627 |
+
}
|
| 1628 |
+
|
| 1629 |
+
// Real-time Monitoring Functions
|
| 1630 |
+
function startRealTimeMonitoring() {
|
| 1631 |
+
if (state.realTimeInterval) {
|
| 1632 |
+
clearInterval(state.realTimeInterval);
|
| 1633 |
+
}
|
| 1634 |
+
|
| 1635 |
+
state.realTimeInterval = setInterval(() => {
|
| 1636 |
+
if (state.trainingActive) {
|
| 1637 |
+
updateAllMetrics();
|
| 1638 |
+
|
| 1639 |
+
if (Date.now() - (state.lastAutoSave || 0) > 5 * 60 * 1000) {
|
| 1640 |
+
saveState();
|
| 1641 |
+
state.lastAutoSave = Date.now();
|
| 1642 |
+
log('Auto-saved training state', 'info');
|
| 1643 |
+
}
|
| 1644 |
+
|
| 1645 |
+
const progress = Math.min(100, (state.totalMoves % 1000) / 10);
|
| 1646 |
+
const progressBar = document.getElementById('training-progress');
|
| 1647 |
+
if (progressBar) {
|
| 1648 |
+
progressBar.style.width = `${progress}%`;
|
| 1649 |
+
}
|
| 1650 |
+
}
|
| 1651 |
+
}, 1000);
|
| 1652 |
+
}
|
| 1653 |
+
|
| 1654 |
+
function stopRealTimeMonitoring() {
|
| 1655 |
+
if (state.realTimeInterval) {
|
| 1656 |
+
clearInterval(state.realTimeInterval);
|
| 1657 |
+
state.realTimeInterval = null;
|
| 1658 |
+
}
|
| 1659 |
+
}
|
| 1660 |
+
|
| 1661 |
+
// UI Update Functions
|
| 1662 |
+
function updateAgentParam(agent, param, value) {
|
| 1663 |
+
if (!state.agentStats[agent]) return;
|
| 1664 |
+
|
| 1665 |
+
state.agentStats[agent][param] = value;
|
| 1666 |
+
|
| 1667 |
+
if (param === 'learningRate' && state.neuralNetworks[agent]) {
|
| 1668 |
+
state.neuralNetworks[agent].updateLearningRate(value);
|
| 1669 |
+
}
|
| 1670 |
+
|
| 1671 |
+
const elementId = `${agent}-${param}-value`;
|
| 1672 |
+
const element = document.getElementById(elementId);
|
| 1673 |
+
if (element) {
|
| 1674 |
+
element.textContent = param === 'learningRate' ? value.toFixed(4) : value.toFixed(2);
|
| 1675 |
+
}
|
| 1676 |
+
|
| 1677 |
+
logAgent(agent, `${param} set to ${value}`, 'info');
|
| 1678 |
+
updateAllMetrics();
|
| 1679 |
+
}
|
| 1680 |
+
|
| 1681 |
+
function updateAllMetrics() {
|
| 1682 |
+
// Black agent metrics
|
| 1683 |
+
const blackTotal = Math.max(1, state.agentStats.black.totalGames);
|
| 1684 |
+
const blackWinRate = (state.agentStats.black.wins / blackTotal * 100).toFixed(1);
|
| 1685 |
+
const blackLoss = state.agentStats.black.lossHistory.length > 0 ?
|
| 1686 |
+
state.agentStats.black.lossHistory.slice(-1)[0].toFixed(3) : '0.000';
|
| 1687 |
+
|
| 1688 |
+
document.getElementById('black-win-rate').innerHTML = `${blackWinRate}<span class="metric-unit">%</span>`;
|
| 1689 |
+
document.getElementById('black-loss').textContent = blackLoss;
|
| 1690 |
+
document.getElementById('black-lr').textContent = state.agentStats.black.learningRate.toFixed(4);
|
| 1691 |
+
document.getElementById('black-explore').textContent = state.agentStats.black.explorationRate.toFixed(2);
|
| 1692 |
+
document.getElementById('black-games').textContent = state.agentStats.black.totalGames;
|
| 1693 |
+
document.getElementById('black-moves').textContent = state.agentStats.black.movesMade;
|
| 1694 |
+
|
| 1695 |
+
// Green agent metrics
|
| 1696 |
+
const greenTotal = Math.max(1, state.agentStats.green.totalGames);
|
| 1697 |
+
const greenWinRate = (state.agentStats.green.wins / greenTotal * 100).toFixed(1);
|
| 1698 |
+
const greenLoss = state.agentStats.green.lossHistory.length > 0 ?
|
| 1699 |
+
state.agentStats.green.lossHistory.slice(-1)[0].toFixed(3) : '0.000';
|
| 1700 |
+
|
| 1701 |
+
document.getElementById('green-win-rate').innerHTML = `${greenWinRate}<span class="metric-unit">%</span>`;
|
| 1702 |
+
document.getElementById('green-loss').textContent = greenLoss;
|
| 1703 |
+
document.getElementById('green-lr').textContent = state.agentStats.green.learningRate.toFixed(4);
|
| 1704 |
+
document.getElementById('green-explore').textContent = state.agentStats.green.explorationRate.toFixed(2);
|
| 1705 |
+
document.getElementById('green-games').textContent = state.agentStats.green.totalGames;
|
| 1706 |
+
document.getElementById('green-moves').textContent = state.agentStats.green.movesMade;
|
| 1707 |
+
|
| 1708 |
+
// Overall training metrics
|
| 1709 |
+
document.getElementById('total-games').textContent = state.validGames;
|
| 1710 |
+
document.getElementById('total-moves').textContent = state.totalMoves;
|
| 1711 |
+
|
| 1712 |
+
// Training progress
|
| 1713 |
+
const progress = Math.min(100, (state.totalMoves % 1000) / 10);
|
| 1714 |
+
const progressBar = document.getElementById('training-progress');
|
| 1715 |
+
if (progressBar) {
|
| 1716 |
+
progressBar.style.width = `${progress}%`;
|
| 1717 |
+
}
|
| 1718 |
+
}
|
| 1719 |
+
|
| 1720 |
+
function startTrainingTimer() {
|
| 1721 |
+
let seconds = 0;
|
| 1722 |
+
|
| 1723 |
+
if (state.trainingTimer) {
|
| 1724 |
+
clearInterval(state.trainingTimer);
|
| 1725 |
+
}
|
| 1726 |
+
|
| 1727 |
+
state.trainingTimer = setInterval(() => {
|
| 1728 |
+
seconds++;
|
| 1729 |
+
const hours = Math.floor(seconds / 3600);
|
| 1730 |
+
const minutes = Math.floor((seconds % 3600) / 60);
|
| 1731 |
+
const secs = seconds % 60;
|
| 1732 |
+
|
| 1733 |
+
document.getElementById('training-timer').textContent =
|
| 1734 |
+
`${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
|
| 1735 |
+
}, 1000);
|
| 1736 |
+
}
|
| 1737 |
+
|
| 1738 |
+
// Logging Functions
|
| 1739 |
+
function log(message, type = 'info') {
|
| 1740 |
+
const terminal = document.getElementById('main-terminal');
|
| 1741 |
+
if (!terminal) return;
|
| 1742 |
+
|
| 1743 |
+
const line = document.createElement('div');
|
| 1744 |
+
line.className = `terminal-line ${type}`;
|
| 1745 |
+
line.textContent = `[${new Date().toLocaleTimeString()}] ${message}`;
|
| 1746 |
+
terminal.appendChild(line);
|
| 1747 |
+
|
| 1748 |
+
if (terminal.children.length > 100) {
|
| 1749 |
+
terminal.removeChild(terminal.firstChild);
|
| 1750 |
+
}
|
| 1751 |
+
|
| 1752 |
+
terminal.scrollTop = terminal.scrollHeight;
|
| 1753 |
+
}
|
| 1754 |
+
|
| 1755 |
+
function logAgent(agent, message, type = 'info') {
|
| 1756 |
+
const logContent = document.getElementById(`${agent}-log-content`);
|
| 1757 |
+
const logCount = document.getElementById(`${agent}-log-count`);
|
| 1758 |
+
|
| 1759 |
+
if (!logContent || !logCount) return;
|
| 1760 |
+
|
| 1761 |
+
const line = document.createElement('div');
|
| 1762 |
+
line.className = `log-line ${type}`;
|
| 1763 |
+
line.textContent = `[${new Date().toLocaleTimeString()}] ${message}`;
|
| 1764 |
+
logContent.appendChild(line);
|
| 1765 |
+
|
| 1766 |
+
const count = logContent.children.length;
|
| 1767 |
+
logCount.textContent = count;
|
| 1768 |
+
|
| 1769 |
+
if (count > 50) {
|
| 1770 |
+
logContent.removeChild(logContent.firstChild);
|
| 1771 |
+
}
|
| 1772 |
+
|
| 1773 |
+
logContent.scrollTop = logContent.scrollHeight;
|
| 1774 |
+
}
|
| 1775 |
+
|
| 1776 |
+
// SIMPLIFIED EXPORT FUNCTION - ONE BUTTON EXPORTS EVERYTHING
|
| 1777 |
+
async function exportEverything() {
|
| 1778 |
+
log('Starting export of all training data and models...', 'info');
|
| 1779 |
+
|
| 1780 |
+
try {
|
| 1781 |
+
// Create ZIP file
|
| 1782 |
+
const zip = new JSZip();
|
| 1783 |
+
|
| 1784 |
+
// 1. Export all training games
|
| 1785 |
+
if (state.dataset.length > 0) {
|
| 1786 |
+
log(`Exporting ${state.dataset.length} training games...`, 'info');
|
| 1787 |
+
const gamesData = JSON.stringify(state.dataset, null, 2);
|
| 1788 |
+
zip.file("training_games.json", gamesData);
|
| 1789 |
+
|
| 1790 |
+
// Also create a CSV version for compatibility
|
| 1791 |
+
const csvHeader = "id,pgn,result,moves_count,start_time,end_time,final_fen\n";
|
| 1792 |
+
const csvRows = state.dataset.map(g =>
|
| 1793 |
+
`"${g.id}","${g.pgn.replace(/"/g, '""')}","${g.result}",${g.moves_count},"${g.start_time}","${g.end_time}","${g.final_fen}"`
|
| 1794 |
+
).join('\n');
|
| 1795 |
+
zip.file("training_games.csv", csvHeader + csvRows);
|
| 1796 |
+
} else {
|
| 1797 |
+
log('No training games to export', 'warning');
|
| 1798 |
+
}
|
| 1799 |
+
|
| 1800 |
+
// 2. Export neural network models
|
| 1801 |
+
log('Exporting neural network models...', 'info');
|
| 1802 |
+
|
| 1803 |
+
// Black agent model
|
| 1804 |
+
if (state.neuralNetworks.black) {
|
| 1805 |
+
const blackModelData = {
|
| 1806 |
+
model_type: "chess_policy_network",
|
| 1807 |
+
color: "black",
|
| 1808 |
+
architecture: {
|
| 1809 |
+
input_size: 896,
|
| 1810 |
+
hidden_layers: [128, 64, 32],
|
| 1811 |
+
output_size: 1,
|
| 1812 |
+
activation: ["relu", "relu", "relu", "tanh"],
|
| 1813 |
+
dropout: 0.2
|
| 1814 |
+
},
|
| 1815 |
+
hyperparameters: {
|
| 1816 |
+
learning_rate: state.agentStats.black.learningRate,
|
| 1817 |
+
exploration_rate: state.agentStats.black.explorationRate,
|
| 1818 |
+
discount_factor: state.agentStats.black.discountFactor
|
| 1819 |
+
},
|
| 1820 |
+
training_stats: {
|
| 1821 |
+
wins: state.agentStats.black.wins,
|
| 1822 |
+
losses: state.agentStats.black.losses,
|
| 1823 |
+
draws: state.agentStats.black.draws,
|
| 1824 |
+
total_games: state.agentStats.black.totalGames,
|
| 1825 |
+
moves_made: state.agentStats.black.movesMade
|
| 1826 |
+
},
|
| 1827 |
+
export_timestamp: new Date().toISOString()
|
| 1828 |
+
};
|
| 1829 |
+
|
| 1830 |
+
zip.file("black_agent_model.json", JSON.stringify(blackModelData, null, 2));
|
| 1831 |
+
}
|
| 1832 |
+
|
| 1833 |
+
// Green agent model
|
| 1834 |
+
if (state.neuralNetworks.green) {
|
| 1835 |
+
const greenModelData = {
|
| 1836 |
+
model_type: "chess_value_network",
|
| 1837 |
+
color: "green",
|
| 1838 |
+
architecture: {
|
| 1839 |
+
input_size: 896,
|
| 1840 |
+
hidden_layers: [128, 64, 32],
|
| 1841 |
+
output_size: 1,
|
| 1842 |
+
activation: ["relu", "relu", "relu", "tanh"],
|
| 1843 |
+
dropout: 0.2
|
| 1844 |
+
},
|
| 1845 |
+
hyperparameters: {
|
| 1846 |
+
learning_rate: state.agentStats.green.learningRate,
|
| 1847 |
+
exploration_rate: state.agentStats.green.explorationRate,
|
| 1848 |
+
discount_factor: state.agentStats.green.discountFactor
|
| 1849 |
+
},
|
| 1850 |
+
training_stats: {
|
| 1851 |
+
wins: state.agentStats.green.wins,
|
| 1852 |
+
losses: state.agentStats.green.losses,
|
| 1853 |
+
draws: state.agentStats.green.draws,
|
| 1854 |
+
total_games: state.agentStats.green.totalGames,
|
| 1855 |
+
moves_made: state.agentStats.green.movesMade
|
| 1856 |
+
},
|
| 1857 |
+
export_timestamp: new Date().toISOString()
|
| 1858 |
+
};
|
| 1859 |
+
|
| 1860 |
+
zip.file("green_agent_model.json", JSON.stringify(greenModelData, null, 2));
|
| 1861 |
+
}
|
| 1862 |
+
|
| 1863 |
+
// 3. Export training statistics
|
| 1864 |
+
log('Exporting training statistics...', 'info');
|
| 1865 |
+
const statsData = {
|
| 1866 |
+
training_summary: {
|
| 1867 |
+
total_games: state.validGames,
|
| 1868 |
+
total_moves: state.totalMoves,
|
| 1869 |
+
training_time: document.getElementById('training-timer').textContent,
|
| 1870 |
+
current_game: state.currentGameNumber,
|
| 1871 |
+
training_active: state.trainingActive
|
| 1872 |
+
},
|
| 1873 |
+
agent_comparison: {
|
| 1874 |
+
black_win_rate: ((state.agentStats.black.wins / Math.max(1, state.agentStats.black.totalGames)) * 100).toFixed(1),
|
| 1875 |
+
green_win_rate: ((state.agentStats.green.wins / Math.max(1, state.agentStats.green.totalGames)) * 100).toFixed(1),
|
| 1876 |
+
draws_rate: ((state.agentStats.black.draws / Math.max(1, state.agentStats.black.totalGames)) * 100).toFixed(1)
|
| 1877 |
+
},
|
| 1878 |
+
export_timestamp: new Date().toISOString(),
|
| 1879 |
+
system_info: {
|
| 1880 |
+
user_agent: navigator.userAgent,
|
| 1881 |
+
platform: navigator.platform,
|
| 1882 |
+
screen_resolution: `${window.screen.width}x${window.screen.height}`
|
| 1883 |
+
}
|
| 1884 |
+
};
|
| 1885 |
+
|
| 1886 |
+
zip.file("training_statistics.json", JSON.stringify(statsData, null, 2));
|
| 1887 |
+
|
| 1888 |
+
// 4. Create README file
|
| 1889 |
+
log('Creating documentation...', 'info');
|
| 1890 |
+
const readme = `# Chess RL Training Export
|
| 1891 |
+
|
| 1892 |
+
## Export Information
|
| 1893 |
+
- Export Date: ${new Date().toISOString()}
|
| 1894 |
+
- Total Training Games: ${state.validGames}
|
| 1895 |
+
- Total Moves: ${state.totalMoves}
|
| 1896 |
+
- Training Time: ${document.getElementById('training-timer').textContent}
|
| 1897 |
+
|
| 1898 |
+
## Files Included
|
| 1899 |
+
|
| 1900 |
+
### 1. training_games.json
|
| 1901 |
+
Complete dataset of all chess games played during training. Each game includes:
|
| 1902 |
+
- Full PGN notation
|
| 1903 |
+
- Move-by-move records
|
| 1904 |
+
- Game result and metadata
|
| 1905 |
+
- Agent parameters for each game
|
| 1906 |
+
|
| 1907 |
+
### 2. training_games.csv
|
| 1908 |
+
Same data as JSON but in CSV format for easy import into spreadsheets or databases.
|
| 1909 |
+
|
| 1910 |
+
### 3. black_agent_model.json
|
| 1911 |
+
Black Agent (Policy Network) configuration and statistics:
|
| 1912 |
+
- Neural network architecture
|
| 1913 |
+
- Hyperparameters (learning rate, exploration rate, etc.)
|
| 1914 |
+
- Training statistics (wins, losses, draws)
|
| 1915 |
+
- Model metadata
|
| 1916 |
+
|
| 1917 |
+
### 4. green_agent_model.json
|
| 1918 |
+
Green Agent (Value Network) configuration and statistics:
|
| 1919 |
+
- Neural network architecture
|
| 1920 |
+
- Hyperparameters
|
| 1921 |
+
- Training statistics
|
| 1922 |
+
- Model metadata
|
| 1923 |
+
|
| 1924 |
+
### 5. training_statistics.json
|
| 1925 |
+
Overall training summary and statistics including:
|
| 1926 |
+
- Training duration
|
| 1927 |
+
- Win rates for both agents
|
| 1928 |
+
- System information
|
| 1929 |
+
- Export metadata
|
| 1930 |
+
|
| 1931 |
+
## Training System
|
| 1932 |
+
Generated by ANN Chess RL Trainer v3.0 - A web-based reinforcement learning system for chess AI development.
|
| 1933 |
+
|
| 1934 |
+
## Usage
|
| 1935 |
+
These files can be used to:
|
| 1936 |
+
- Continue training from this point
|
| 1937 |
+
- Analyze the learning progress
|
| 1938 |
+
- Import into other machine learning frameworks
|
| 1939 |
+
- Share with the research community
|
| 1940 |
+
|
| 1941 |
+
## Notes
|
| 1942 |
+
- All data is in standard JSON/CSV formats
|
| 1943 |
+
- Compatible with Hugging Face datasets
|
| 1944 |
+
- Can be compressed with GZIP, ZSTD, BZ2, LZ4, or LZMA for upload
|
| 1945 |
+
`;
|
| 1946 |
+
|
| 1947 |
+
zip.file("README.md", readme);
|
| 1948 |
+
|
| 1949 |
+
// 5. Generate and download ZIP
|
| 1950 |
+
log('Generating ZIP archive...', 'info');
|
| 1951 |
+
const content = await zip.generateAsync({
|
| 1952 |
+
type: "blob",
|
| 1953 |
+
compression: "DEFLATE",
|
| 1954 |
+
compressionOptions: {
|
| 1955 |
+
level: 6
|
| 1956 |
+
}
|
| 1957 |
+
});
|
| 1958 |
+
|
| 1959 |
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
| 1960 |
+
const filename = `chess_rl_training_export_${timestamp}.zip`;
|
| 1961 |
+
const url = URL.createObjectURL(content);
|
| 1962 |
+
const a = document.createElement('a');
|
| 1963 |
+
a.href = url;
|
| 1964 |
+
a.download = filename;
|
| 1965 |
+
document.body.appendChild(a);
|
| 1966 |
+
a.click();
|
| 1967 |
+
document.body.removeChild(a);
|
| 1968 |
+
URL.revokeObjectURL(url);
|
| 1969 |
+
|
| 1970 |
+
log(`Export completed successfully! File: ${filename}`, 'success');
|
| 1971 |
+
log('The ZIP file contains all training data, models, and statistics.', 'info');
|
| 1972 |
+
|
| 1973 |
+
} catch (error) {
|
| 1974 |
+
console.error('Export error:', error);
|
| 1975 |
+
log(`Export failed: ${error.message}`, 'error');
|
| 1976 |
+
}
|
| 1977 |
+
}
|
| 1978 |
+
|
| 1979 |
+
function saveState() {
|
| 1980 |
+
const stateData = {
|
| 1981 |
+
agentStats: state.agentStats,
|
| 1982 |
+
dataset: state.dataset.slice(-50),
|
| 1983 |
+
validGames: state.validGames,
|
| 1984 |
+
totalMoves: state.totalMoves,
|
| 1985 |
+
currentGame: {
|
| 1986 |
+
number: state.currentGameNumber,
|
| 1987 |
+
fen: state.game ? state.game.fen() : null
|
| 1988 |
+
},
|
| 1989 |
+
timestamp: new Date().toISOString(),
|
| 1990 |
+
training_time: document.getElementById('training-timer').textContent
|
| 1991 |
+
};
|
| 1992 |
+
|
| 1993 |
+
const blob = new Blob([JSON.stringify(stateData, null, 2)], { type: 'application/json' });
|
| 1994 |
+
const url = URL.createObjectURL(blob);
|
| 1995 |
+
const a = document.createElement('a');
|
| 1996 |
+
a.href = url;
|
| 1997 |
+
a.download = `chess_rl_state_${Date.now()}.json`;
|
| 1998 |
+
a.click();
|
| 1999 |
+
URL.revokeObjectURL(url);
|
| 2000 |
+
|
| 2001 |
+
state.lastAutoSave = Date.now();
|
| 2002 |
+
log('Training state saved locally', 'success');
|
| 2003 |
+
}
|
| 2004 |
+
|
| 2005 |
+
// Initialization
|
| 2006 |
+
async function initializeNeuralNetworks() {
|
| 2007 |
+
log('Initializing neural networks...', 'info');
|
| 2008 |
+
|
| 2009 |
+
state.neuralNetworks.black = new ChessNeuralNetwork('BlackAgent', 'black', state.agentStats.black.learningRate);
|
| 2010 |
+
state.neuralNetworks.green = new ChessNeuralNetwork('GreenAgent', 'green', state.agentStats.green.learningRate);
|
| 2011 |
+
|
| 2012 |
+
state.agents.black = new RLAgent('black', state.neuralNetworks.black);
|
| 2013 |
+
state.agents.green = new RLAgent('green', state.neuralNetworks.green);
|
| 2014 |
+
|
| 2015 |
+
state.game = new Chess();
|
| 2016 |
+
|
| 2017 |
+
visualizeNeuralNetwork('black-nn-viz', 'black');
|
| 2018 |
+
visualizeNeuralNetwork('green-nn-viz', 'green');
|
| 2019 |
+
|
| 2020 |
+
log('Neural networks initialized successfully', 'success');
|
| 2021 |
+
logAgent('black', 'Neural network ready', 'success');
|
| 2022 |
+
logAgent('green', 'Neural network ready', 'success');
|
| 2023 |
+
}
|
| 2024 |
+
|
| 2025 |
+
async function init() {
|
| 2026 |
+
const loadingBar = document.querySelector('.loading-bar');
|
| 2027 |
+
const loadingDetails = document.getElementById('loading-details');
|
| 2028 |
+
|
| 2029 |
+
const steps = [
|
| 2030 |
+
'Loading TensorFlow.js...',
|
| 2031 |
+
'Initializing neural networks...',
|
| 2032 |
+
'Setting up RL agents...',
|
| 2033 |
+
'Preparing visualization...',
|
| 2034 |
+
'Starting training environment...'
|
| 2035 |
+
];
|
| 2036 |
+
|
| 2037 |
+
for (let i = 0; i < steps.length; i++) {
|
| 2038 |
+
if (loadingDetails) {
|
| 2039 |
+
loadingDetails.textContent = steps[i];
|
| 2040 |
+
}
|
| 2041 |
+
if (loadingBar) {
|
| 2042 |
+
loadingBar.style.width = `${((i + 1) / steps.length) * 100}%`;
|
| 2043 |
+
}
|
| 2044 |
+
await new Promise(resolve => setTimeout(resolve, 300));
|
| 2045 |
+
}
|
| 2046 |
+
|
| 2047 |
+
try {
|
| 2048 |
+
await initializeNeuralNetworks();
|
| 2049 |
+
updateQuantumBackground();
|
| 2050 |
+
renderChessBoard();
|
| 2051 |
+
updateAllMetrics();
|
| 2052 |
+
|
| 2053 |
+
document.getElementById('loading-screen').style.display = 'none';
|
| 2054 |
+
document.querySelector('.container').style.opacity = '1';
|
| 2055 |
+
|
| 2056 |
+
log('ANN Chess RL Trainer v3.0 ready!', 'success');
|
| 2057 |
+
log('Left: Black Agent (Policy Network)', 'info');
|
| 2058 |
+
log('Right: Green Agent (Value Network)', 'info');
|
| 2059 |
+
log('Click "Start Training" to begin reinforcement learning', 'info');
|
| 2060 |
+
log('Click "Export All" to download everything as a ZIP file', 'info');
|
| 2061 |
+
log('ZIP includes: games, models, statistics in JSON/CSV formats', 'info');
|
| 2062 |
+
|
| 2063 |
+
} catch (error) {
|
| 2064 |
+
log(`Initialization failed: ${error.message}`, 'error');
|
| 2065 |
+
console.error(error);
|
| 2066 |
+
}
|
| 2067 |
+
}
|
| 2068 |
+
|
| 2069 |
+
// Initialize on load
|
| 2070 |
+
window.addEventListener('load', init);
|
| 2071 |
+
window.addEventListener('resize', updateQuantumBackground);
|
| 2072 |
+
</script>
|
| 2073 |
+
</body>
|
| 2074 |
+
</html>
|