-
Notifications
You must be signed in to change notification settings - Fork 18
/
main.c
54 lines (46 loc) · 832 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdlib.h>
#include <time.h>
#ifdef WIN32
#include <windows.h>
#endif
#include "config.h"
#include "network.h"
#include "simulation.h"
#include "display.h"
void millisleep(int millis)
{
#ifndef _WIN32
struct timespec ts;
ts.tv_sec = millis / 1000;
ts.tv_nsec = (millis % 1000) * 1000000;
nanosleep(&ts, NULL);
#else
Sleep(millis);
#endif
}
int main(int argc, char** argv)
{
int i = 0;
srand(time(0));
config(&argc, argv);
initNetwork();
initSimulation();
initDisplay(&argc, argv);
for(;;)
{
stepNetwork();
stepSimulation();
if(conf.fastmode)
{
i++;
i %= 100;
if(i != 0) continue;
}
stepDisplay();
if(conf.throttle > 0)
{
millisleep(conf.throttle);
}
};
return 0;
}