-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
35 lines (29 loc) · 801 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "SRC/genetic.h"
#include "SRC/robot.h"
int main()
{
srand(time(NULL));
rand();
start_population();
set_start_variables();
int distance = 0;
unsigned long long int gen = 0;
double random = (double)rand()/(double)RAND_MAX;
while(gen != MAX_GEN)
{
gen++;
distance = (int)(1/calculate_fitness());
decode();
printf("Gen: %lld\tLocal minimmum: %d\tGlobal minimmum: %d\t",
gen, distance, winner.minor_distance);
printf("Coordenadas da porta(x,y): (%d,%d)\n", door.p.x, door.p.y);
if(random <= MUTATION_PROB)
mutation();
random = (double)rand()/(double)RAND_MAX;
fflush(stdin);
}
printf("Done!\n");
}