E
Solo Assignment

Evolutionary Jumper Simulation

PythonPygameBox2DMatplotlibEvolutionary Algorithms

Overview

Solo assignment for the ML2 course at INN. A physics-based evolutionary simulation built with Pygame and Box2D. Each individual agent has a genome of 4 values — jump angle, jump force, body width, and body height — initialized randomly. Each generation, the top 50% are selected as parents, cloned into offspring, and mutated by adding small random values to their genome. Over 80 generations the population visibly improves. A Matplotlib fitness graph plots average and max fitness across all generations showing the learning curve.

My Contributions

  • Implemented random genome initialization for 20 agents with uniform distribution
  • Built the selection operator — sorts population by fitness and keeps top 50%
  • Built the variation operator — clones the best parents and fixed population shrinking bug so offspring always stays at 20
  • Implemented mutate() — mutates genome with random noise and clamps values between -1 and 1
  • Built the full evolutionary main loop across 80 generations: selection → variation → mutation → evaluation
  • Added Matplotlib fitness graph tracking average and max fitness per generation
  • Added color mutation inside mutate() so agents visually change color each generation
  • Debugged and fixed 10+ bugs: population shrinking, wrong indentation on plt, generation number showing None, duplicate generation 0

Tech Breakdown

Python, Pygame (visualisation), Box2D (physics simulation), Matplotlib (fitness graph), evolutionary algorithm (selection + mutation), genome-based agent design, clamp utility for value bounding