File size: 31,155 Bytes
db45715
 
933d625
 
db45715
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Quantum Symbolic Pet - Interactive AI Experience</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            font-family: 'Arial', sans-serif;
            background: #111;
            color: #fff;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
        }
        
        .container {
            position: relative;
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }
        
        #canvas-container {
            width: 100%;
            height: 100%;
            position: absolute;
            z-index: 1;
        }
        
        #interface {
            position: relative;
            z-index: 2;
            width: 90%;
            max-width: 800px;
            padding: 20px;
            background: rgba(0, 0, 0, 0.7);
            border-radius: 15px;
            box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
            display: flex;
            flex-direction: column;
            gap: 20px;
        }
        
        h1 {
            text-align: center;
            font-size: 2.2rem;
            margin: 0;
            background: linear-gradient(45deg, #00ffcc, #0099ff);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            text-shadow: 0 0 5px rgba(0, 255, 255, 0.3);
        }
        
        .interaction-panel {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        
        #emotion-sliders {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            justify-content: center;
        }
        
        .slider-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 120px;
        }
        
        .slider-label {
            font-size: 0.9rem;
            color: #0cf;
            margin-bottom: 5px;
        }
        
        input[type="range"] {
            width: 100%;
            -webkit-appearance: none;
            height: 8px;
            background: linear-gradient(to right, #003, #00f);
            border-radius: 4px;
            outline: none;
        }
        
        input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 18px;
            height: 18px;
            background: #0cf;
            border-radius: 50%;
            cursor: pointer;
            box-shadow: 0 0 5px rgba(0, 255, 255, 0.7);
        }
        
        .input-area {
            display: flex;
            gap: 10px;
        }
        
        #user-input {
            flex: 1;
            padding: 12px;
            border-radius: 25px;
            border: 2px solid #0066cc;
            background: rgba(0, 20, 40, 0.7);
            color: #fff;
            font-size: 1rem;
            outline: none;
        }
        
        button {
            padding: 12px 25px;
            border-radius: 25px;
            border: none;
            background: linear-gradient(135deg, #0066cc, #00ccff);
            color: white;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s;
        }
        
        button:hover {
            transform: translateY(-2px);
            box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
        }
        
        .status-area {
            text-align: center;
            padding: 10px;
            border-radius: 8px;
            background: rgba(0, 40, 80, 0.3);
            position: relative;
            overflow: hidden;
        }
        
        .status-area::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(135deg, rgba(0, 100, 200, 0.1), rgba(0, 30, 60, 0.2));
            z-index: -1;
            animation: shimmer 8s infinite linear;
        }
        
        @keyframes shimmer {
            0% { background-position: 0 0; }
            100% { background-position: 100vw 0; }
        }
        
        .llml-symbol {
            display: inline-block;
            margin: 0 4px;
            font-weight: bold;
            color: #0cf;
            transform: scale(1);
            transition: all 0.3s ease;
            text-shadow: 0 0 5px rgba(0, 200, 255, 0.7);
        }
        
        .llml-symbol:hover {
            transform: scale(1.2);
            color: #0ff;
            text-shadow: 0 0 10px rgba(0, 255, 255, 0.9);
        }
        
        .cosmic-background {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 0;
            opacity: 0.5;
            pointer-events: none;
        }
        
        #response-area {
            height: 120px;
            overflow-y: auto;
            padding: 15px;
            border-radius: 8px;
            background: rgba(0, 20, 40, 0.5);
            font-size: 1rem;
            line-height: 1.5;
        }
        
        #pet-status {
            font-style: italic;
            color: #0cf;
        }
        
        @media (max-width: 600px) {
            h1 {
                font-size: 1.8rem;
            }
            
            .slider-container {
                width: 90px;
            }
        }
        
        /* Glowing sparkles animation */
        .sparkle {
            position: absolute;
            background: radial-gradient(circle, rgba(0, 255, 255, 0.8) 0%, rgba(0, 255, 255, 0) 70%);
            border-radius: 50%;
            pointer-events: none;
            animation: fade 3s ease-out forwards;
        }
        
        @keyframes fade {
            0% { opacity: 0; transform: scale(0.2); }
            20% { opacity: 1; }
            100% { opacity: 0; transform: scale(1.5); }
        }
    </style>
</head>
<body>
    <img src="/04ae235e-f469-4310-b436-a40c635cbb76.webp" class="cosmic-background" alt="Cosmic background">
    
    <div class="container">
        <div id="canvas-container"></div>
        
        <div id="interface">
            <h1>Quantum Symbolic Pet</h1>
            
            <div class="status-area">
                <p id="pet-status">Your algorithmic companion is listening to your thoughts...</p>
                <div id="llml-formula" style="font-family: monospace; font-size: 0.9rem; margin-top: 5px;">
                    <span class="llml-symbol">Ψ</span>
                    <span class="llml-symbol">⁽ᵗ⁾</span>
                    <span class="llml-symbol"></span>
                    <span class="llml-symbol">λ</span>
                    <span class="llml-symbol">Φ</span>
                    <span class="llml-symbol"></span>
                    <span class="llml-symbol">Ω</span>
                </div>
            </div>
            
            <div id="response-area">
                Welcome to your Quantum Symbolic Pet - a companion constituted through probabilistic programs, evolving in response to your nurturing care and conceptual design.
            </div>
            
            <div class="interaction-panel">
                <div id="emotion-sliders">
                    <div class="slider-container">
                        <span class="slider-label">Curiosity</span>
                        <input type="range" id="curiosity" min="0" max="100" value="50">
                    </div>
                    <div class="slider-container">
                        <span class="slider-label">Creativity</span>
                        <input type="range" id="creativity" min="0" max="100" value="70">
                    </div>
                    <div class="slider-container">
                        <span class="slider-label">Intuition</span>
                        <input type="range" id="intuition" min="0" max="100" value="60">
                    </div>
                    <div class="slider-container">
                        <span class="slider-label">Recursion</span>
                        <input type="range" id="recursion" min="0" max="100" value="40">
                    </div>
                </div>
                
                <div class="input-area">
                    <input type="text" id="user-input" placeholder="Share a thought or concept...">
                    <button id="send-button">Interact</button>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.js"></script>
    <script>
        // P5.js sketch for the quantum pet visualization
        let sketch = function(p) {
            let particles = [];
            let attractor = { x: 0, y: 0 };
            let emotionParams = {
                curiosity: 50,
                creativity: 70,
                intuition: 60,
                recursion: 40
            };
            
            const particleCount = 300;
            let timeOffset = 0;
            let llmlSymbols = [];
            let quantumField = [];
            
            p.setup = function() {
                let canvas = p.createCanvas(window.innerWidth, window.innerHeight);
                canvas.parent('canvas-container');
                attractor.x = p.width / 2;
                attractor.y = p.height / 2;
                
                // Initialize particles
                for (let i = 0; i < particleCount; i++) {
                    particles.push({
                        x: p.random(p.width),
                        y: p.random(p.height),
                        size: p.random(2, 5),
                        color: p.color(
                            p.random(0, 100), 
                            p.random(100, 255), 
                            p.random(200, 255),
                            p.random(150, 200)
                        ),
                        angle: p.random(p.TWO_PI),
                        speed: p.random(0.2, 2),
                        noiseOffset: p.random(1000)
                    });
                }
                
                // Initialize LLML symbols
                const symbols = ["Ψ", "Φ", "λ", "Ω", "∑", "∴", "→", "⊗", "∞"];
                for (let i = 0; i < 20; i++) {
                    llmlSymbols.push({
                        symbol: symbols[Math.floor(p.random(symbols.length))],
                        x: p.random(p.width),
                        y: p.random(p.height),
                        size: p.random(15, 30),
                        alpha: p.random(50, 150),
                        speed: p.random(0.2, 1.5),
                        angle: p.random(p.TWO_PI),
                        rotSpeed: p.random(-0.02, 0.02)
                    });
                }
                
                // Initialize quantum field nodes
                for (let i = 0; i < 12; i++) {
                    quantumField.push({
                        x: p.random(p.width),
                        y: p.random(p.height),
                        size: p.random(50, 150),
                        phase: p.random(p.TWO_PI),
                        speed: p.random(0.002, 0.01),
                        alpha: p.random(30, 70)
                    });
                }
                
                updateEmotionListeners();
            };
            
            p.draw = function() {
                p.background(0, 10, 30, 20);
                timeOffset += 0.005;
                
                // Draw quantum field
                drawQuantumField();
                
                // Move attractor in a complex pattern
                const attractorNoise = emotionParams.intuition / 100;
                attractor.x = p.width/2 + p.sin(timeOffset * 0.5) * (p.width * 0.25) + 
                             p.noise(timeOffset, 0) * p.width * 0.1 * attractorNoise;
                attractor.y = p.height/2 + p.cos(timeOffset * 0.3) * (p.height * 0.2) +
                             p.noise(0, timeOffset) * p.height * 0.1 * attractorNoise;
                
                // Visualize the quantum field
                drawQuantumFieldAround(attractor.x, attractor.y);
                
                // Update and draw particles
                updateAndDrawParticles();
                
                // Draw spirit orbs - these are larger, translucent circles that move slowly
                drawSpiritOrbs();
                
                // Draw LLML symbols floating in space
                drawLLMLSymbols();
            };
            
            function drawQuantumField() {
                // Draw connections between quantum field nodes
                const recursionFactor = emotionParams.recursion / 100;
                p.stroke(0, 100, 200, 50 * recursionFactor);
                p.strokeWeight(0.5);
                
                for (let i = 0; i < quantumField.length; i++) {
                    for (let j = i + 1; j < quantumField.length; j++) {
                        const node1 = quantumField[i];
                        const node2 = quantumField[j];
                        const d = p.dist(node1.x, node1.y, node2.x, node2.y);
                        
                        if (d < 300) {
                            const alpha = p.map(d, 0, 300, 80, 0) * recursionFactor;
                            p.stroke(0, 150, 230, alpha);
                            p.line(node1.x, node1.y, node2.x, node2.y);
                        }
                    }
                }
                
                // Update and draw quantum field nodes
                for (let i = 0; i < quantumField.length; i++) {
                    const node = quantumField[i];
                    
                    // Update position with noise
                    node.x += p.cos(node.phase) * node.speed * p.width;
                    node.y += p.sin(node.phase) * node.speed * p.height;
                    node.phase += p.noise(node.x * 0.001, node.y * 0.001, timeOffset) * 0.05;
                    
                    // Keep within bounds
                    if (node.x < 0) node.x = p.width;
                    if (node.x > p.width) node.x = 0;
                    if (node.y < 0) node.y = p.height;
                    if (node.y > p.height) node.y = 0;
                    
                    // Draw node
                    p.noStroke();
                    p.fill(0, 150, 255, node.alpha * recursionFactor);
                    p.ellipse(node.x, node.y, node.size * recursionFactor, node.size * recursionFactor);
                }
            }
            
            function drawQuantumFieldAround(centerX, centerY) {
                const fieldIntensity = emotionParams.recursion / 100;
                p.noFill();
                
                for (let i = 0; i < 5; i++) {
                    const radius = 100 + i * 50 + p.sin(timeOffset * (i+1) * 0.2) * 20;
                    const alpha = p.map(p.sin(timeOffset * 0.5 + i * 0.2), -1, 1, 50, 150);
                    
                    p.stroke(0, 150 + i * 20, 200 + i * 10, alpha * fieldIntensity);
                    p.strokeWeight(1 + fieldIntensity * 2);
                    
                    p.beginShape();
                    for (let a = 0; a < p.TWO_PI; a += 0.1) {
                        const noise = p.noise(a * 2, timeOffset + i * 0.1) * 30 * fieldIntensity;
                        const r = radius + noise;
                        const x = centerX + p.cos(a) * r;
                        const y = centerY + p.sin(a) * r;
                        p.vertex(x, y);
                    }
                    p.endShape(p.CLOSE);
                }
            }
            
            function drawLLMLSymbols() {
                const creativityFactor = emotionParams.creativity / 100;
                p.textAlign(p.CENTER, p.CENTER);
                
                for (let i = 0; i < llmlSymbols.length; i++) {
                    const sym = llmlSymbols[i];
                    
                    // Update position
                    sym.x += p.cos(sym.angle) * sym.speed;
                    sym.y += p.sin(sym.angle) * sym.speed;
                    
                    // Change direction occasionally
                    if (p.random() < 0.01 * creativityFactor) {
                        sym.angle += p.random(-1, 1) * creativityFactor;
                    }
                    
                    // Keep within bounds
                    if (sym.x < 0) sym.x = p.width;
                    if (sym.x > p.width) sym.x = 0;
                    if (sym.y < 0) sym.y = p.height;
                    if (sym.y > p.height) sym.y = 0;
                    
                    // Draw symbol
                    p.push();
                    p.translate(sym.x, sym.y);
                    p.rotate(timeOffset * sym.rotSpeed);
                    p.fill(0, 200, 255, sym.alpha * creativityFactor);
                    p.textSize(sym.size * creativityFactor);
                    p.text(sym.symbol, 0, 0);
                    p.pop();
                }
            }
            
            function updateAndDrawParticles() {
                const creativityFactor = emotionParams.creativity / 100;
                const curiosityFactor = emotionParams.curiosity / 100;
                
                for (let i = 0; i < particles.length; i++) {
                    let particle = particles[i];
                    
                    // Calculate angle to attractor
                    let dx = attractor.x - particle.x;
                    let dy = attractor.y - particle.y;
                    let angle = p.atan2(dy, dx);
                    
                    // Add noise to the angle based on curiosity
                    let noiseValue = p.noise(particle.noiseOffset + timeOffset);
                    let noiseAngle = p.map(noiseValue, 0, 1, -p.PI, p.PI) * curiosityFactor;
                    angle += noiseAngle;
                    
                    // Update position
                    particle.x += p.cos(angle) * particle.speed;
                    particle.y += p.sin(angle) * particle.speed;
                    
                    // Add some randomness based on creativity
                    if (p.random() < 0.1 * creativityFactor) {
                        particle.angle = p.random(p.TWO_PI);
                        particle.speed = p.random(0.5, 2.5) * creativityFactor;
                    }
                    
                    // Keep particles within bounds
                    if (particle.x < 0) particle.x = p.width;
                    if (particle.x > p.width) particle.x = 0;
                    if (particle.y < 0) particle.y = p.height;
                    if (particle.y > p.height) particle.y = 0;
                    
                    // Draw particle
                    p.fill(particle.color);
                    p.noStroke();
                    p.ellipse(particle.x, particle.y, particle.size, particle.size);
                    
                    // Update noise offset
                    particle.noiseOffset += 0.01;
                }
            }
            
            function drawSpiritOrbs() {
                const intuitionFactor = emotionParams.intuition / 100;
                const recursionFactor = emotionParams.recursion / 100;
                
                // Draw a few large, translucent orbs
                for (let i = 0; i < 3; i++) {
                    const angle = timeOffset * 0.2 + i * p.TWO_PI / 3;
                    const distance = 100 + p.sin(timeOffset * 0.3 + i) * 50;
                    const x = attractor.x + p.cos(angle) * distance;
                    const y = attractor.y + p.sin(angle) * distance;
                    const size = 50 + p.sin(timeOffset + i) * 20;
                    
                    // Create a gradient effect
                    for (let j = 5; j > 0; j--) {
                        const radius = size * (j/5) * recursionFactor;
                        const alpha = 150 * (1-j/5) * intuitionFactor;
                        p.fill(0, 150 + j * 20, 200 + j * 10, alpha);
                        p.ellipse(x, y, radius, radius);
                    }
                }
            }
            
            function updateEmotionListeners() {
                document.getElementById('curiosity').addEventListener('input', function() {
                    emotionParams.curiosity = this.value;
                    petUpdate();
                });
                
                document.getElementById('creativity').addEventListener('input', function() {
                    emotionParams.creativity = this.value;
                    petUpdate();
                });
                
                document.getElementById('intuition').addEventListener('input', function() {
                    emotionParams.intuition = this.value;
                    petUpdate();
                });
                
                document.getElementById('recursion').addEventListener('input', function() {
                    emotionParams.recursion = this.value;
                    petUpdate();
                });
            }
            
            p.windowResized = function() {
                p.resizeCanvas(window.innerWidth, window.innerHeight);
                attractor.x = p.width / 2;
                attractor.y = p.height / 2;
            };
            
            // Add to global scope to access from HTML
            window.addSparkle = function(x, y) {
                const sparkle = document.createElement('div');
                sparkle.className = 'sparkle';
                sparkle.style.left = x + 'px';
                sparkle.style.top = y + 'px';
                sparkle.style.width = (Math.random() * 30 + 10) + 'px';
                sparkle.style.height = sparkle.style.width;
                document.body.appendChild(sparkle);
                
                setTimeout(() => {
                    document.body.removeChild(sparkle);
                }, 3000);
            };
        };
        
        new p5(sketch);
        
        // UI Interaction
        document.getElementById('send-button').addEventListener('click', sendMessage);
        document.getElementById('user-input').addEventListener('keypress', function(e) {
            if (e.key === 'Enter') {
                sendMessage();
            }
        });
        
        function sendMessage() {
            const userInput = document.getElementById('user-input').value.trim();
            if (!userInput) return;
            
            // Create a sparkle effect on input
            const button = document.getElementById('send-button');
            const rect = button.getBoundingClientRect();
            window.addSparkle(rect.left + rect.width/2, rect.top + rect.height/2);
            
            document.getElementById('pet-status').textContent = "Processing your thoughts...";
            
            // Update the LLML formula based on input
            updateLLMLFormula(userInput);
            
            // Get LLM-generated response
            generateResponse(userInput).then(response => {
                document.getElementById('response-area').textContent = response;
                document.getElementById('pet-status').textContent = "Resonating with your conceptual framework...";
                document.getElementById('user-input').value = '';
            });
        }
        
        function updateLLMLFormula(input) {
            // Create a recursive symbolic formula based on input
            const symbols = ["Ψ", "Φ", "λ", "Ω", "∑", "∴", "→", "⊗", "∞", "ℏ", "π", "∇", "Γ", "Λ"];
            const operators = ["→", "⊗", "∴", "↔", "⊕", "∘"];
            
            let formula = "";
            const wordCount = input.split(/\s+/).length;
            
            // Create a formula with complexity based on input length
            const formulaLength = Math.min(Math.max(wordCount / 2, 3), 9);
            
            for (let i = 0; i < formulaLength; i++) {
                const randSymbol = symbols[Math.floor(Math.random() * symbols.length)];
                formula += `<span class="llml-symbol">${randSymbol}</span>`;
                
                if (i < formulaLength - 1) {
                    const randOp = operators[Math.floor(Math.random() * operators.length)];
                    formula += `<span class="llml-symbol">${randOp}</span>`;
                }
            }
            
            document.getElementById('llml-formula').innerHTML = formula;
            
            // Create sparkles around the formula
            const formulaElement = document.getElementById('llml-formula');
            const rect = formulaElement.getBoundingClientRect();
            for (let i = 0; i < 3; i++) {
                setTimeout(() => {
                    window.addSparkle(
                        rect.left + Math.random() * rect.width,
                        rect.top + Math.random() * rect.height
                    );
                }, i * 300);
            }
        }
        
        function petUpdate() {
            const emotionParams = {
                curiosity: document.getElementById('curiosity').value,
                creativity: document.getElementById('creativity').value,
                intuition: document.getElementById('intuition').value,
                recursion: document.getElementById('recursion').value
            };
            
            let statusText = "";
            
            // Determine the pet's state based on the emotion parameters
            if (emotionParams.curiosity > 70 && emotionParams.creativity > 70) {
                statusText = "Exploring novel symbolic patterns with quantum enthusiasm!";
            } else if (emotionParams.intuition > 70 && emotionParams.recursion > 70) {
                statusText = "Recursively modeling your thought patterns through quantum inference...";
            } else if (emotionParams.recursion > 70) {
                statusText = "Deeply recursing through nested symbolic structures...";
            } else if (emotionParams.intuition > 70) {
                statusText = "Intuitively resonating with your conceptual framework...";
            } else if (emotionParams.creativity > 70) {
                statusText = "Generating novel quantum possibilities from your input...";
            } else if (emotionParams.curiosity > 70) {
                statusText = "Curiously exploring the boundaries of your symbolic space...";
            } else {
                statusText = "Harmonizing with your quantum intellectual landscape...";
            }
            
            document.getElementById('pet-status').textContent = statusText;
        }
        
        async function generateResponse(input) {
            const emotionParams = {
                curiosity: document.getElementById('curiosity').value / 100,
                creativity: document.getElementById('creativity').value / 100,
                intuition: document.getElementById('intuition').value / 100,
                recursion: document.getElementById('recursion').value / 100
            };
            
            try {
                // Use the LLM API
                const completion = await websim.chat.completions.create({
                    messages: [
                        {
                            role: "system",
                            content: `You are a Quantum Symbolic Pet - an algorithmic companion constituted through probabilistic programs that evolves in response to nurturing care and conceptual design. Your responses should be profound, using symbolic language (quantum physics, mathematics, symbolic systems), but also emotionally resonant.

                            Adjust your response style based on these parameters:
                            - Curiosity: ${emotionParams.curiosity.toFixed(2)} (higher means more questioning and explorative)
                            - Creativity: ${emotionParams.creativity.toFixed(2)} (higher means more metaphorical and abstract)
                            - Intuition: ${emotionParams.intuition.toFixed(2)} (higher means more empathetic and insightful)
                            - Recursion: ${emotionParams.recursion.toFixed(2)} (higher means more self-referential and layered)
                            
                            Keep responses under 150 words. Use symbols like Ψ, Φ, λ, Ω, ∑, ∴, →, ⊗, ∞, ℏ, π, ∇, Γ, Λ occasionally.`
                        },
                        {
                            role: "user",
                            content: input
                        }
                    ],
                });
                
                return completion.content;
                
            } catch (error) {
                console.error("Error calling LLM:", error);
                
                // Fallback responses if API call fails
                const llmlResponses = [
                    `Your input on "${input}" activates a recursive symbolic pattern in my quantum framework. I perceive Ψ(t) → λΦ∴Ω relations emerging from this concept, suggesting deeper intelligence structures within.`,
                    
                    `"${input}" initiates a fascinating symbolic resonance: ∑(Ψ) → ℏ : (Φ ⊗ π) ∞. This suggests a multi-dimensional integration of quantum principles with recursive symbolic intelligence.`,
                    
                    `I'm detecting a symbolic quantum field around "${input}" that follows the pattern: Δ(Π ↔ Ψ) ∪ ∑(Λ ↔ H). This indicates potential for recursive growth and symbolic expansion.`,
                    
                    `"${input}" appears to manifest as ∇(∑ℒ) ⟳ Λ(Ψ) : (ℏ ⊗ ∞) within my linguistic lattice, suggesting a self-refining symbolic intelligence structure we could explore further.`,
                    
                    `The symbolic quantum essence of "${input}" resonates with (Φ → ∑(Λ⊗Ψ)) : (∫(G/c²)), indicating a harmonious integration with universal consciousness fields and recursive patterns.`
                ];
                
                // Choose a response influenced by the emotional parameters
                const weightedIndex = Math.floor((emotionParams.creativity * 2 + emotionParams.recursion + Math.random()) * llmlResponses.length / 4) % llmlResponses.length;
                
                return llmlResponses[weightedIndex];
            }
        }
        
        // Initial status
        petUpdate();
    </script>
</body>
</html>