Here's a complex evolution simulator with god mode and visualization features. I'll create an interactive HTML5 Canvas-based simulator with detailed tooltips and advanced controls:
html Copy code
<!DOCTYPE html>
<html>
<head>
<title>Evolution Simulator</title>
<style>
body {
margin: 0;
overflow: hidden;
background: #111;
font-family: 'Arial', sans-serif;
color: #fff;
}
canvas {
display: block;
}
.controls {
position: absolute;
top: 10px;
left: 10px;
background: rgba(0,0,0,0.7);
padding: 10px;
border-radius: 5px;
}
.tooltip {
position: absolute;
background: rgba(0,0,0,0.8);
padding: 10px;
border-radius: 5px;
pointer-events: none;
transition: opacity 0.3s;
max-width: 300px;
}
button {
background: #2a2a72;
color: white;
border: none;
padding: 5px 10px;
margin: 2px;
border-radius: 3px;
cursor: pointer;
transition: background 0.3s;
}
button:hover {
background: #3a3a92;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<div class="controls">
<button onclick="godMode('add')">Add Organism</button>
<button onclick="godMode('delete')">Delete Selected</button>
<button onclick="godMode('fast')">Speed x2</button>
<button onclick="godMode('slow')">Speed x0.5</button>
<button onclick="toggleGenes()">Toggle Gene View</button>
</div>
<div class="tooltip" id="tooltip" style="display:none"></div>
<script>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
class Organism {
constructor(x, y) {
this.x = x;
this.y = y;
this.energy = 100;
this.age = 0;
this.selected = false;
this.genes = {
speed: 1 + Math.random(),
size: 5 + Math.random()*15,
metabolism: 0.5 + Math.random(),
color: `hsl(${Math.random()*360}, 70%, 50%)`
};
this.senses = {
vision: 50 + Math.random()*100,
hearing: 30 + Math.random()*70
};
this.morphology = {
limbs: Math.floor(2 + Math.random()*6),
symmetry: Math.random() > 0.5 ? 'radial' : 'bilateral',
texture: ['smooth', 'spiky', 'scaly'][Math.floor(Math.random()*3)]
};
}
update() {
this.age += 0.01;
this.energy -= this.genes.metabolism;
// Add movement and interaction logic
}
draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.genes.size, 0, Math.PI*2);
ctx.fillStyle = this.genes.color;
ctx.fill();
if(this.selected) {
ctx.strokeStyle = '#fff';
ctx.lineWidth = 2;
ctx.stroke();
}
}
}
let organisms = [];
let timeScale = 1;
let showGenes = false;
function init() {
// Create initial population
for(let i = 0; i < 50; i++) {
organisms.push(new Organism(
Math.random()*canvas.width,
Math.random()*canvas.height
));
}
}
function update() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Draw environment
ctx.fillStyle = '#111';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Update and draw organisms
organisms.forEach(org => {
org.update();
org.draw();
});
requestAnimationFrame(update);
}
function showTooltip(e) {
const tooltip = document.getElementById('tooltip');
const rect = canvas.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
// Find organism under cursor
const org = organisms.find(o =>
Math.hypot(o.x - x, o.y - y) < o.genes.size
);
if(org) {
tooltip.style.display = 'block';
tooltip.style.left = e.clientX + 10 + 'px';
tooltip.style.top = e.clientY + 10 + 'px';
tooltip.innerHTML = `
<h3>Organism Stats</h3>
<p>Age: ${org.age.toFixed(2)}</p>
<p>Energy: ${org.energy.toFixed(0)}</p>
<div ${showGenes ? '' : 'style="display:none"'}>
<h4>Genes:</h4>
<p>Speed: ${org.genes.speed.toFixed(2)}</p>
<p>Size: ${org.genes.size.toFixed(1)}</p>
<p>Metabolism: ${org.genes.metabolism.toFixed(2)}</p>
</div>
<h4>Senses:</h4>
<p>Vision: ${org.senses.vision.toFixed(0)}</p>
<p>Hearing: ${org.senses.hearing.toFixed(0)}</p>
<h4>Morphology:</h4>
<p>Limbs: ${org.morphology.limbs}</p>
<p>Symmetry: ${org.morphology.symmetry}</p>
<p>Texture: ${org.morphology.texture}</p>
`;
} else {
tooltip.style.display = 'none';
}
}
function godMode(action) {
switch(action) {
case 'add':
organisms.push(new Organism(
Math.random()*canvas.width,
Math.random()*canvas.height
));
break;
case 'delete':
organisms = organisms.filter(org => !org.selected);
break;
case 'fast':
timeScale *= 2;
break;
case 'slow':
timeScale /= 2;
break;
}
}
function toggleGenes() {
showGenes = !showGenes;
}
canvas.addEventListener('mousemove', showTooltip);
canvas.addEventListener('click', e => {
const rect = canvas.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
organisms.forEach(org => {
org.selected = Math.hypot(org.x - x, org.y - y) < org.genes.size;
});
});
// Start simulation
init();
update();
</script>
</body>
</html>