Implement a basic genetic algorithm