Prompt
Create a p5.js animation that visually represents how genetic algorithms evolve solutions over generations. Start by displaying a population of simple creatures (e.g., dots, rectangles, or basic stick figures) trying to reach a target on the screen. Each generation should attempt to move toward the goal, and their "genes" (e.g., movement vectors or decision sequences) should mutate slightly over time. Visually show crossover and mutation steps during the transition to a new generation. Use colors and simple effects to indicate fitness (e.g., brightness or size), and animate the progression every few seconds. The goal is to help students intuitively grasp how evolution-inspired algorithms work.
A system prompt was added to support web rendering