SantanderAI/genetic-algorithm — reverse-engineered prompt

Reverse engineered prompt

Build me a small, clean Python library that implements a genetic algorithm engine with no runtime dependencies beyond the standard library.

I want it to feel reusable, not like a one off script. The core should handle population, selection, crossover, mutation, elitism, and reproducible runs with a seed. The important part is that the idea of fitness is swappable, so I can pass in a normal Python function or register a named fitness function and use that as a plugin. Higher scores should mean better candidates.

Please include a simple API for working with populations and chromosomes, a few built in fitness examples like maximizing values, matching a target vector, and a weighted sum, plus example scripts that show basic numeric optimization and a simple autoresearcher style loop where candidates are generated, scored, and improved over generations. If it makes sense, support optional multithreaded fitness evaluation for slow scoring functions.

Add tests, a short README with usage examples, and keep the code easy to understand. Look up current docs online if you need to.

Want more depth? Deep Reverse