[ion] Init random seed with time in simulator main

This commit is contained in:
Émilie Feral
2020-04-14 12:27:21 +02:00
committed by Ecco
parent 870dd868e9
commit dcfabf754d
3 changed files with 26 additions and 1 deletions

View File

@@ -5,6 +5,7 @@
#include "layout.h"
#endif
#include "telemetry.h"
#include "random.h"
#include <assert.h>
#include <ion.h>
@@ -59,6 +60,8 @@ void init() {
return;
}
Random::init();
sWindow = SDL_CreateWindow(
"Epsilon",
SDL_WINDOWPOS_CENTERED,

View File

@@ -1,5 +1,11 @@
#include <ion.h>
#include "random.h"
#include <stdlib.h>
#include <time.h>
void Ion::Simulator::Random::init() {
// Set the seed for random using the current time
srand(time(NULL));
}
uint32_t Ion::random() {
/* rand() returns a pseudo-random integral number in the range between 0 and

View File

@@ -0,0 +1,16 @@
#ifndef ION_SIMULATOR_RANDOM_H
#define ION_SIMULATOR_RANDOM_H
#include <ion.h>
namespace Ion {
namespace Simulator {
namespace Random {
void init();
}
}
}
#endif