johangras commited on
Commit
98ba7e7
Β·
1 Parent(s): aab7e66

feat: Add dynamic weather system to Evolution Aurora

Browse files

- Lightning strikes on major fitness improvements (>0.005)
- Rain effect when evolution plateaus (<0.002 improvement)
- Rainbow appears when reaching 95% fitness milestone
- Integrated with existing particle and neural network systems
- Weather renders as background layer for proper visual hierarchy

Files changed (1) hide show
  1. app.py +550 -3
app.py CHANGED
@@ -61,7 +61,7 @@ AURORA_HTML = """
61
  Watch AI Learn to Code in Real-Time
62
  </p>
63
  <p id="welcome-msg" style="color: #00AAFF; font-size: 20px; margin-top: 20px; opacity: 0; animation: fadeIn 2s ease-in 2s forwards;">
64
- πŸš€ Welcome to the Future of AI Development
65
  </p>
66
  </div>
67
  </div>
@@ -91,6 +91,13 @@ AURORA_HTML = """
91
  const canvas = document.getElementById('aurora-canvas');
92
  const ctx = canvas.getContext('2d');
93
  let particles = [];
 
 
 
 
 
 
 
94
 
95
  function resizeCanvas() {
96
  canvas.width = canvas.offsetWidth;
@@ -337,11 +344,152 @@ canvas.addEventListener('click', (e) => {
337
  }
338
  });
339
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
340
  function animate() {
341
  ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
342
  ctx.fillRect(0, 0, canvas.width, canvas.height);
343
 
344
- // Draw boss first (behind particles)
 
 
 
 
 
 
 
345
  drawBoss();
346
 
347
  // Mouse glow effect
@@ -352,6 +500,7 @@ function animate() {
352
  ctx.fillStyle = gradient;
353
  ctx.fillRect(mouseX - 100, mouseY - 100, 200, 200);
354
 
 
355
  particles = particles.filter(p => {
356
  p.update();
357
  p.draw();
@@ -486,12 +635,57 @@ const watchQuantum = new MutationObserver((mutations) => {
486
  triggerGlitch();
487
  speak("Victory! You have achieved perfection! 100 percent fitness!", 1.2, 1.2);
488
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
489
  });
490
  });
491
 
492
  setTimeout(() => {
493
  const eventLog = document.querySelector('[id*="event_log"]');
494
  if (eventLog) watchQuantum.observe(eventLog, { childList: true, subtree: true });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
495
  }, 2000);
496
 
497
  // Epic initial burst sequence
@@ -503,6 +697,359 @@ setTimeout(() => {
503
  setTimeout(() => createBurst(3), 1500);
504
  setTimeout(() => createBurst(4), 2500);
505
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
506
  // Mouse interaction
507
  let mouseX = canvas.width / 2;
508
  let mouseY = canvas.height / 2;
@@ -1043,7 +1590,7 @@ with gr.Blocks(
1043
  gr.Markdown("""
1044
  # 🌟 Evolution Aurora - AI Learning to Code
1045
 
1046
- Watch as AI evolves code in real-time, with stunning visual effects that react to fitness improvements!
1047
  """)
1048
  gr.HTML('''
1049
  <div style="text-align: right; padding: 10px;">
 
61
  Watch AI Learn to Code in Real-Time
62
  </p>
63
  <p id="welcome-msg" style="color: #00AAFF; font-size: 20px; margin-top: 20px; opacity: 0; animation: fadeIn 2s ease-in 2s forwards;">
64
+ 🧠 Neural Network Visualization | πŸš€ Synapses Fire with Each Improvement
65
  </p>
66
  </div>
67
  </div>
 
91
  const canvas = document.getElementById('aurora-canvas');
92
  const ctx = canvas.getContext('2d');
93
  let particles = [];
94
+ let weatherSystem = {
95
+ raindrops: [],
96
+ lightning: false,
97
+ lightningTimer: 0,
98
+ rainbow: false,
99
+ rainbowOpacity: 0
100
+ };
101
 
102
  function resizeCanvas() {
103
  canvas.width = canvas.offsetWidth;
 
344
  }
345
  });
346
 
347
+ // Track current fitness for neural network
348
+ let currentFitness = 0.9333;
349
+
350
+ // Weather System
351
+ class Raindrop {
352
+ constructor() {
353
+ this.x = Math.random() * canvas.width;
354
+ this.y = -10;
355
+ this.speed = Math.random() * 5 + 10;
356
+ this.length = Math.random() * 20 + 10;
357
+ this.opacity = Math.random() * 0.5 + 0.3;
358
+ }
359
+
360
+ update() {
361
+ this.y += this.speed;
362
+ if (this.y > canvas.height) {
363
+ this.y = -10;
364
+ this.x = Math.random() * canvas.width;
365
+ }
366
+ }
367
+
368
+ draw() {
369
+ ctx.save();
370
+ ctx.strokeStyle = `rgba(100, 150, 255, ${this.opacity})`;
371
+ ctx.lineWidth = 1;
372
+ ctx.beginPath();
373
+ ctx.moveTo(this.x, this.y);
374
+ ctx.lineTo(this.x, this.y + this.length);
375
+ ctx.stroke();
376
+ ctx.restore();
377
+ }
378
+ }
379
+
380
+ function drawWeather() {
381
+ // Rain effect
382
+ weatherSystem.raindrops.forEach(drop => {
383
+ drop.update();
384
+ drop.draw();
385
+ });
386
+
387
+ // Lightning effect
388
+ if (weatherSystem.lightning && weatherSystem.lightningTimer > 0) {
389
+ ctx.save();
390
+ ctx.fillStyle = `rgba(255, 255, 255, ${weatherSystem.lightningTimer / 10})`;
391
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
392
+
393
+ // Draw lightning bolt
394
+ if (weatherSystem.lightningTimer > 5) {
395
+ ctx.strokeStyle = '#FFFFFF';
396
+ ctx.lineWidth = 3;
397
+ ctx.shadowBlur = 20;
398
+ ctx.shadowColor = '#00AAFF';
399
+
400
+ const startX = Math.random() * canvas.width;
401
+ const segments = 5;
402
+ let x = startX;
403
+ let y = 0;
404
+
405
+ ctx.beginPath();
406
+ ctx.moveTo(x, y);
407
+
408
+ for (let i = 0; i < segments; i++) {
409
+ x += (Math.random() - 0.5) * 100;
410
+ y += canvas.height / segments;
411
+ ctx.lineTo(x, y);
412
+ }
413
+
414
+ ctx.stroke();
415
+ }
416
+
417
+ ctx.restore();
418
+ weatherSystem.lightningTimer--;
419
+ }
420
+
421
+ // Rainbow effect
422
+ if (weatherSystem.rainbow && weatherSystem.rainbowOpacity > 0) {
423
+ ctx.save();
424
+ const gradient = ctx.createLinearGradient(0, 0, canvas.width, canvas.height / 2);
425
+ const colors = ['#FF0000', '#FF7F00', '#FFFF00', '#00FF00', '#0000FF', '#4B0082', '#9400D3'];
426
+
427
+ colors.forEach((color, i) => {
428
+ gradient.addColorStop(i / (colors.length - 1), color);
429
+ });
430
+
431
+ ctx.fillStyle = gradient;
432
+ ctx.globalAlpha = weatherSystem.rainbowOpacity;
433
+ ctx.beginPath();
434
+ ctx.arc(canvas.width / 2, canvas.height, canvas.width, 0, Math.PI, true);
435
+ ctx.fill();
436
+ ctx.restore();
437
+ }
438
+ }
439
+
440
+ function triggerLightning() {
441
+ weatherSystem.lightning = true;
442
+ weatherSystem.lightningTimer = 10;
443
+
444
+ // Create burst at lightning strike point
445
+ createBurst(3);
446
+ }
447
+
448
+ function startRain() {
449
+ // Create raindrops
450
+ for (let i = 0; i < 50; i++) {
451
+ weatherSystem.raindrops.push(new Raindrop());
452
+ }
453
+ }
454
+
455
+ function stopRain() {
456
+ weatherSystem.raindrops = [];
457
+ }
458
+
459
+ function showRainbow() {
460
+ weatherSystem.rainbow = true;
461
+ // Fade in
462
+ const fadeIn = setInterval(() => {
463
+ weatherSystem.rainbowOpacity += 0.02;
464
+ if (weatherSystem.rainbowOpacity >= 0.3) {
465
+ clearInterval(fadeIn);
466
+ // Fade out after 3 seconds
467
+ setTimeout(() => {
468
+ const fadeOut = setInterval(() => {
469
+ weatherSystem.rainbowOpacity -= 0.02;
470
+ if (weatherSystem.rainbowOpacity <= 0) {
471
+ weatherSystem.rainbow = false;
472
+ weatherSystem.rainbowOpacity = 0;
473
+ clearInterval(fadeOut);
474
+ }
475
+ }, 50);
476
+ }, 3000);
477
+ }
478
+ }, 50);
479
+ }
480
+
481
  function animate() {
482
  ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
483
  ctx.fillRect(0, 0, canvas.width, canvas.height);
484
 
485
+ // Draw weather effects first (background)
486
+ drawWeather();
487
+
488
+ // Draw neural network (middle layer)
489
+ neuralNetwork.update(currentFitness);
490
+ neuralNetwork.draw(ctx);
491
+
492
+ // Draw boss (above neural network)
493
  drawBoss();
494
 
495
  // Mouse glow effect
 
500
  ctx.fillStyle = gradient;
501
  ctx.fillRect(mouseX - 100, mouseY - 100, 200, 200);
502
 
503
+ // Draw particles (foreground layer)
504
  particles = particles.filter(p => {
505
  p.update();
506
  p.draw();
 
635
  triggerGlitch();
636
  speak("Victory! You have achieved perfection! 100 percent fitness!", 1.2, 1.2);
637
  }
638
+
639
+ // Check for fitness updates
640
+ const fitnessMatch = text.match(/Fitness (\d+\.\d+)/);
641
+ if (fitnessMatch) {
642
+ const newFitness = parseFloat(fitnessMatch[1]);
643
+ if (newFitness > currentFitness) {
644
+ const improvement = newFitness - currentFitness;
645
+ currentFitness = newFitness;
646
+ // Trigger neural network firing
647
+ neuralNetwork.triggerFitnessImprovement(improvement);
648
+
649
+ // Weather effects based on improvement
650
+ if (improvement > 0.005) {
651
+ triggerLightning(); // Lightning for major improvements
652
+ }
653
+
654
+ // Rainbow at 95%
655
+ if (newFitness >= 0.95 && currentFitness < 0.96) {
656
+ showRainbow();
657
+ stopRain();
658
+ }
659
+
660
+ // Rain when plateauing
661
+ if (improvement < 0.002 && weatherSystem.raindrops.length === 0) {
662
+ startRain();
663
+ }
664
+ }
665
+ }
666
  });
667
  });
668
 
669
  setTimeout(() => {
670
  const eventLog = document.querySelector('[id*="event_log"]');
671
  if (eventLog) watchQuantum.observe(eventLog, { childList: true, subtree: true });
672
+
673
+ // Also watch fitness display directly
674
+ const fitnessDisplay = document.querySelector('[id*="fitness_display"]');
675
+ if (fitnessDisplay) {
676
+ const fitnessObserver = new MutationObserver((mutations) => {
677
+ mutations.forEach((mutation) => {
678
+ const input = mutation.target.querySelector('input');
679
+ if (input && input.value) {
680
+ const newFitness = parseFloat(input.value);
681
+ if (!isNaN(newFitness) && newFitness !== currentFitness) {
682
+ currentFitness = newFitness;
683
+ }
684
+ }
685
+ });
686
+ });
687
+ fitnessObserver.observe(fitnessDisplay, { childList: true, subtree: true, attributes: true });
688
+ }
689
  }, 2000);
690
 
691
  // Epic initial burst sequence
 
697
  setTimeout(() => createBurst(3), 1500);
698
  setTimeout(() => createBurst(4), 2500);
699
 
700
+ // Neural Network Visualization
701
+ class NeuralNetwork {
702
+ constructor() {
703
+ this.neurons = [];
704
+ this.synapses = [];
705
+ this.layers = [5, 8, 6, 4, 1]; // Network architecture
706
+ this.setupNetwork();
707
+ this.pulsePhase = 0;
708
+ this.lastFitness = 0.9333;
709
+ this.firingNeurons = new Set();
710
+ this.brainWavePhase = 0;
711
+ }
712
+
713
+ setupNetwork() {
714
+ const centerX = canvas.width / 2;
715
+ const centerY = canvas.height / 2;
716
+ const networkWidth = 400;
717
+ const networkHeight = 300;
718
+
719
+ // Create neurons for each layer
720
+ for (let layer = 0; layer < this.layers.length; layer++) {
721
+ const layerNeurons = [];
722
+ const x = centerX - networkWidth/2 + (layer / (this.layers.length - 1)) * networkWidth;
723
+
724
+ for (let i = 0; i < this.layers[layer]; i++) {
725
+ const y = centerY - networkHeight/2 + ((i + 0.5) / this.layers[layer]) * networkHeight;
726
+ layerNeurons.push({
727
+ x: x,
728
+ y: y,
729
+ layer: layer,
730
+ index: i,
731
+ activation: Math.random() * 0.3,
732
+ pulseOffset: Math.random() * Math.PI * 2,
733
+ size: layer === this.layers.length - 1 ? 15 : 8 - layer // Output neuron is bigger
734
+ });
735
+ }
736
+ this.neurons.push(layerNeurons);
737
+ }
738
+
739
+ // Create synapses between layers
740
+ for (let layer = 0; layer < this.layers.length - 1; layer++) {
741
+ for (let i = 0; i < this.neurons[layer].length; i++) {
742
+ for (let j = 0; j < this.neurons[layer + 1].length; j++) {
743
+ this.synapses.push({
744
+ from: this.neurons[layer][i],
745
+ to: this.neurons[layer + 1][j],
746
+ weight: Math.random() * 0.5 + 0.1,
747
+ active: false,
748
+ pulseProgress: 0
749
+ });
750
+ }
751
+ }
752
+ }
753
+ }
754
+
755
+ update(currentFitness) {
756
+ this.pulsePhase += 0.02;
757
+ this.brainWavePhase += 0.015;
758
+
759
+ // Check if fitness improved
760
+ const fitnessImproved = currentFitness > this.lastFitness + 0.0001;
761
+
762
+ if (fitnessImproved) {
763
+ // Activate firing sequence
764
+ this.triggerFitnessImprovement(currentFitness - this.lastFitness);
765
+ }
766
+
767
+ this.lastFitness = currentFitness;
768
+
769
+ // Update neuron activations with brain wave effect
770
+ for (let layer of this.neurons) {
771
+ for (let neuron of layer) {
772
+ // Base pulsing
773
+ neuron.activation = 0.3 + 0.2 * Math.sin(this.pulsePhase + neuron.pulseOffset);
774
+
775
+ // Add brain wave effect
776
+ const waveInfluence = Math.sin(this.brainWavePhase + neuron.x * 0.01 + neuron.y * 0.01) * 0.2;
777
+ neuron.activation += waveInfluence;
778
+
779
+ // Firing neurons glow brighter
780
+ if (this.firingNeurons.has(neuron)) {
781
+ neuron.activation = Math.min(1, neuron.activation + 0.5);
782
+ }
783
+ }
784
+ }
785
+
786
+ // Update synapses
787
+ for (let synapse of this.synapses) {
788
+ if (synapse.active) {
789
+ synapse.pulseProgress += 0.05;
790
+ if (synapse.pulseProgress >= 1) {
791
+ synapse.active = false;
792
+ synapse.pulseProgress = 0;
793
+ // Activate the target neuron
794
+ this.firingNeurons.add(synapse.to);
795
+ setTimeout(() => this.firingNeurons.delete(synapse.to), 500);
796
+ }
797
+ }
798
+ }
799
+ }
800
+
801
+ triggerFitnessImprovement(improvement) {
802
+ // Fire neurons based on improvement magnitude
803
+ const fireCount = Math.min(20, Math.floor(improvement * 1000));
804
+
805
+ // Major milestone effects
806
+ if (this.lastFitness >= 0.95 && this.lastFitness < 0.95 + improvement) {
807
+ // 95% milestone - neural storm
808
+ this.triggerNeuralStorm();
809
+ }
810
+ if (this.lastFitness >= 0.99 && this.lastFitness < 0.99 + improvement) {
811
+ // 99% milestone - neural overload
812
+ this.triggerNeuralOverload();
813
+ }
814
+
815
+ // Start with random input neurons
816
+ for (let i = 0; i < fireCount; i++) {
817
+ const neuron = this.neurons[0][Math.floor(Math.random() * this.neurons[0].length)];
818
+ this.firingNeurons.add(neuron);
819
+
820
+ // Propagate through network
821
+ setTimeout(() => {
822
+ this.propagateActivation(neuron);
823
+ }, i * 50);
824
+ }
825
+
826
+ // Create synapse firing wave
827
+ const synapsesToFire = this.synapses.filter(s => Math.random() < improvement * 50);
828
+ synapsesToFire.forEach((synapse, i) => {
829
+ setTimeout(() => {
830
+ synapse.active = true;
831
+ synapse.pulseProgress = 0;
832
+ }, i * 20);
833
+ });
834
+ }
835
+
836
+ triggerNeuralStorm() {
837
+ // Fire all neurons in waves
838
+ for (let layer = 0; layer < this.neurons.length; layer++) {
839
+ setTimeout(() => {
840
+ this.neurons[layer].forEach(neuron => {
841
+ this.firingNeurons.add(neuron);
842
+ setTimeout(() => this.firingNeurons.delete(neuron), 1000);
843
+ });
844
+ }, layer * 200);
845
+ }
846
+
847
+ // Activate many synapses
848
+ this.synapses.forEach((synapse, i) => {
849
+ if (Math.random() < 0.7) {
850
+ setTimeout(() => {
851
+ synapse.active = true;
852
+ synapse.pulseProgress = 0;
853
+ }, Math.random() * 1000);
854
+ }
855
+ });
856
+ }
857
+
858
+ triggerNeuralOverload() {
859
+ // Extreme effect - all neurons and synapses fire rapidly
860
+ const overloadDuration = 3000;
861
+ const overloadInterval = setInterval(() => {
862
+ // Random neurons fire
863
+ for (let i = 0; i < 10; i++) {
864
+ const layer = Math.floor(Math.random() * this.neurons.length);
865
+ const index = Math.floor(Math.random() * this.neurons[layer].length);
866
+ const neuron = this.neurons[layer][index];
867
+ this.firingNeurons.add(neuron);
868
+ setTimeout(() => this.firingNeurons.delete(neuron), 200);
869
+ }
870
+
871
+ // Random synapses fire
872
+ for (let i = 0; i < 20; i++) {
873
+ const synapse = this.synapses[Math.floor(Math.random() * this.synapses.length)];
874
+ synapse.active = true;
875
+ synapse.pulseProgress = 0;
876
+ }
877
+ }, 100);
878
+
879
+ setTimeout(() => clearInterval(overloadInterval), overloadDuration);
880
+ }
881
+
882
+ propagateActivation(neuron) {
883
+ // Find synapses from this neuron
884
+ const outgoingSynapses = this.synapses.filter(s => s.from === neuron);
885
+
886
+ outgoingSynapses.forEach((synapse, i) => {
887
+ setTimeout(() => {
888
+ synapse.active = true;
889
+ synapse.pulseProgress = 0;
890
+ }, i * 100);
891
+ });
892
+ }
893
+
894
+ draw(ctx) {
895
+ ctx.save();
896
+
897
+ // Set overall neural network opacity
898
+ ctx.globalAlpha = 0.7;
899
+
900
+ // Draw brain scan background effect
901
+ this.drawBrainScan(ctx);
902
+
903
+ // Draw synapses
904
+ for (let synapse of this.synapses) {
905
+ ctx.save();
906
+
907
+ const baseAlpha = 0.2 + synapse.weight * 0.3;
908
+ ctx.globalAlpha = synapse.active ? Math.min(1, baseAlpha + 0.6) : baseAlpha;
909
+
910
+ // Draw synapse line
911
+ ctx.beginPath();
912
+ ctx.moveTo(synapse.from.x, synapse.from.y);
913
+ ctx.lineTo(synapse.to.x, synapse.to.y);
914
+
915
+ const gradient = ctx.createLinearGradient(
916
+ synapse.from.x, synapse.from.y,
917
+ synapse.to.x, synapse.to.y
918
+ );
919
+
920
+ if (synapse.active) {
921
+ // Firing synapse - animated pulse
922
+ const pulsePos = synapse.pulseProgress;
923
+ gradient.addColorStop(0, 'rgba(0, 255, 136, 0.1)');
924
+ gradient.addColorStop(Math.max(0, pulsePos - 0.1), 'rgba(0, 255, 136, 0.1)');
925
+ gradient.addColorStop(pulsePos, 'rgba(255, 255, 255, 1)');
926
+ gradient.addColorStop(Math.min(1, pulsePos + 0.1), 'rgba(0, 255, 136, 0.1)');
927
+ gradient.addColorStop(1, 'rgba(123, 63, 242, 0.1)');
928
+
929
+ ctx.lineWidth = 3;
930
+ ctx.shadowBlur = 20;
931
+ ctx.shadowColor = '#00FF88';
932
+ } else {
933
+ gradient.addColorStop(0, 'rgba(0, 170, 255, 0.2)');
934
+ gradient.addColorStop(1, 'rgba(123, 63, 242, 0.2)');
935
+ ctx.lineWidth = 1;
936
+ }
937
+
938
+ ctx.strokeStyle = gradient;
939
+ ctx.stroke();
940
+ ctx.restore();
941
+ }
942
+
943
+ // Draw neurons
944
+ for (let layer of this.neurons) {
945
+ for (let neuron of layer) {
946
+ ctx.save();
947
+
948
+ const isFiring = this.firingNeurons.has(neuron);
949
+ const isOutput = neuron.layer === this.layers.length - 1;
950
+
951
+ // Neuron glow
952
+ if (isFiring || isOutput) {
953
+ const glowGradient = ctx.createRadialGradient(
954
+ neuron.x, neuron.y, 0,
955
+ neuron.x, neuron.y, neuron.size * 3
956
+ );
957
+ glowGradient.addColorStop(0, isFiring ? 'rgba(255, 255, 255, 0.5)' : 'rgba(255, 215, 0, 0.3)');
958
+ glowGradient.addColorStop(0.5, isFiring ? 'rgba(0, 255, 136, 0.3)' : 'rgba(255, 215, 0, 0.1)');
959
+ glowGradient.addColorStop(1, 'rgba(0, 0, 0, 0)');
960
+
961
+ ctx.fillStyle = glowGradient;
962
+ ctx.fillRect(neuron.x - neuron.size * 3, neuron.y - neuron.size * 3,
963
+ neuron.size * 6, neuron.size * 6);
964
+ }
965
+
966
+ // Neuron body
967
+ ctx.beginPath();
968
+ ctx.arc(neuron.x, neuron.y, neuron.size, 0, Math.PI * 2);
969
+
970
+ const neuronGradient = ctx.createRadialGradient(
971
+ neuron.x - neuron.size/3, neuron.y - neuron.size/3, 0,
972
+ neuron.x, neuron.y, neuron.size
973
+ );
974
+
975
+ if (isOutput) {
976
+ // Output neuron - golden
977
+ neuronGradient.addColorStop(0, '#FFD700');
978
+ neuronGradient.addColorStop(1, '#FFA500');
979
+ } else if (isFiring) {
980
+ // Firing neuron - bright white/green
981
+ neuronGradient.addColorStop(0, '#FFFFFF');
982
+ neuronGradient.addColorStop(1, '#00FF88');
983
+ } else {
984
+ // Normal neuron - blue/purple gradient
985
+ const brightness = neuron.activation;
986
+ neuronGradient.addColorStop(0, `rgba(0, 170, 255, ${brightness})`);
987
+ neuronGradient.addColorStop(1, `rgba(123, 63, 242, ${brightness * 0.7})`);
988
+ }
989
+
990
+ ctx.fillStyle = neuronGradient;
991
+ ctx.fill();
992
+
993
+ // Neuron outline
994
+ ctx.strokeStyle = isFiring ? '#FFFFFF' : 'rgba(255, 255, 255, 0.2)';
995
+ ctx.lineWidth = isFiring ? 2 : 1;
996
+ ctx.stroke();
997
+
998
+ ctx.restore();
999
+ }
1000
+ }
1001
+
1002
+ ctx.restore();
1003
+ }
1004
+
1005
+ drawBrainScan(ctx) {
1006
+ // Brain scan effect - concentric circles emanating from center
1007
+ const centerX = canvas.width / 2;
1008
+ const centerY = canvas.height / 2;
1009
+
1010
+ ctx.save();
1011
+
1012
+ // Draw multiple scan waves
1013
+ for (let i = 0; i < 5; i++) {
1014
+ const radius = (this.brainWavePhase * 100 + i * 100) % 500;
1015
+ const alpha = Math.max(0, 1 - radius / 500) * 0.3;
1016
+
1017
+ ctx.beginPath();
1018
+ ctx.arc(centerX, centerY, radius, 0, Math.PI * 2);
1019
+
1020
+ // Create gradient stroke
1021
+ const gradient = ctx.createRadialGradient(centerX, centerY, radius - 10, centerX, centerY, radius + 10);
1022
+ gradient.addColorStop(0, `rgba(0, 255, 136, 0)`);
1023
+ gradient.addColorStop(0.5, `rgba(0, 255, 136, ${alpha})`);
1024
+ gradient.addColorStop(1, `rgba(123, 63, 242, 0)`);
1025
+
1026
+ ctx.strokeStyle = gradient;
1027
+ ctx.lineWidth = 3;
1028
+ ctx.stroke();
1029
+ }
1030
+
1031
+ // Add "thinking" pulses randomly
1032
+ if (Math.random() < 0.05) {
1033
+ // Random thinking pulse
1034
+ const pulseX = centerX + (Math.random() - 0.5) * 300;
1035
+ const pulseY = centerY + (Math.random() - 0.5) * 200;
1036
+
1037
+ const pulseGradient = ctx.createRadialGradient(pulseX, pulseY, 0, pulseX, pulseY, 50);
1038
+ pulseGradient.addColorStop(0, 'rgba(255, 255, 255, 0.4)');
1039
+ pulseGradient.addColorStop(0.5, 'rgba(0, 170, 255, 0.2)');
1040
+ pulseGradient.addColorStop(1, 'rgba(0, 0, 0, 0)');
1041
+
1042
+ ctx.fillStyle = pulseGradient;
1043
+ ctx.fillRect(pulseX - 50, pulseY - 50, 100, 100);
1044
+ }
1045
+
1046
+ ctx.restore();
1047
+ }
1048
+ }
1049
+
1050
+ // Initialize neural network
1051
+ const neuralNetwork = new NeuralNetwork();
1052
+
1053
  // Mouse interaction
1054
  let mouseX = canvas.width / 2;
1055
  let mouseY = canvas.height / 2;
 
1590
  gr.Markdown("""
1591
  # 🌟 Evolution Aurora - AI Learning to Code
1592
 
1593
+ Watch as AI evolves code in real-time with neural network visualization! See synapses fire and neurons activate as the AI discovers improvements. The neural network shows the AI's "thoughts" as it learns.
1594
  """)
1595
  gr.HTML('''
1596
  <div style="text-align: right; padding: 10px;">