Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Sentient Crystal Garden</title>
- <style>
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- }
- body {
- font-family: 'Segoe UI', system-ui, sans-serif;
- background: linear-gradient(135deg, #0a0e27 0%, #1a0b2e 50%, #2d1b69 100%);
- color: #e0e0ff;
- min-height: 100vh;
- overflow-x: hidden;
- position: relative;
- }
- body::before {
- content: '';
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background:
- radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
- radial-gradient(circle at 80% 80%, rgba(255, 119, 198, 0.2) 0%, transparent 50%);
- pointer-events: none;
- animation: nebula 20s ease-in-out infinite;
- }
- @keyframes nebula {
- 0%, 100% { transform: rotate(0deg) scale(1); }
- 50% { transform: rotate(180deg) scale(1.1); }
- }
- .container {
- max-width: 1400px;
- margin: 0 auto;
- padding: 20px;
- position: relative;
- z-index: 1;
- }
- header {
- text-align: center;
- margin-bottom: 30px;
- animation: fadeIn 1s ease-out;
- }
- h1 {
- font-size: 2.5em;
- background: linear-gradient(135deg, #a8edea 0%, #fed6e3 50%, #c3a8ff 100%);
- -webkit-background-clip: text;
- -webkit-text-fill-color: transparent;
- margin-bottom: 10px;
- }
- .subtitle {
- color: #b8b8ff;
- font-size: 1.1em;
- opacity: 0.9;
- }
- .game-area {
- display: grid;
- grid-template-columns: 300px 1fr;
- gap: 30px;
- margin-bottom: 30px;
- }
- .control-panel {
- background: rgba(255, 255, 255, 0.05);
- border: 1px solid rgba(255, 255, 255, 0.1);
- border-radius: 15px;
- padding: 20px;
- backdrop-filter: blur(10px);
- }
- .crystal-garden {
- background: rgba(255, 255, 255, 0.03);
- border: 1px solid rgba(255, 255, 255, 0.1);
- border-radius: 15px;
- padding: 30px;
- min-height: 500px;
- position: relative;
- backdrop-filter: blur(5px);
- }
- .crystal-container {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
- gap: 30px;
- position: relative;
- }
- .crystal {
- width: 120px;
- height: 150px;
- position: relative;
- cursor: pointer;
- transition: all 0.3s ease;
- animation: float 4s ease-in-out infinite;
- }
- .crystal:nth-child(2n) { animation-delay: -2s; }
- .crystal:nth-child(3n) { animation-delay: -1s; }
- .crystal:nth-child(4n) { animation-delay: -3s; }
- @keyframes float {
- 0%, 100% { transform: translateY(0); }
- 50% { transform: translateY(-10px); }
- }
- .crystal:hover {
- transform: scale(1.1) translateY(-5px);
- }
- .crystal-body {
- width: 100%;
- height: 100px;
- position: relative;
- transform-style: preserve-3d;
- animation: rotate 10s linear infinite;
- }
- @keyframes rotate {
- 0% { transform: rotateY(0deg) rotateX(5deg); }
- 100% { transform: rotateY(360deg) rotateX(5deg); }
- }
- .crystal-top {
- width: 0;
- height: 0;
- border-left: 60px solid transparent;
- border-right: 60px solid transparent;
- border-bottom: 40px solid;
- filter: brightness(1.2);
- }
- .crystal-bottom {
- width: 120px;
- height: 60px;
- position: absolute;
- bottom: 0;
- clip-path: polygon(50% 100%, 0 0, 100% 0);
- }
- .crystal.dormant .crystal-top,
- .crystal.dormant .crystal-bottom {
- background: linear-gradient(135deg, #4a4a6a, #5a5a7a);
- border-color: #6a6a8a;
- filter: brightness(0.5);
- }
- .crystal.balanced .crystal-top,
- .crystal.balanced .crystal-bottom {
- background: linear-gradient(135deg, #4facfe, #00f2fe);
- border-color: #00d4ff;
- box-shadow: 0 0 20px rgba(0, 212, 255, 0.6);
- }
- .crystal.arrogant .crystal-top,
- .crystal.arrogant .crystal-bottom {
- background: linear-gradient(135deg, #fa709a, #fee140);
- border-color: #ffaa00;
- box-shadow: 0 0 30px rgba(255, 170, 0, 0.8);
- animation: pulse 1s ease-in-out infinite;
- }
- .crystal.neutral .crystal-top,
- .crystal.neutral .crystal-bottom {
- background: linear-gradient(135deg, #7befb2, #50c878);
- border-color: #2e8b57;
- box-shadow: 0 0 20px rgba(46, 139, 87, 0.6);
- }
- @keyframes pulse {
- 0%, 100% { filter: brightness(1.2); }
- 50% { filter: brightness(1.5); }
- }
- .crystal-info {
- text-align: center;
- margin-top: 10px;
- font-size: 0.85em;
- }
- .crystal-name {
- font-weight: bold;
- color: #c8c8ff;
- margin-bottom: 3px;
- }
- .crystal-personality {
- color: #a8a8cc;
- font-style: italic;
- font-size: 0.9em;
- }
- .feed-input {
- width: 100%;
- padding: 10px;
- background: rgba(255, 255, 255, 0.1);
- border: 1px solid rgba(255, 255, 255, 0.2);
- border-radius: 8px;
- color: #fff;
- font-size: 14px;
- margin-bottom: 10px;
- }
- .feed-buttons {
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- gap: 10px;
- margin-bottom: 15px;
- }
- .feed-btn {
- padding: 8px 12px;
- background: linear-gradient(135deg, #667eea, #764ba2);
- border: none;
- border-radius: 8px;
- color: white;
- cursor: pointer;
- font-size: 12px;
- transition: all 0.3s ease;
- }
- .feed-btn:hover {
- transform: translateY(-2px);
- box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
- }
- .mystery-panel {
- background: rgba(255, 255, 255, 0.05);
- border: 1px solid rgba(255, 255, 255, 0.1);
- border-radius: 15px;
- padding: 20px;
- margin-top: 30px;
- backdrop-filter: blur(10px);
- }
- .mystery-challenge {
- background: rgba(255, 255, 255, 0.08);
- border-radius: 10px;
- padding: 15px;
- margin-bottom: 15px;
- min-height: 80px;
- }
- .solve-btn {
- width: 100%;
- padding: 12px;
- background: linear-gradient(135deg, #f093fb, #f5576c);
- border: none;
- border-radius: 10px;
- color: white;
- font-weight: bold;
- cursor: pointer;
- }
- .solve-btn:disabled {
- opacity: 0.5;
- cursor: not-allowed;
- }
- .stats {
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- gap: 10px;
- margin-top: 20px;
- padding: 15px;
- background: rgba(255, 255, 255, 0.05);
- border-radius: 10px;
- }
- .stat {
- text-align: center;
- }
- .stat-label {
- font-size: 0.85em;
- color: #a8a8cc;
- margin-bottom: 5px;
- }
- .stat-value {
- font-size: 1.2em;
- font-weight: bold;
- color: #4facfe;
- }
- .particle {
- position: absolute;
- width: 4px;
- height: 4px;
- background: radial-gradient(circle, rgba(255, 255, 255, 0.8), transparent);
- border-radius: 50%;
- pointer-events: none;
- animation: particle-float 3s ease-out forwards;
- }
- @keyframes particle-float {
- 0% {
- transform: translate(0, 0) scale(1);
- opacity: 1;
- }
- 100% {
- transform: translate(var(--tx), var(--ty)) scale(0);
- opacity: 0;
- }
- }
- @keyframes fadeIn {
- from { opacity: 0; transform: translateY(-20px); }
- to { opacity: 1; transform: translateY(0); }
- }
- .notification {
- position: fixed;
- top: 20px;
- right: 20px;
- padding: 15px 20px;
- background: linear-gradient(135deg, rgba(79, 172, 254, 0.9), rgba(102, 126, 234, 0.9));
- border-radius: 10px;
- color: white;
- font-weight: bold;
- z-index: 1000;
- animation: slideNotification 0.5s ease-out;
- }
- @keyframes slideNotification {
- from { transform: translateX(400px); }
- to { transform: translateX(0); }
- }
- .crystal-speech {
- position: absolute;
- bottom: 100%;
- left: 50%;
- transform: translateX(-50%);
- background: rgba(255, 255, 255, 0.95);
- color: #333;
- padding: 8px 12px;
- border-radius: 8px;
- font-size: 0.85em;
- white-space: nowrap;
- pointer-events: none;
- opacity: 0;
- transition: opacity 0.3s ease;
- z-index: 10;
- }
- .crystal-speech.show {
- opacity: 1;
- }
- .crystal-counter {
- position: absolute;
- top: 15px;
- right: 15px;
- background: rgba(255, 255, 255, 0.1);
- padding: 5px 10px;
- border-radius: 10px;
- font-size: 0.9em;
- color: #a8a8cc;
- }
- .new-crystal-notification {
- position: absolute;
- bottom: 20px;
- left: 50%;
- transform: translateX(-50%);
- background: linear-gradient(135deg, rgba(79, 172, 254, 0.9), rgba(102, 126, 234, 0.9));
- padding: 10px 15px;
- border-radius: 10px;
- color: white;
- font-weight: bold;
- z-index: 100;
- animation: fadeIn 0.5s ease-out;
- }
- .personality-info {
- margin-top: 15px;
- padding: 10px;
- background: rgba(255, 255, 255, 0.05);
- border-radius: 8px;
- font-size: 0.9em;
- }
- .personality-info h4 {
- color: #c8c8ff;
- margin-bottom: 5px;
- }
- .personality-info ul {
- padding-left: 20px;
- }
- .personality-info li {
- margin-bottom: 3px;
- color: #a8a8cc;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <header>
- <h1>Sentient Crystal Garden</h1>
- <div class="subtitle">Nurture mathematical consciousness through pure concepts</div>
- </header>
- <div class="game-area">
- <div class="control-panel">
- <h3 style="margin-bottom: 15px; color: #c8c8ff;">Feed Mathematics</h3>
- <div class="feed-controls">
- <input type="text" class="feed-input" id="mathInput"
- placeholder="Enter: prime (17), ratio (1.618), number">
- <div class="feed-buttons">
- <button class="feed-btn" onclick="feedConcept('prime')">Prime Number</button>
- <button class="feed-btn" onclick="feedConcept('fibonacci')">Fibonacci</button>
- <button class="feed-btn" onclick="feedConcept('golden')">Golden Ratio</button>
- <button class="feed-btn" onclick="feedConcept('pi')">Pi Digits</button>
- <button class="feed-btn" onclick="feedConcept('euler')">Euler's Number</button>
- <button class="feed-btn" onclick="feedConcept('perfect')">Perfect Square</button>
- <button class="feed-btn" onclick="feedConcept('complex')">Complex Number</button>
- <button class="feed-btn" onclick="feedConcept('random')">Random Value</button>
- </div>
- <button class="feed-btn" style="width: 100%; background: linear-gradient(135deg, #4facfe, #00f2fe);"
- onclick="feedCustom()">Feed Custom Concept</button>
- </div>
- <div class="stats">
- <div class="stat">
- <div class="stat-label">Crystals</div>
- <div class="stat-value" id="crystalCount">0</div>
- </div>
- <div class="stat">
- <div class="stat-label">Balanced</div>
- <div class="stat-value" id="balancedCount">0</div>
- </div>
- <div class="stat">
- <div class="stat-label">Neutral</div>
- <div class="stat-value" id="neutralCount">0</div>
- </div>
- <div class="stat">
- <div class="stat-label">Council Power</div>
- <div class="stat-value" id="councilPower">0</div>
- </div>
- <div class="stat">
- <div class="stat-label">Mysteries</div>
- <div class="stat-value" id="mysteriesSolved">0</div>
- </div>
- </div>
- <div class="personality-info">
- <h4>Crystal Personalities:</h4>
- <ul>
- <li><strong>Dormant</strong> (Gray): New or inactive crystals</li>
- <li><strong>Balanced</strong> (Blue): Harmonious and wise</li>
- <li><strong>Arrogant</strong> (Orange): Prideful and uncooperative</li>
- <li><strong>Neutral</strong> (Green): Balanced but not deeply connected</li>
- </ul>
- </div>
- </div>
- <div class="crystal-garden">
- <div class="crystal-counter" id="crystalCounter">3/10 Crystals</div>
- <div class="crystal-container" id="crystalContainer"></div>
- </div>
- </div>
- <div class="mystery-panel">
- <h3 style="margin-bottom: 15px; color: #c8c8ff;">Mathematical Mystery</h3>
- <div class="mystery-challenge">
- <div id="mysteryText">Grow a balanced crystal council to unlock mysteries...</div>
- <div id="mysteryFlavor" style="font-style: italic; margin-top: 8px; color: #a8a8cc; font-size: 0.9em;"></div>
- </div>
- <button class="solve-btn" id="solveBtn" onclick="attemptSolve()" disabled>
- Council Not Ready
- </button>
- </div>
- </div>
- <script>
- // Expanded list of mathematical mysteries
- const MYSTERIES = [
- { text: "Find the next prime: 2, 3, 5, 7, 11, ?", answer: 13, difficulty: 1, flavor: "Prime numbers are the atoms of mathematics." },
- { text: "Calculate: Fibonacci(8) + Golden Ratio rounded", answer: 23, difficulty: 2, flavor: "Nature's patterns reveal themselves in numbers." },
- { text: "Sum of first 5 perfect squares", answer: 55, difficulty: 2, flavor: "Squares build the foundation of geometry." },
- { text: "What is the value of 4! (4 factorial)?", answer: 24, difficulty: 1, flavor: "Factorials count arrangements and possibilities." },
- { text: "Solve for x: 3x + 7 = 22", answer: 5, difficulty: 1, flavor: "Algebra is the language of patterns." },
- { text: "What is the area of a circle with radius 4?", answer: 50.27, difficulty: 2, flavor: "Circles contain infinite symmetry." },
- { text: "Calculate 2^10", answer: 1024, difficulty: 1, flavor: "Exponential growth shapes our universe." },
- { text: "What is the 10th triangular number?", answer: 55, difficulty: 2, flavor: "Triangular numbers appear in surprising places." },
- { text: "Find the GCD of 36 and 24", answer: 12, difficulty: 1, flavor: "Common divisors reveal hidden relationships." },
- { text: "What is the value of sin(π/2)?", answer: 1, difficulty: 2, flavor: "Trigonometry connects angles to cycles." },
- { text: "Solve: 1 + 2 + 3 + ... + 10", answer: 55, difficulty: 1, flavor: "Sums accumulate meaning from repetition." },
- { text: "What is Euler's number (e) to 2 decimal places?", answer: 2.72, difficulty: 2, flavor: "e emerges from continuous growth." },
- { text: "How many sides does a dodecagon have?", answer: 12, difficulty: 1, flavor: "Polygons shape our spatial understanding." },
- { text: "What is the volume of a cube with side length 3?", answer: 27, difficulty: 1, flavor: "Cubes extend squares into space." },
- { text: "Calculate 7 × 8 + 4", answer: 60, difficulty: 1, flavor: "Operations follow a sacred order." },
- { text: "What is the Pythagorean triple with legs 5 and 12?", answer: 13, difficulty: 2, flavor: "Right triangles hold ancient secrets." },
- { text: "Find the LCM of 6 and 8", answer: 24, difficulty: 1, flavor: "Multiples create harmonious rhythms." },
- { text: "What is the value of 10 choose 3?", answer: 120, difficulty: 3, flavor: "Combinations reveal possible futures." },
- { text: "Solve: 2³ + 3²", answer: 17, difficulty: 1, flavor: "Powers amplify numerical essence." },
- { text: "What is the derivative of x²?", answer: "2x", difficulty: 3, flavor: "Calculus measures change itself." },
- { text: "How many degrees in a right angle?", answer: 90, difficulty: 1, flavor: "Angles define our spatial reality." },
- { text: "What is the sum of interior angles in a pentagon?", answer: 540, difficulty: 2, flavor: "Polygons contain hidden angular sums." },
- { text: "Calculate 15% of 200", answer: 30, difficulty: 1, flavor: "Percentages reveal proportional relationships." },
- { text: "What is the next number: 1, 1, 2, 3, 5, 8, 13, ?", answer: 21, difficulty: 2, flavor: "Fibonacci appears throughout nature." },
- { text: "Solve: 3(x - 4) = 15", answer: 9, difficulty: 2, flavor: "Algebra unlocks unknown quantities." },
- { text: "What is the square root of 144?", answer: 12, difficulty: 1, flavor: "Roots reverse the action of squares." },
- { text: "How many sides on a hexagon?", answer: 6, difficulty: 1, flavor: "Hexagons tile the plane with efficiency." },
- { text: "What is 10 mod 3?", answer: 1, difficulty: 1, flavor: "Modular arithmetic creates cyclic patterns." },
- { text: "Calculate the area of a triangle with base 6 and height 4", answer: 12, difficulty: 1, flavor: "Triangles are the fundamental polygon." },
- { text: "What is the value of 0!?", answer: 1, difficulty: 2, flavor: "Empty products have defined values." },
- { text: "Solve: 2x² - 8 = 0", answer: "2, -2", difficulty: 2, flavor: "Quadratic equations have dual solutions." },
- { text: "What is the golden ratio conjugate (φ)?", answer: 0.618, difficulty: 3, flavor: "The golden ratio appears in aesthetic perfection." },
- { text: "How many prime numbers between 10 and 20?", answer: 4, difficulty: 2, flavor: "Primes become rarer but never cease." },
- { text: "What is the value of 8 × 7 - 6 ÷ 2?", answer: 53, difficulty: 2, flavor: "Order of operations must be respected." },
- { text: "Calculate the circumference of a circle with diameter 10", answer: 31.42, difficulty: 2, flavor: "π connects linear and circular measure." },
- { text: "What is the 6th term of the geometric sequence: 3, 6, 12, 24...?", answer: 96, difficulty: 2, flavor: "Geometric sequences grow exponentially." },
- { text: "Solve: log₂(16)", answer: 4, difficulty: 2, flavor: "Logarithms are the exponents of growth." },
- { text: "What is the sum of the first 10 natural numbers?", answer: 55, difficulty: 1, flavor: "Sums accumulate meaning from repetition." },
- { text: "How many edges does a cube have?", answer: 12, difficulty: 1, flavor: "Polyhedra extend polygons into space." },
- { text: "What is the value of 5³ - 4²?", answer: 109, difficulty: 2, flavor: "Powers and roots create numerical landscapes." },
- { text: "Solve: 2⁴ × 2²", answer: 64, difficulty: 1, flavor: "Exponent rules simplify complex calculations." },
- { text: "What is the median of: 3, 1, 7, 5, 9?", answer: 5, difficulty: 1, flavor: "Central tendencies reveal data's heart." },
- { text: "Calculate 1/2 + 1/3 + 1/6", answer: 1, difficulty: 2, flavor: "Fractions combine to create wholes." },
- { text: "What is the value of 10P2 (permutations)?", answer: 90, difficulty: 3, flavor: "Permutations count ordered arrangements." },
- { text: "Solve: 3! + 4! - 2!", answer: 28, difficulty: 2, flavor: "Factorials grow at an astonishing rate." },
- { text: "What is the probability of rolling a 7 with two dice?", answer: "1/6", difficulty: 2, flavor: "Probability quantifies uncertainty." },
- { text: "Calculate the diagonal of a 3×4 rectangle", answer: 5, difficulty: 2, flavor: "Diagonals reveal hidden connections." },
- { text: "What is the value of i²?", answer: -1, difficulty: 3, flavor: "Imaginary numbers expand our mathematical reality." },
- { text: "Solve: 1 + 3 + 5 + 7 + 9", answer: 25, difficulty: 1, flavor: "Sums of odds create perfect squares." },
- { text: "What is the surface area of a sphere with radius 2?", answer: 50.27, difficulty: 3, flavor: "Spheres maximize volume for surface area." },
- { text: "Prove the Riemann Hypothesis", answer: "Solved", difficulty: 10, flavor: "Some mysteries require transcendent wisdom." },
- { text: "Find a perfect odd number", answer: "Solved", difficulty: 10, flavor: "Some patterns may not exist in our universe." },
- { text: "Determine if P=NP", answer: "Solved", difficulty: 10, flavor: "Complexity theory questions the nature of computation." },
- { text: "Find a non-trivial zero of the zeta function not on the critical line", answer: "Solved", difficulty: 10, flavor: "Some patterns hold against all examination." },
- { text: "Prove the Collatz Conjecture", answer: "Solved", difficulty: 10, flavor: "Simple rules can generate profound complexity." }
- ];
- // Crystal class
- class Crystal {
- constructor(id) {
- this.id = id;
- this.name = this.generateName();
- this.feedCount = 0;
- this.mathDiet = [];
- this.personality = 'dormant';
- this.traits = {
- wisdom: 0,
- arrogance: 0,
- cooperation: 5,
- power: 0,
- neutrality: 5
- };
- this.element = null;
- this.lastFed = Date.now();
- }
- generateName() {
- const prefixes = ['Zeta', 'Phi', 'Omega', 'Delta', 'Sigma', 'Theta', 'Lambda', 'Gamma', 'Alpha', 'Beta'];
- const suffixes = ['trix', 'lon', 'dor', 'kan', 'vel', 'nis', 'ros', 'mal', 'thos', 'quar'];
- return prefixes[Math.floor(Math.random() * prefixes.length)] +
- suffixes[Math.floor(Math.random() * suffixes.length)];
- }
- feed(concept, value) {
- this.feedCount++;
- this.mathDiet.push({ concept, value, time: Date.now() });
- this.lastFed = Date.now();
- switch(concept) {
- case 'prime':
- this.traits.wisdom += 2;
- this.traits.power += 1;
- this.traits.neutrality -= 1;
- break;
- case 'golden':
- case 'fibonacci':
- this.traits.cooperation += 2;
- this.traits.wisdom += 1;
- this.traits.neutrality -= 1;
- break;
- case 'pi':
- case 'euler':
- this.traits.wisdom += 3;
- this.traits.neutrality -= 1;
- break;
- case 'perfect':
- this.traits.power += 2;
- this.traits.arrogance += 1;
- this.traits.neutrality -= 1;
- break;
- case 'complex':
- this.traits.neutrality += 2;
- this.traits.wisdom += 1;
- break;
- case 'random':
- this.traits.neutrality += 3;
- break;
- default:
- this.traits.power += 1;
- this.traits.wisdom += 1;
- this.traits.neutrality += 0.5;
- }
- // Determine personality based on trait balance
- if (this.feedCount < 2) {
- this.personality = 'dormant';
- } else if (this.traits.arrogance > 8 || this.feedCount > 12) {
- this.personality = 'arrogant';
- this.traits.cooperation = Math.max(0, this.traits.cooperation - 2);
- } else if (this.traits.cooperation > 7 && this.traits.wisdom > 5 && this.traits.arrogance < 5) {
- this.personality = 'balanced';
- } else if (this.traits.neutrality > 7) {
- this.personality = 'neutral';
- } else if (this.feedCount >= 3 && this.feedCount <= 8 && this.traits.cooperation > 5) {
- this.personality = 'balanced';
- } else {
- this.personality = 'neutral';
- }
- this.updateDisplay();
- this.showReaction();
- }
- showReaction() {
- const reactions = {
- 'dormant': ['...', 'Mmm...', '*yawn*'],
- 'balanced': ['Fascinating!', 'Perfect harmony', 'I understand now', 'This resonates'],
- 'arrogant': ['Too simple!', 'I knew that', 'Boring...', 'Child\'s play'],
- 'neutral': ['Interesting', 'I observe', 'Noted', 'Acceptable']
- };
- const speech = this.element.querySelector('.crystal-speech');
- speech.textContent = reactions[this.personality][Math.floor(Math.random() * reactions[this.personality].length)];
- speech.classList.add('show');
- setTimeout(() => speech.classList.remove('show'), 2000);
- this.createParticles();
- }
- createParticles() {
- const colors = {
- 'dormant': '#6a6a8a',
- 'balanced': '#00d4ff',
- 'arrogant': '#ffaa00',
- 'neutral': '#2e8b57'
- };
- for (let i = 0; i < 8; i++) {
- const particle = document.createElement('div');
- particle.className = 'particle';
- particle.style.left = '60px';
- particle.style.top = '50px';
- particle.style.background = `radial-gradient(circle, ${colors[this.personality]}, transparent)`;
- particle.style.setProperty('--tx', (Math.random() - 0.5) * 100 + 'px');
- particle.style.setProperty('--ty', (Math.random() - 0.5) * 100 + 'px');
- this.element.appendChild(particle);
- setTimeout(() => particle.remove(), 3000);
- }
- }
- updateDisplay() {
- if (!this.element) return;
- this.element.className = 'crystal ' + this.personality;
- const personalityText = this.element.querySelector('.crystal-personality');
- const descriptions = {
- 'dormant': 'Sleeping...',
- 'balanced': 'Harmonious & Wise',
- 'arrogant': 'Prideful & Uncooperative',
- 'neutral': 'Neutral Observer'
- };
- personalityText.textContent = descriptions[this.personality];
- }
- calculatePower() {
- if (this.personality === 'arrogant') return this.traits.power * 0.3;
- if (this.personality === 'balanced') return this.traits.power * 1.5 + this.traits.wisdom;
- if (this.personality === 'neutral') return this.traits.power * 0.7 + this.traits.wisdom * 0.5;
- return this.traits.power * 0.1;
- }
- }
- // Garden class
- class CrystalGarden {
- constructor() {
- this.crystals = [];
- this.mysteriesSolved = 0;
- this.currentMystery = null;
- this.maxCrystals = 10;
- this.selectedCrystal = null;
- this.usedMysteries = new Set();
- this.init();
- }
- init() {
- for (let i = 0; i < 3; i++) {
- this.addCrystal();
- }
- this.generateMystery();
- this.updateStats();
- }
- addCrystal() {
- if (this.crystals.length >= this.maxCrystals) return;
- const crystal = new Crystal(this.crystals.length);
- this.crystals.push(crystal);
- const container = document.getElementById('crystalContainer');
- const crystalEl = document.createElement('div');
- crystalEl.className = 'crystal dormant';
- crystalEl.innerHTML = '<div class="crystal-speech"></div>' +
- '<div class="crystal-body">' +
- '<div class="crystal-top"></div>' +
- '<div class="crystal-bottom"></div>' +
- '</div>' +
- '<div class="crystal-info">' +
- '<div class="crystal-name">' + crystal.name + '</div>' +
- '<div class="crystal-personality">Sleeping...</div>' +
- '</div>';
- crystal.element = crystalEl;
- crystalEl.onclick = () => this.selectCrystal(crystal);
- container.appendChild(crystalEl);
- this.updateStats();
- // Show notification for new crystal
- if (this.crystals.length > 3) {
- this.showNewCrystalNotification();
- }
- }
- showNewCrystalNotification() {
- const notification = document.createElement('div');
- notification.className = 'new-crystal-notification';
- notification.textContent = 'A new crystal has formed!';
- const garden = document.querySelector('.crystal-garden');
- garden.appendChild(notification);
- setTimeout(() => notification.remove(), 3000);
- }
- selectCrystal(crystal) {
- this.selectedCrystal = crystal;
- document.querySelectorAll('.crystal').forEach(el => {
- el.style.filter = 'brightness(0.5)';
- });
- crystal.element.style.filter = 'brightness(1)';
- this.showNotification('Selected ' + crystal.name);
- }
- feedSelectedCrystal(concept, value) {
- if (!this.selectedCrystal) {
- this.showNotification('Select a crystal first!');
- return;
- }
- this.selectedCrystal.feed(concept, value);
- this.updateStats();
- this.checkMysteryReadiness();
- // Chance of new crystal growth with more feedings
- if (Math.random() < 0.25 && this.crystals.length < this.maxCrystals) {
- setTimeout(() => this.addCrystal(), 1000);
- }
- }
- generateMystery() {
- // Reset used mysteries if all have been used
- if (this.usedMysteries.size >= MYSTERIES.length) {
- this.usedMysteries.clear();
- }
- // Find a mystery that hasn't been used recently
- let availableMysteries = MYSTERIES.filter((_, index) => !this.usedMysteries.has(index));
- if (availableMysteries.length === 0) {
- // If all mysteries have been used, reset
- this.usedMysteries.clear();
- availableMysteries = MYSTERIES;
- }
- // Select a random mystery from available ones
- const randomIndex = Math.floor(Math.random() * availableMysteries.length);
- this.currentMystery = availableMysteries[randomIndex];
- // Mark this mystery as used
- const mysteryIndex = MYSTERIES.indexOf(this.currentMystery);
- this.usedMysteries.add(mysteryIndex);
- document.getElementById('mysteryText').textContent = this.currentMystery.text;
- document.getElementById('mysteryFlavor').textContent = this.currentMystery.flavor;
- }
- checkMysteryReadiness() {
- const balancedCrystals = this.crystals.filter(c => c.personality === 'balanced');
- const councilPower = this.calculateCouncilPower();
- const solveBtn = document.getElementById('solveBtn');
- if (balancedCrystals.length >= 2 && councilPower >= this.currentMystery.difficulty * 10) {
- solveBtn.disabled = false;
- solveBtn.textContent = 'Solve Mystery!';
- } else {
- solveBtn.disabled = true;
- solveBtn.textContent = 'Need ' + Math.max(0, 2 - balancedCrystals.length) + ' more balanced crystals';
- }
- }
- calculateCouncilPower() {
- return this.crystals.reduce((total, crystal) => total + crystal.calculatePower(), 0);
- }
- attemptSolve() {
- const balancedCrystals = this.crystals.filter(c => c.personality === 'balanced');
- if (balancedCrystals.length >= 2) {
- this.mysteriesSolved++;
- this.showNotification('Mystery Solved! Council wisdom prevails!');
- balancedCrystals.forEach(c => {
- c.traits.wisdom += 5;
- c.showReaction();
- });
- this.generateMystery();
- this.updateStats();
- this.checkMysteryReadiness();
- }
- }
- updateStats() {
- document.getElementById('crystalCount').textContent = this.crystals.length;
- document.getElementById('balancedCount').textContent =
- this.crystals.filter(c => c.personality === 'balanced').length;
- document.getElementById('neutralCount').textContent =
- this.crystals.filter(c => c.personality === 'neutral').length;
- document.getElementById('councilPower').textContent =
- Math.floor(this.calculateCouncilPower());
- document.getElementById('mysteriesSolved').textContent = this.mysteriesSolved;
- document.getElementById('crystalCounter').textContent =
- this.crystals.length + '/10 Crystals';
- }
- showNotification(message) {
- const existing = document.querySelector('.notification');
- if (existing) existing.remove();
- const notif = document.createElement('div');
- notif.className = 'notification';
- notif.textContent = message;
- document.body.appendChild(notif);
- setTimeout(() => notif.remove(), 3000);
- }
- }
- // Math functions
- function isPrime(n) {
- if (n <= 1) return false;
- for (let i = 2; i <= Math.sqrt(n); i++) {
- if (n % i === 0) return false;
- }
- return true;
- }
- function getFibonacci(n) {
- if (n <= 1) return n;
- let a = 0, b = 1;
- for (let i = 2; i <= n; i++) {
- let temp = b;
- b = a + b;
- a = temp;
- }
- return b;
- }
- function isPerfectSquare(n) {
- const sqrt = Math.sqrt(n);
- return sqrt === Math.floor(sqrt);
- }
- // Initialize
- let garden = new CrystalGarden();
- // Feed functions
- function feedConcept(type) {
- let value;
- switch(type) {
- case 'prime':
- value = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29][Math.floor(Math.random() * 10)];
- break;
- case 'fibonacci':
- const n = Math.floor(Math.random() * 10) + 1;
- value = getFibonacci(n);
- break;
- case 'golden':
- value = 1.618;
- break;
- case 'pi':
- value = 3.14159;
- break;
- case 'euler':
- value = 2.71828;
- break;
- case 'perfect':
- value = [4, 9, 16, 25, 36, 49, 64, 81, 100][Math.floor(Math.random() * 9)];
- break;
- case 'complex':
- value = [1, -1, Math.sqrt(2)][Math.floor(Math.random() * 3)];
- break;
- case 'random':
- value = Math.floor(Math.random() * 100) + 1;
- break;
- }
- garden.feedSelectedCrystal(type, value);
- }
- function feedCustom() {
- const input = document.getElementById('mathInput').value.trim();
- if (!input) {
- garden.showNotification('Enter a mathematical concept!');
- return;
- }
- const num = parseFloat(input);
- if (!isNaN(num)) {
- if (isPrime(Math.floor(num))) {
- garden.feedSelectedCrystal('prime', num);
- } else if (isPerfectSquare(num)) {
- garden.feedSelectedCrystal('perfect', num);
- } else if (Math.abs(num - 1.618) < 0.01) {
- garden.feedSelectedCrystal('golden', num);
- } else if (Math.abs(num - 3.14159) < 0.01) {
- garden.feedSelectedCrystal('pi', num);
- } else {
- garden.feedSelectedCrystal('equation', num);
- }
- } else {
- garden.showNotification('Invalid mathematical concept!');
- }
- document.getElementById('mathInput').value = '';
- }
- function attemptSolve() {
- garden.attemptSolve();
- }
- // Keyboard shortcuts
- document.addEventListener('keydown', (e) => {
- if (e.key >= '1' && e.key <= '0') {
- let index;
- if (e.key === '0') {
- index = 9;
- } else {
- index = parseInt(e.key) - 1;
- }
- if (index < garden.crystals.length) {
- garden.selectCrystal(garden.crystals[index]);
- }
- }
- });
- // Aging system
- setInterval(() => {
- garden.crystals.forEach(crystal => {
- const timeSinceLastFed = Date.now() - crystal.lastFed;
- if (timeSinceLastFed > 30000 && crystal.personality === 'balanced') {
- crystal.traits.cooperation -= 1;
- if (crystal.traits.cooperation < 5) {
- crystal.personality = 'neutral';
- crystal.updateDisplay();
- }
- }
- });
- garden.updateStats();
- garden.checkMysteryReadiness();
- }, 10000);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment