Lookimi commited on
Commit
83791a4
·
verified ·
1 Parent(s): fdeb327

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +731 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Myawesomeface
3
- emoji: 📊
4
- colorFrom: gray
5
- colorTo: gray
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: myawesomeface
3
+ emoji: 🐳
4
+ colorFrom: green
5
+ colorTo: yellow
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,731 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>Neon Mutation Breakout - AI Edition</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <style>
9
+ body {
10
+ margin: 0;
11
+ overflow: hidden;
12
+ background-color: #0f172a;
13
+ font-family: 'Courier New', monospace;
14
+ }
15
+ canvas {
16
+ display: block;
17
+ }
18
+ .status-panel {
19
+ position: absolute;
20
+ top: 20px;
21
+ right: 20px;
22
+ width: 300px;
23
+ background: rgba(15, 23, 42, 0.8);
24
+ border: 2px solid #4f46e5;
25
+ border-radius: 8px;
26
+ padding: 15px;
27
+ color: #e2e8f0;
28
+ font-size: 14px;
29
+ box-shadow: 0 0 20px #4f46e5;
30
+ max-height: 80vh;
31
+ overflow-y: auto;
32
+ }
33
+ .mutation-event {
34
+ margin-bottom: 10px;
35
+ padding-bottom: 10px;
36
+ border-bottom: 1px solid #334155;
37
+ animation: pulse 0.5s;
38
+ }
39
+ @keyframes pulse {
40
+ 0% { background-color: rgba(79, 70, 229, 0); }
41
+ 50% { background-color: rgba(79, 70, 229, 0.3); }
42
+ 100% { background-color rgba(79, 70, 229, 0); }
43
+ }
44
+ .mutation-positive {
45
+ color: #4ade80;
46
+ }
47
+ .mutation-negative {
48
+ color: #f87171;
49
+ }
50
+ .mutation-neutral {
51
+ color: #60a5fa;
52
+ }
53
+ .title {
54
+ position: absolute;
55
+ top: 20px;
56
+ left: 20px;
57
+ color: #e2e8f0;
58
+ font-size: 24px;
59
+ text-shadow: 0 0 10px #4f46e5;
60
+ }
61
+ .score {
62
+ position: absolute;
63
+ top: 60px;
64
+ left: 20px;
65
+ color: #e2e8f0;
66
+ font-size: 18px;
67
+ text-shadow: 0 0 5px #4f46e5;
68
+ }
69
+ .game-over {
70
+ position: absolute;
71
+ top: 50%;
72
+ left: 50%;
73
+ transform: translate(-50%, -50%);
74
+ background: rgba(15, 23, 42, 0.9);
75
+ border: 2px solid #4f46e5;
76
+ border-radius: 8px;
77
+ padding: 30px;
78
+ color: #e2e8f0;
79
+ text-align: center;
80
+ box-shadow: 0 0 30px #4f46e5;
81
+ display: none;
82
+ }
83
+ .restart-btn {
84
+ background: #4f46e5;
85
+ color: white;
86
+ border: none;
87
+ padding: 10px 20px;
88
+ margin-top: 20px;
89
+ border-radius: 5px;
90
+ cursor: pointer;
91
+ font-family: 'Courier New', monospace;
92
+ font-size: 16px;
93
+ transition: all 0.3s;
94
+ }
95
+ .restart-btn:hover {
96
+ background: #6366f1;
97
+ transform: scale(1.05);
98
+ }
99
+ .speed-indicator {
100
+ position: absolute;
101
+ bottom: 20px;
102
+ left: 20px;
103
+ color: #e2e8f0;
104
+ font-size: 14px;
105
+ }
106
+ .speed-bar {
107
+ height: 5px;
108
+ background: linear-gradient(90deg, #4f46e5, #ec4899);
109
+ margin-top: 5px;
110
+ border-radius: 5px;
111
+ }
112
+ .ai-controls {
113
+ position: absolute;
114
+ bottom: 20px;
115
+ right: 20px;
116
+ display: flex;
117
+ gap: 10px;
118
+ }
119
+ .ai-btn {
120
+ background: rgba(79, 70, 229, 0.7);
121
+ color: white;
122
+ border: none;
123
+ width: 60px;
124
+ height: 60px;
125
+ border-radius: 50%;
126
+ font-size: 24px;
127
+ cursor: pointer;
128
+ transition: all 0.2s;
129
+ box-shadow: 0 0 10px #4f46e5;
130
+ }
131
+ .ai-btn:hover {
132
+ background: rgba(79, 70, 229, 1);
133
+ transform: scale(1.1);
134
+ }
135
+ .ai-btn:active {
136
+ transform: scale(0.95);
137
+ }
138
+ .ai-mode {
139
+ position: absolute;
140
+ top: 100px;
141
+ left: 20px;
142
+ color: #e2e8f0;
143
+ font-size: 14px;
144
+ }
145
+ .ai-learning {
146
+ position: absolute;
147
+ top: 120px;
148
+ left: 20px;
149
+ color: #e2e8f0;
150
+ font-size: 14px;
151
+ }
152
+ </style>
153
+ </head>
154
+ <body>
155
+ <div class="title">NEON MUTATION BREAKOUT - PERFECT AI</div>
156
+ <div class="score">SCORE: <span id="score">0</span></div>
157
+ <div class="ai-mode">AI MODE: <span id="ai-mode">PERFECT</span></div>
158
+ <div class="ai-learning">AI LEARNING RATE: <span id="ai-learning">100%</span></div>
159
+ <div class="speed-indicator">
160
+ GAME SPEED: <span id="speed">1.0x</span>
161
+ <div class="speed-bar" id="speed-bar"></div>
162
+ </div>
163
+
164
+ <div class="status-panel">
165
+ <h3 class="text-lg font-bold mb-4 text-center border-b border-indigo-500 pb-2">MUTATION EVENTS</h3>
166
+ <div id="mutation-log"></div>
167
+ </div>
168
+
169
+ <div class="game-over" id="game-over">
170
+ <h2 class="text-2xl font-bold mb-4">LEVEL COMPLETE</h2>
171
+ <p>Final Score: <span id="final-score">0</span></p>
172
+ <p>Mutations Achieved: <span id="mutation-count">0</span></p>
173
+ <p>AI Mastery: <span id="ai-mastery">100%</span></p>
174
+ <button class="restart-btn" id="restart-btn">NEXT LEVEL</button>
175
+ </div>
176
+
177
+ <div class="ai-controls">
178
+ <button class="ai-btn" id="ai-train-btn">🧠</button>
179
+ <button class="ai-btn" id="ai-play-btn">🤖</button>
180
+ </div>
181
+
182
+ <canvas id="gameCanvas"></canvas>
183
+
184
+ <script>
185
+ // Game canvas setup
186
+ const canvas = document.getElementById('gameCanvas');
187
+ const ctx = canvas.getContext('2d');
188
+ canvas.width = window.innerWidth;
189
+ canvas.height = window.innerHeight;
190
+
191
+ // Game state
192
+ let gameRunning = true;
193
+ let score = 0;
194
+ let gameSpeed = 1.0;
195
+ let speedIncreaseTimer = 0;
196
+ let mutationCount = 0;
197
+ let lastMutationTime = 0;
198
+
199
+ // AI state
200
+ let aiMode = 'PERFECT'; // 'LEARNING' or 'PLAYING' or 'PERFECT'
201
+ let aiLearningRate = 1.0;
202
+ let aiMastery = 1.0;
203
+ let aiMemory = [];
204
+ let aiDecisionThreshold = 1.0;
205
+
206
+ // Paddle
207
+ const paddle = {
208
+ width: 100,
209
+ height: 15,
210
+ x: canvas.width / 2 - 50,
211
+ y: canvas.height - 30,
212
+ speed: 15,
213
+ color: '#4f46e5'
214
+ };
215
+
216
+ // Ball
217
+ const ball = {
218
+ radius: 10,
219
+ x: canvas.width / 2,
220
+ y: canvas.height / 2,
221
+ dx: 5 * gameSpeed,
222
+ dy: -5 * gameSpeed,
223
+ color: '#ec4899',
224
+ speed: 5
225
+ };
226
+
227
+ // Bricks
228
+ const brick = {
229
+ rowCount: 5,
230
+ columnCount: 10,
231
+ width: 75,
232
+ height: 20,
233
+ padding: 10,
234
+ offsetTop: 60,
235
+ offsetLeft: 30,
236
+ colors: ['#4f46e5', '#6366f1', '#818cf8', '#a5b4fc', '#c7d2fe']
237
+ };
238
+
239
+ let bricks = [];
240
+ function initBricks() {
241
+ bricks = [];
242
+ for (let c = 0; c < brick.columnCount; c++) {
243
+ bricks[c] = [];
244
+ for (let r = 0; r < brick.rowCount; r++) {
245
+ bricks[c][r] = { x: 0, y: 0, status: 1, color: brick.colors[r] };
246
+ }
247
+ }
248
+ }
249
+
250
+ // Mutation effects
251
+ const mutations = {
252
+ paddleWiden: { name: "Paddle Widened", effect: () => { paddle.width += 20; }, type: "positive" },
253
+ paddleNarrow: { name: "Paddle Narrowed", effect: () => { paddle.width = Math.max(60, paddle.width - 20); }, type: "negative" },
254
+ ballSpeedUp: { name: "Ball Speed Increased", effect: () => { ball.speed += 1; updateBallSpeed(); }, type: "neutral" },
255
+ ballSpeedDown: { name: "Ball Speed Decreased", effect: () => { ball.speed = Math.max(3, ball.speed - 1); updateBallSpeed(); }, type: "neutral" },
256
+ multiBall: { name: "Multi-Ball!", effect: () => { createExtraBall(); }, type: "positive" },
257
+ gameSpeedUp: { name: "Game Speed Increased", effect: () => { gameSpeed = Math.min(3.0, gameSpeed + 0.2); updateSpeedDisplay(); }, type: "neutral" },
258
+ gameSpeedDown: { name: "Game Speed Decreased", effect: () => { gameSpeed = Math.max(0.8, gameSpeed - 0.2); updateSpeedDisplay(); }, type: "neutral" },
259
+ paddleSpeedUp: { name: "Paddle Speed Increased", effect: () => { paddle.speed += 2; }, type: "positive" },
260
+ paddleSpeedDown: { name: "Paddle Speed Decreased", effect: () => { paddle.speed = Math.max(5, paddle.speed - 2; }, type: "negative" },
261
+ aiLearningBoost: { name: "AI Learning Boost", effect: () => { aiLearningRate = Math.min(1, aiLearningRate + 0.1); updateAIDisplay(); }, type: "positive" },
262
+ aiForget: { name: "AI Memory Reset", effect: () => { aiMemory = []; aiLearningRate = Math.max(0, aiLearningRate - 0.2); updateAIDisplay(); }, type: "negative" }
263
+ };
264
+
265
+ let extraBalls = [];
266
+ function createExtraBall() {
267
+ extraBalls.push({
268
+ radius: 10,
269
+ x: ball.x,
270
+ y: ball.y,
271
+ dx: (Math.random() > 0.5 ? 1 : -1) * ball.speed * gameSpeed,
272
+ dy: -ball.speed * gameSpeed,
273
+ color: `hsl(${Math.random() * 360}, 100%, 70%)`
274
+ });
275
+ }
276
+
277
+ // AI functions - PERFECT VERSION
278
+ function makeAIDecision() {
279
+ if (aiMode !== 'PERFECT' && aiMode !== 'PLAYING') return;
280
+
281
+ // Perfect prediction of ball's position
282
+ const prediction = perfectBallPrediction();
283
+
284
+ // Move paddle to intercept the ball perfectly
285
+ const paddleCenter = paddle.x + paddle.width / 2;
286
+ const targetX = prediction - paddle.width / 2;
287
+
288
+ // Smooth movement to target position
289
+ if (targetX > paddle.x + 5) {
290
+ paddle.x = Math.min(targetX, paddle.x + paddle.speed * gameSpeed);
291
+ } else if (targetX < paddle.x - 5) {
292
+ paddle.x = Math.max(targetX, paddle.x - paddle.speed * gameSpeed);
293
+ }
294
+ }
295
+
296
+ function perfectBallPrediction() {
297
+ // Simulate ball's path perfectly
298
+ let simX = ball.x;
299
+ let simY = ball.y;
300
+ let simDX = ball.dx;
301
+ let simDY = ball.dy;
302
+
303
+ while (simY < paddle.y) {
304
+ // Move ball
305
+ simX += simDX;
306
+ simY += simDY;
307
+
308
+ // Check wall collisions
309
+ if (simX < ball.radius || simX > canvas.width - ball.radius) {
310
+ simDX = -simDX;
311
+ }
312
+
313
+ // Check ceiling collision
314
+ if (simY < ball.radius) {
315
+ simDY = -simDY;
316
+ }
317
+
318
+ // Check brick collisions
319
+ for (let c = 0; c < brick.columnCount; c++) {
320
+ for (let r = 0; r < brick.rowCount; r++) {
321
+ const b = bricks[c][r];
322
+ if (b.status === 1) {
323
+ if (simX > b.x && simX < b.x + brick.width &&
324
+ simY > b.y && simY < b.y + brick.height) {
325
+ simDY = -simDY;
326
+ // Don't actually break the brick in simulation
327
+ }
328
+ }
329
+ }
330
+ }
331
+ }
332
+
333
+ // Return predicted X position at paddle level
334
+ return Math.max(ball.radius, Math.min(canvas.width - ball.radius, simX));
335
+ }
336
+
337
+ function updateAIDisplay() {
338
+ document.getElementById('ai-mode').textContent = aiMode;
339
+ document.getElementById('ai-learning').textContent = `${Math.floor(aiLearningRate * 100)}%`;
340
+ }
341
+
342
+ // Input handling
343
+ let rightPressed = false;
344
+ let leftPressed = false;
345
+ document.addEventListener('keydown', keyDownHandler);
346
+ document.addEventListener('keyup', keyUpHandler);
347
+ document.addEventListener('mousemove', mouseMoveHandler);
348
+
349
+ // AI control buttons
350
+ document.getElementById('ai-train-btn').addEventListener('click', () => {
351
+ aiMode = 'LEARNING';
352
+ updateAIDisplay();
353
+ });
354
+
355
+ document.getElementById('ai-play-btn').addEventListener('click', () => {
356
+ aiMode = 'PERFECT';
357
+ updateAIDisplay();
358
+ });
359
+
360
+ function keyDownHandler(e) {
361
+ if (e.key === 'Right' || e.key === 'ArrowRight') {
362
+ rightPressed = true;
363
+ } else if (e.key === 'Left' || e.key === 'ArrowLeft') {
364
+ leftPressed = true;
365
+ }
366
+ }
367
+
368
+ function keyUpHandler(e) {
369
+ if (e.key === 'Right' || e.key === 'ArrowRight') {
370
+ rightPressed = false;
371
+ } else if (e.key === 'Left' || e.key === 'ArrowLeft') {
372
+ leftPressed = false;
373
+ }
374
+ }
375
+
376
+ function mouseMoveHandler(e) {
377
+ if (aiMode === 'PERFECT') return;
378
+
379
+ const relativeX = e.clientX - canvas.offsetLeft;
380
+ if (relativeX > paddle.width / 2 && relativeX < canvas.width - paddle.width / 2) {
381
+ paddle.x = relativeX - paddle.width / 2;
382
+ }
383
+ }
384
+
385
+ // Collision detection
386
+ function collisionDetection() {
387
+ for (let c = 0; c < brick.columnCount; c++) {
388
+ for (let r = 0; r < brick.rowCount; r++) {
389
+ const b = bricks[c][r];
390
+ if (b.status === 1) {
391
+ if (
392
+ ball.x > b.x &&
393
+ ball.x < b.x + brick.width &&
394
+ ball.y > b.y &&
395
+ ball.y < b.y + brick.height
396
+ ) {
397
+ ball.dy = -ball.dy;
398
+ b.status = 0;
399
+ score += 10 * gameSpeed;
400
+ document.getElementById('score').textContent = Math.floor(score);
401
+
402
+ // Chance to trigger mutation when hitting a brick
403
+ if (Math.random() < 0.1 && Date.now() - lastMutationTime > 5000) {
404
+ triggerRandomMutation();
405
+ }
406
+ }
407
+ }
408
+ }
409
+ }
410
+ }
411
+
412
+ function triggerRandomMutation() {
413
+ lastMutationTime = Date.now();
414
+ mutationCount++;
415
+
416
+ // Get random mutation
417
+ const mutationKeys = Object.keys(mutations);
418
+ const randomKey = mutationKeys[Math.floor(Math.random() * mutationKeys.length)];
419
+ const mutation = mutations[randomKey];
420
+
421
+ // Apply mutation effect
422
+ mutation.effect();
423
+
424
+ // Log mutation
425
+ logMutation(mutation.name, mutation.type);
426
+ }
427
+
428
+ function logMutation(name, type) {
429
+ const logElement = document.createElement('div');
430
+ logElement.className = `mutation-event mutation-${type}`;
431
+
432
+ const time = new Date().toLocaleTimeString();
433
+ logElement.innerHTML = `<strong>${time}</strong>: ${name}`;
434
+
435
+ const logContainer = document.getElementById('mutation-log');
436
+ logContainer.insertBefore(logElement, logContainer.firstChild);
437
+
438
+ // Keep log from growing too large
439
+ if (logContainer.children.length > 20) {
440
+ logContainer.removeChild(logContainer.lastChild);
441
+ }
442
+
443
+ // Highlight new event
444
+ logElement.style.animation = 'pulse 1s';
445
+ setTimeout(() => {
446
+ logElement.style.animation = '';
447
+ }, 1000);
448
+ }
449
+
450
+ // Game functions
451
+ function updateBallSpeed() {
452
+ const directionX = ball.dx > 0 ? 1 : -1;
453
+ const directionY = ball.dy > 0 ? 1 : -1;
454
+ ball.dx = directionX * ball.speed * gameSpeed;
455
+ ball.dy = directionY * ball.speed * gameSpeed;
456
+ }
457
+
458
+ function updateSpeedDisplay() {
459
+ document.getElementById('speed').textContent = gameSpeed.toFixed(1) + 'x';
460
+ document.getElementById('speed-bar').style.width = `${(gameSpeed / 3) * 100}%`;
461
+ }
462
+
463
+ function drawBall(ballObj) {
464
+ ctx.beginPath();
465
+ ctx.arc(ballObj.x, ballObj.y, ballObj.radius, 0, Math.PI * 2);
466
+ ctx.fillStyle = ballObj.color;
467
+ ctx.fill();
468
+ ctx.closePath();
469
+
470
+ // Glow effect
471
+ ctx.shadowBlur = 15;
472
+ ctx.shadowColor = ballObj.color;
473
+ ctx.fill();
474
+ ctx.shadowBlur = 0;
475
+ }
476
+
477
+ function drawPaddle() {
478
+ ctx.beginPath();
479
+ ctx.rect(paddle.x, paddle.y, paddle.width, paddle.height);
480
+ ctx.fillStyle = paddle.color;
481
+ ctx.fill();
482
+ ctx.closePath();
483
+
484
+ // Glow effect
485
+ ctx.shadowBlur = 20;
486
+ ctx.shadowColor = paddle.color;
487
+ ctx.fill();
488
+ ctx.shadowBlur = 0;
489
+ }
490
+
491
+ function drawBricks() {
492
+ for (let c = 0; c < brick.columnCount; c++) {
493
+ for (let r = 0; r < brick.rowCount; r++) {
494
+ if (bricks[c][r].status === 1) {
495
+ const brickX = c * (brick.width + brick.padding) + brick.offsetLeft;
496
+ const brickY = r * (brick.height + brick.padding) + brick.offsetTop;
497
+ bricks[c][r].x = brickX;
498
+ bricks[c][r].y = brickY;
499
+
500
+ ctx.beginPath();
501
+ ctx.rect(brickX, brickY, brick.width, brick.height);
502
+ ctx.fillStyle = bricks[c][r].color;
503
+ ctx.fill();
504
+ ctx.closePath();
505
+
506
+ // Glow effect
507
+ ctx.shadowBlur = 10;
508
+ ctx.shadowColor = bricks[c][r].color;
509
+ ctx.fill();
510
+ ctx.shadowBlur = 0;
511
+ }
512
+ }
513
+ }
514
+ }
515
+
516
+ function draw() {
517
+ if (!gameRunning) return;
518
+
519
+ // Clear canvas
520
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
521
+
522
+ // Draw game elements
523
+ drawBricks();
524
+ drawBall(ball);
525
+ for (const extraBall of extraBalls) {
526
+ drawBall(extraBall);
527
+ }
528
+ drawPaddle();
529
+
530
+ // AI functions
531
+ makeAIDecision();
532
+
533
+ // Collision detection
534
+ collisionDetection();
535
+
536
+ // Wall collision (left/right)
537
+ if (ball.x + ball.dx > canvas.width - ball.radius || ball.x + ball.dx < ball.radius) {
538
+ ball.dx = -ball.dx;
539
+ }
540
+
541
+ // Wall collision (top)
542
+ if (ball.y + ball.dy < ball.radius) {
543
+ ball.dy = -ball.dy;
544
+ }
545
+
546
+ // Paddle collision
547
+ if (
548
+ ball.y + ball.dy > canvas.height - ball.radius - paddle.height &&
549
+ ball.y + ball.dy < canvas.height - ball.radius &&
550
+ ball.x > paddle.x &&
551
+ ball.x < paddle.x + paddle.width
552
+ ) {
553
+ // Calculate bounce angle based on where ball hits paddle
554
+ const hitPosition = (ball.x - (paddle.x + paddle.width / 2)) / (paddle.width / 2);
555
+ const angle = hitPosition * Math.PI / 3; // Max 60 degree angle
556
+
557
+ ball.dy = -Math.abs(ball.speed * gameSpeed * Math.cos(angle));
558
+ ball.dx = ball.speed * gameSpeed * Math.sin(angle);
559
+ }
560
+
561
+ // Extra balls paddle collision
562
+ for (let i = 0; i < extraBalls.length; i++) {
563
+ const eb = extraBalls[i];
564
+
565
+ if (
566
+ eb.y + eb.dy > canvas.height - eb.radius - paddle.height &&
567
+ eb.y + eb.dy < canvas.height - eb.radius &&
568
+ eb.x > paddle.x &&
569
+ eb.x < paddle.x + paddle.width
570
+ ) {
571
+ const hitPosition = (eb.x - (paddle.x + paddle.width / 2)) / (paddle.width / 2);
572
+ const angle = hitPosition * Math.PI / 3;
573
+
574
+ eb.dy = -Math.abs(eb.dy * Math.cos(angle));
575
+ eb.dx = eb.dx * Math.sin(angle);
576
+ }
577
+
578
+ // Extra balls wall collision
579
+ if (eb.x + eb.dx > canvas.width - eb.radius || eb.x + eb.dx < eb.radius) {
580
+ eb.dx = -eb.dx;
581
+ }
582
+ if (eb.y + eb.dy < eb.radius) {
583
+ eb.dy = -eb.dy;
584
+ }
585
+
586
+ // Move extra balls
587
+ eb.x += eb.dx;
588
+ eb.y += eb.dy;
589
+
590
+ // Remove extra balls that go out of bounds
591
+ if (eb.y > canvas.height) {
592
+ extraBalls.splice(i, 1);
593
+ i--;
594
+ }
595
+ }
596
+
597
+ // Game over check (should never happen with perfect AI)
598
+ if (ball.y + ball.dy > canvas.height) {
599
+ // Check if this is the last ball
600
+ if (extraBalls.length === 0) {
601
+ gameOver();
602
+ return;
603
+ } else {
604
+ // Remove main ball but keep playing with extra balls
605
+ ball.y = -100;
606
+ }
607
+ }
608
+
609
+ // Move ball
610
+ ball.x += ball.dx;
611
+ ball.y += ball.dy;
612
+
613
+ // Move paddle (if not in AI PERFECT mode)
614
+ if (aiMode !== 'PERFECT') {
615
+ if (rightPressed && paddle.x < canvas.width - paddle.width) {
616
+ paddle.x += paddle.speed * gameSpeed;
617
+ } else if (leftPressed && paddle.x > 0) {
618
+ paddle.x -= paddle.speed * gameSpeed;
619
+ }
620
+ }
621
+
622
+ // Gradually increase game speed
623
+ speedIncreaseTimer++;
624
+ if (speedIncreaseTimer > 500 && gameSpeed < 3.0) {
625
+ gameSpeed += 0.05;
626
+ updateSpeedDisplay();
627
+ speedIncreaseTimer = 0;
628
+ }
629
+
630
+ // Check win condition
631
+ let allBricksDestroyed = true;
632
+ for (let c = 0; c < brick.columnCount; c++) {
633
+ for (let r = 0; r < brick.rowCount; r++) {
634
+ if (bricks[c][r].status === 1) {
635
+ allBricksDestroyed = false;
636
+ break;
637
+ }
638
+ }
639
+ if (!allBricksDestroyed) break;
640
+ }
641
+
642
+ if (allBricksDestroyed) {
643
+ // Level complete - reset with more bricks
644
+ brick.rowCount = Math.min(8, brick.rowCount + 1);
645
+ initBricks();
646
+
647
+ // Reset ball position
648
+ ball.x = canvas.width / 2;
649
+ ball.y = canvas.height / 2;
650
+ ball.dx = 5 * gameSpeed;
651
+ ball.dy = -5 * gameSpeed;
652
+
653
+ // Bonus points for completing level
654
+ score += 100 * gameSpeed;
655
+ document.getElementById('score').textContent = Math.floor(score);
656
+
657
+ // Higher chance for mutation after level complete
658
+ if (Math.random() < 0.3) {
659
+ triggerRandomMutation();
660
+ }
661
+ }
662
+
663
+ requestAnimationFrame(draw);
664
+ }
665
+
666
+ function gameOver() {
667
+ gameRunning = false;
668
+ document.getElementById('final-score').textContent = Math.floor(score);
669
+ document.getElementById('mutation-count').textContent = mutationCount;
670
+ document.getElementById('ai-mastery').textContent = `${Math.floor(aiLearningRate * 100)}%`;
671
+ document.getElementById('game-over').style.display = 'block';
672
+ }
673
+
674
+ function resetGame() {
675
+ gameRunning = true;
676
+ score = 0;
677
+ gameSpeed = 1.0;
678
+ speedIncreaseTimer = 0;
679
+ mutationCount = 0;
680
+ lastMutationTime = 0;
681
+ extraBalls = [];
682
+
683
+ // Reset AI
684
+ aiLearningRate = 1.0;
685
+ aiMemory = [];
686
+ aiMode = 'PERFECT';
687
+
688
+ document.getElementById('score').textContent = '0';
689
+ document.getElementById('speed').textContent = '1.0x';
690
+ document.getElementById('speed-bar').style.width = '33.3%';
691
+ document.getElementById('game-over').style.display = 'none';
692
+ document.getElementById('mutation-log').innerHTML = '';
693
+ updateAIDisplay();
694
+
695
+ // Reset paddle
696
+ paddle.width = 100;
697
+ paddle.speed = 15;
698
+ paddle.x = canvas.width / 2 - 50;
699
+
700
+ // Reset ball
701
+ ball.speed = 5;
702
+ ball.x = canvas.width / 2;
703
+ ball.y = canvas.height / 2;
704
+ ball.dx = 5 * gameSpeed;
705
+ ball.dy = -5 * gameSpeed;
706
+ updateBallSpeed();
707
+
708
+ // Reset bricks
709
+ brick.rowCount = 5;
710
+ initBricks();
711
+
712
+ draw();
713
+ }
714
+
715
+ // Initialize game
716
+ document.getElementById('restart-btn').addEventListener('click', resetGame);
717
+
718
+ // Handle window resize
719
+ window.addEventListener('resize', () => {
720
+ canvas.width = window.innerWidth;
721
+ canvas.height = window.innerHeight;
722
+ paddle.y = canvas.height - 30;
723
+ });
724
+
725
+ initBricks();
726
+ updateSpeedDisplay();
727
+ updateAIDisplay();
728
+ draw();
729
+ </script>
730
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - <a href="https://enzostvs-deepsite.hf.space?remix=Lookimi/myawesomeface" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
731
+ </html>