Commit b4bc132a authored by Frederik Schwarzer's avatar Frederik Schwarzer

rand() -> qrand()

parent acbd1995
......@@ -81,9 +81,9 @@ usi AiBoard::height() const {
Coord AiBoard::move() {
if (m_cleanBoard) {
srand(static_cast<int>(time(0)));
usi randX = rand()%(m_dimension->width()/3) + m_dimension->width()/3;
usi randY = rand()%(m_dimension->height()/3) + m_dimension->height()/3;
qsrand(static_cast<int>(time(0)));
usi randX = qrand()%(m_dimension->width()/3) + m_dimension->width()/3;
usi randY = qrand()%(m_dimension->height()/3) + m_dimension->height()/3;
return Coord(randX, randY);
}
for (usi x = 0; x < m_dimension->width(); ++x) {
......
......@@ -45,7 +45,7 @@ AiImpl::AiImpl() : table_size_x(20), table_size_y(20),
{
if (!rand_inited) {
rand_inited = true;
srand((unsigned int) time(NULL));
qsrand((unsigned int) time(NULL));
}
memset(hashData, 0, sizeof(hashData));
}
......@@ -253,15 +253,15 @@ Field AiImpl::openingBook() {
pos_T x, y;
x = table_size_x / 2;
y = table_size_y / 2;
x += rand() % 5 - 2;
y += rand() % 5 - 2;
x += qrand() % 5 - 2;
y += qrand() % 5 - 2;
while (rememberedStanding.table[x][y]) x++;
return Field(x, y);
} else if (rememberedStanding.stepCount == 1) {
pos_T x, y;
x = rememberedStanding.lastx;
y = rememberedStanding.lasty;
int r = rand() % 100;
int r = qrand() % 100;
if (r >= 20) {
if (x < table_size_x / 2) {
x++;
......@@ -291,19 +291,19 @@ Field AiImpl::openingBook() {
dy = (int) y1 - (int) y2;
if (-1 <= dx && dx <= 1 && -1 <= dy && dy <= 1) {
if (dx == 0) {
return Field((int) x1 + (rand() % 2) * 2 - 1, (int) y1 + rand() % 3 - 1);
return Field((int) x1 + (qrand() % 2) * 2 - 1, (int) y1 + qrand() % 3 - 1);
}
if (dy == 0) {
return Field((int) x1 + rand() % 3 - 1, (int) y1 + (rand() % 2) * 2 - 1);
return Field((int) x1 + qrand() % 3 - 1, (int) y1 + (qrand() % 2) * 2 - 1);
}
if (rand() % 2) {
if (rand() % 2) {
if (qrand() % 2) {
if (qrand() % 2) {
return Field((int) x1 + dx, y1);
} else {
return Field(x1, (int) y1 + dy);
}
} else {
if (rand() % 2) {
if (qrand() % 2) {
return Field((int) x1 - dx, (int) y1 + dy);
} else {
return Field((int) x1 + dx, (int) y1 - dy);
......
......@@ -225,7 +225,7 @@ void Standing::evaluate() {
countMatches();
decide();
if (current) hval *= -1;
int current_seed = rand() % (2 * (int) heur_seed + 1) - (int) heur_seed;
int current_seed = qrand() % (2 * (int) heur_seed + 1) - (int) heur_seed;
int hval_int = (int) hval + current_seed;
hval = hval_int > MaxHeur ? MaxHeur : hval_int < MinHeur ? MinHeur : hval_int;
}
......
......@@ -240,12 +240,12 @@ void testSetNonvalidPlayer() {
void testEcho() {
board b = board(dim(20, 20));
unsigned short int player = 1;
srand((unsigned)time(0));
qsrand((unsigned)time(0));
try {
while (true) {
coord c(0,0);
while (true) {
c = coord(rand()%20, rand()%20);
c = coord(qrand()%20, qrand()%20);
if (b.empty(c)) break;
}
b.setPlayer(c, player);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment