Fixing sprites

This commit is contained in:
vladislav.khorev committed 2018-09-23 11:35:20 +05:00
1 parent ef0392fb63
commit b4e5d2a104
6 files changed
+20 -13

No files matched your search

Regular → Executable
+6 -3
View File
@@ -1,9 +1,12 @@
#include "weighted_set.h"
#include <cassert>
#include <ctime>
namespace Math {
WeightedSet::WeightedSet(unsigned int seed) :
elements(),
rng(seed) {
elements()
{
std::srand(unsigned(std::time(0)));
}
void WeightedSet::add(unsigned int w, unsigned int e) {
@@ -15,7 +18,7 @@ namespace Math {
unsigned int WeightedSet::getRandom() {
//unsigned int rnd = (int) (totalWeight * (rand() / (RAND_MAX + 1.0)));
unsigned int rnd = rng.nextUint(elements.size());
unsigned int rnd = std::rand() % (elements.size());
return elements[rnd];
}
}
Regular → Executable
-2
View File
@@ -2,7 +2,6 @@
#define WEIGHTED_SET_H
#include <vector>
#include "yasli/random.h"
namespace Math {
@@ -13,7 +12,6 @@ namespace Math {
unsigned int getRandom();
private:
std::vector<unsigned int> elements;
Random rng;
};
}