Spaces:
Running
Running
a particle sim
Browse filesParticles have x, y, phase, and value
Phase range 0-2PI default to PI +- 5%
Phase controls the degree of attraction/repulsion to other particles. 0 = very attracted to other particles, 2PI = very repulsed from other particles, PI = balanced (both attracted to and repulsed from)
Particles influence the phases of other particles
Particles influence each others phases by formula: (number oof particles * average particle phase) / average distance of particles
But only if the other particle is between a global minimum and max distance
Particles also have a value between 2-100 set when the sim starts.
Particles have second-order attraction to - they stick to - other particles whose values share prime factors with theirs
- README.md +9 -5
- index.html +262 -18
README.md
CHANGED
|
@@ -1,10 +1,14 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: undefined
|
| 3 |
+
colorFrom: yellow
|
| 4 |
+
colorTo: gray
|
| 5 |
+
emoji: 🐳
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite-v3
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Welcome to your new DeepSite project!
|
| 13 |
+
This project was created with [DeepSite](https://deepsite.hf.co).
|
| 14 |
+
|
index.html
CHANGED
|
@@ -1,19 +1,263 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>QuantumPrimeSync: Particle Harmony Nexus</title>
|
| 7 |
+
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
|
| 8 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 10 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 11 |
+
</head>
|
| 12 |
+
<body class="bg-gray-900 text-white overflow-hidden">
|
| 13 |
+
<div class="absolute top-0 left-0 w-full z-10">
|
| 14 |
+
<div class="container mx-auto px-4 py-6">
|
| 15 |
+
<div class="flex flex-col md:flex-row justify-between items-center">
|
| 16 |
+
<h1 class="text-3xl font-bold text-purple-400 mb-4 md:mb-0">QuantumPrimeSync <span class="text-2xl">🌌</span></h1>
|
| 17 |
+
<div class="flex items-center space-x-4">
|
| 18 |
+
<div class="flex items-center space-x-2">
|
| 19 |
+
<span class="text-sm">Particles: <span id="particleCount" class="font-mono">0</span></span>
|
| 20 |
+
<button id="addParticle" class="bg-purple-600 hover:bg-purple-700 px-3 py-1 rounded-lg text-sm transition-colors">
|
| 21 |
+
<i data-feather="plus"></i>
|
| 22 |
+
</button>
|
| 23 |
+
</div>
|
| 24 |
+
<button id="reset" class="bg-red-600 hover:bg-red-700 px-4 py-2 rounded-lg text-sm transition-colors">
|
| 25 |
+
<i data-feather="refresh-cw" class="w-4 h-4"></i> Reset
|
| 26 |
+
</button>
|
| 27 |
+
</div>
|
| 28 |
+
</div>
|
| 29 |
+
</div>
|
| 30 |
+
</div>
|
| 31 |
+
|
| 32 |
+
<canvas id="particleCanvas" class="w-full h-screen"></canvas>
|
| 33 |
+
|
| 34 |
+
<div class="absolute bottom-0 left-0 w-full z-10">
|
| 35 |
+
<div class="container mx-auto px-4 py-6">
|
| 36 |
+
<div class="bg-gray-800 bg-opacity-80 backdrop-blur-sm rounded-xl p-6 max-w-md">
|
| 37 |
+
<h2 class="text-xl font-semibold mb-4 text-purple-300">Controls</h2
|
| 38 |
+
<div class="space-y-4">
|
| 39 |
+
<div>
|
| 40 |
+
<label class="block text-sm font-medium mb-2">Minimum Distance</label>
|
| 41 |
+
<input type="range" id="minDist" min="10" max="200" value="50" class="w-full accent-purple-500">
|
| 42 |
+
<span id="minDistValue" class="text-xs text-gray-400">50</span>
|
| 43 |
+
</div>
|
| 44 |
+
<div>
|
| 45 |
+
<label class="block text-sm font-medium mb-2">Maximum Distance</label>
|
| 46 |
+
<input type="range" id="maxDist" min="100" max="500" value="300" class="w-full accent-purple-500">
|
| 47 |
+
<span id="maxDistValue" class="text-xs text-gray-400">300</span>
|
| 48 |
+
</div>
|
| 49 |
+
<div>
|
| 50 |
+
<label class="block text-sm font-medium mb-2">Attraction Force</label>
|
| 51 |
+
<input type="range" id="force" min="0.1" max="2" step="0.1" value="0.5" class="w-full accent-purple-500">
|
| 52 |
+
<span id="forceValue" class="text-xs text-gray-400">0.5</span>
|
| 53 |
+
</div>
|
| 54 |
+
</div>
|
| 55 |
+
<div class="mt-4 p-3 bg-gray-700 rounded-lg">
|
| 56 |
+
<p class="text-sm text-gray-300">Particles have values (2-100) and attract based on shared prime factors!</p>
|
| 57 |
+
</div>
|
| 58 |
+
</div>
|
| 59 |
+
</div>
|
| 60 |
+
</div>
|
| 61 |
+
|
| 62 |
+
<script>
|
| 63 |
+
const canvas = document.getElementById('particleCanvas');
|
| 64 |
+
const ctx = canvas.getContext('2d');
|
| 65 |
+
|
| 66 |
+
// Set canvas size
|
| 67 |
+
function resizeCanvas() {
|
| 68 |
+
canvas.width = window.innerWidth;
|
| 69 |
+
canvas.height = window.innerHeight;
|
| 70 |
+
}
|
| 71 |
+
resizeCanvas();
|
| 72 |
+
window.addEventListener('resize', resizeCanvas);
|
| 73 |
+
|
| 74 |
+
// Particle system
|
| 75 |
+
class Particle {
|
| 76 |
+
constructor(x, y) {
|
| 77 |
+
this.x = x || Math.random() * canvas.width;
|
| 78 |
+
this.y = y || Math.random() * canvas.height;
|
| 79 |
+
this.vx = (Math.random() - 0.5) * 2;
|
| 80 |
+
this.vy = (Math.random() - 0.5) * 2;
|
| 81 |
+
this.radius = 4;
|
| 82 |
+
this.phase = Math.PI + (Math.random() - 0.5) * Math.PI * 0.1; // PI ± 5%
|
| 83 |
+
this.hue = (this.phase / (2 * Math.PI)) * 360;
|
| 84 |
+
}
|
| 85 |
+
update(particles, minDist, maxDist, force) {
|
| 86 |
+
// Apply phase influence from nearby particles
|
| 87 |
+
let totalPhase = 0;
|
| 88 |
+
let validParticles = 0;
|
| 89 |
+
let totalDistance = 0;
|
| 90 |
+
|
| 91 |
+
particles.forEach(other => {
|
| 92 |
+
if (other !== this) {
|
| 93 |
+
const dx = other.x - this.x;
|
| 94 |
+
const dy = other.y - this.y;
|
| 95 |
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
| 96 |
+
|
| 97 |
+
if (distance >= minDist && distance <= maxDist) {
|
| 98 |
+
totalPhase += other.phase;
|
| 99 |
+
totalDistance += distance;
|
| 100 |
+
validParticles++;
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
});
|
| 104 |
+
|
| 105 |
+
if (validParticles > 0) {
|
| 106 |
+
const avgPhase = totalPhase / validParticles;
|
| 107 |
+
const avgDistance = totalDistance / validParticles;
|
| 108 |
+
const phaseInfluence = (validParticles * avgPhase) / avgDistance;
|
| 109 |
+
this.phase = (this.phase + phaseInfluence * 0.001) % (2 * Math.PI);
|
| 110 |
+
this.hue = (this.phase / (2 * Math.PI)) * 360;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
// Apply attraction/repulsion based on phase
|
| 114 |
+
particles.forEach(other => {
|
| 115 |
+
if (other !== this) {
|
| 116 |
+
const dx = other.x - this.x;
|
| 117 |
+
const dy = other.y - this.y;
|
| 118 |
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
| 119 |
+
|
| 120 |
+
if (distance > 0 && distance < maxDist) {
|
| 121 |
+
// Phase-based force
|
| 122 |
+
let phaseForce = 0;
|
| 123 |
+
if (this.phase === 0) {
|
| 124 |
+
phaseForce = 1; // Maximum attraction
|
| 125 |
+
} else if (this.phase === 2 * Math.PI) {
|
| 126 |
+
phaseForce = -1; // Maximum repulsion
|
| 127 |
+
} else if (this.phase < Math.PI) {
|
| 128 |
+
phaseForce = 1 - (this.phase / Math.PI); // Decreasing attraction
|
| 129 |
+
} else {
|
| 130 |
+
phaseForce = -((this.phase - Math.PI) / Math.PI); // Increasing repulsion
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
const fx = (dx / distance) * force * phaseForce;
|
| 134 |
+
const fy = (dy / distance) * force * phaseForce;
|
| 135 |
+
|
| 136 |
+
this.vx += fx;
|
| 137 |
+
this.vy += fy;
|
| 138 |
+
|
| 139 |
+
// Prime factor attraction - stronger bond when particles share prime factors
|
| 140 |
+
const sharedFactors = this.primeFactors.filter(factor =>
|
| 141 |
+
other.primeFactors.includes(factor)
|
| 142 |
+
);
|
| 143 |
+
if (sharedFactors.length > 0) {
|
| 144 |
+
const primeAttraction = sharedFactors.length * 0.1;
|
| 145 |
+
const primeFx = (dx / distance) * primeAttraction;
|
| 146 |
+
const primeFy = (dy / distance) * primeAttraction;
|
| 147 |
+
this.vx += primeFx;
|
| 148 |
+
this.vy += primeFy;
|
| 149 |
+
}
|
| 150 |
+
}
|
| 151 |
+
}
|
| 152 |
+
});
|
| 153 |
+
// Update position with velocity damping
|
| 154 |
+
this.vx *= 0.99;
|
| 155 |
+
this.vy *= 0.99;
|
| 156 |
+
this.x += this.vx;
|
| 157 |
+
this.y += this.vy;
|
| 158 |
+
|
| 159 |
+
// Boundary collision
|
| 160 |
+
if (this.x < 0 || this.x > canvas.width) this.vx *= -0.8;
|
| 161 |
+
if (this.y < 0 || this.y > canvas.height) this.vy *= -0.8;
|
| 162 |
+
|
| 163 |
+
this.x = Math.max(0, Math.min(canvas.width, this.x));
|
| 164 |
+
this.y = Math.max(0, Math.min(canvas.height, this.y));
|
| 165 |
+
}
|
| 166 |
+
draw() {
|
| 167 |
+
ctx.beginPath();
|
| 168 |
+
ctx.arc(this.x, this.y, this.radius, 0, 2 * Math.PI);
|
| 169 |
+
ctx.fillStyle = `hsl(${this.hue}, 70%, 60%)`;
|
| 170 |
+
ctx.fill();
|
| 171 |
+
|
| 172 |
+
// Draw phase indicator
|
| 173 |
+
ctx.beginPath();
|
| 174 |
+
ctx.arc(this.x, this.y, this.radius + 2, 0, this.phase, false);
|
| 175 |
+
ctx.strokeStyle = 'white';
|
| 176 |
+
ctx.lineWidth = 1;
|
| 177 |
+
ctx.stroke();
|
| 178 |
+
|
| 179 |
+
// Draw value indicator
|
| 180 |
+
ctx.fillStyle = 'white';
|
| 181 |
+
ctx.font = '10px Arial';
|
| 182 |
+
ctx.textAlign = 'center';
|
| 183 |
+
ctx.textBaseline = 'middle';
|
| 184 |
+
ctx.fillText(this.value, this.x, this.y);
|
| 185 |
+
}
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
// Initialize particles
|
| 189 |
+
let particles = [];
|
| 190 |
+
const initialCount = 50;
|
| 191 |
+
|
| 192 |
+
for (let i = 0; i < initialCount; i++) {
|
| 193 |
+
particles.push(new Particle());
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
// Control variables
|
| 197 |
+
let minDist = 50;
|
| 198 |
+
let maxDist = 300;
|
| 199 |
+
let force = 0.5;
|
| 200 |
+
|
| 201 |
+
// Animation loop
|
| 202 |
+
function animate() {
|
| 203 |
+
ctx.fillStyle = 'rgba(17, 24, 39, 0.1)';
|
| 204 |
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
| 205 |
+
|
| 206 |
+
particles.forEach(particle => {
|
| 207 |
+
particle.update(particles, minDist, maxDist, force);
|
| 208 |
+
particle.draw();
|
| 209 |
+
});
|
| 210 |
+
|
| 211 |
+
requestAnimationFrame(animate);
|
| 212 |
+
}
|
| 213 |
+
animate();
|
| 214 |
+
|
| 215 |
+
// Event listeners for controls
|
| 216 |
+
document.getElementById('addParticle').addEventListener('click', () => {
|
| 217 |
+
particles.push(new Particle());
|
| 218 |
+
updateParticleCount();
|
| 219 |
+
});
|
| 220 |
+
|
| 221 |
+
document.getElementById('reset').addEventListener('click', () => {
|
| 222 |
+
particles = [];
|
| 223 |
+
for (let i = 0; i < initialCount; i++) {
|
| 224 |
+
particles.push(new Particle());
|
| 225 |
+
}
|
| 226 |
+
updateParticleCount();
|
| 227 |
+
});
|
| 228 |
+
|
| 229 |
+
document.getElementById('minDist').addEventListener('input', (e) => {
|
| 230 |
+
minDist = parseInt(e.target.value);
|
| 231 |
+
document.getElementById('minDistValue').textContent = minDist;
|
| 232 |
+
});
|
| 233 |
+
|
| 234 |
+
document.getElementById('maxDist').addEventListener('input', (e) => {
|
| 235 |
+
maxDist = parseInt(e.target.value);
|
| 236 |
+
document.getElementById('maxDistValue').textContent = maxDist;
|
| 237 |
+
});
|
| 238 |
+
|
| 239 |
+
document.getElementById('force').addEventListener('input', (e) => {
|
| 240 |
+
force = parseFloat(e.target.value);
|
| 241 |
+
document.getElementById('forceValue').textContent = force;
|
| 242 |
+
});
|
| 243 |
+
|
| 244 |
+
function updateParticleCount() {
|
| 245 |
+
document.getElementById('particleCount').textContent = particles.length;
|
| 246 |
+
}
|
| 247 |
+
updateParticleCount();
|
| 248 |
+
|
| 249 |
+
// Add particles on click
|
| 250 |
+
canvas.addEventListener('click', (e) => {
|
| 251 |
+
const rect = canvas.getBoundingClientRect();
|
| 252 |
+
const x = e.clientX - rect.left;
|
| 253 |
+
const y = e.clientY - rect.top;
|
| 254 |
+
particles.push(new Particle(x, y));
|
| 255 |
+
updateParticleCount();
|
| 256 |
+
});
|
| 257 |
+
|
| 258 |
+
// Initialize feather icons
|
| 259 |
+
feather.replace();
|
| 260 |
+
</script>
|
| 261 |
+
</body>
|
| 262 |
</html>
|
| 263 |
+
|