simulation: separate out mutation into its own function

This commit is contained in:
2026-03-18 09:53:27 +00:00
parent 41c4a39e05
commit deec79a3bf
2 changed files with 5 additions and 2 deletions

View File

@@ -23,9 +23,8 @@ static const Color possible_colors[] = {
['\0'] = {0x0, 0x0, 0x0, 0xff}, ['\0'] = {0x0, 0x0, 0x0, 0xff},
}; };
void simulation_iterate(simulation_t *sim) void simulation_mutate(simulation_t *sim)
{ {
// Mutate cells if an option
#if MUTATION_CHANCE #if MUTATION_CHANCE
for (u64 i = 0; i < SIMULATION_SIZE; ++i) for (u64 i = 0; i < SIMULATION_SIZE; ++i)
{ {
@@ -35,7 +34,10 @@ void simulation_iterate(simulation_t *sim)
} }
} }
#endif #endif
}
void simulation_iterate(simulation_t *sim)
{
u64 a = 0, b = 0; u64 a = 0, b = 0;
while (a == b) while (a == b)
{ {

View File

@@ -16,6 +16,7 @@ typedef struct
bf_token memory[SIMULATION_SIZE]; bf_token memory[SIMULATION_SIZE];
} simulation_t; } simulation_t;
void simulation_mutate(simulation_t *sim);
void simulation_iterate(simulation_t *sim); void simulation_iterate(simulation_t *sim);
void simulation_draw(simulation_t *sim); void simulation_draw(simulation_t *sim);