[gnome-sudoku] qqwing-wrapper: seed RNG
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sudoku] qqwing-wrapper: seed RNG
- Date: Tue, 12 Jul 2016 04:06:25 +0000 (UTC)
commit 7d404bebb77ae63eb901cc6f2c0131eec84570d0
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Mon Jul 11 22:55:42 2016 -0500
qqwing-wrapper: seed RNG
So we don't repeat same puzzles each time Sudoku is started.
Credit to Yuri Khan for discovering and debugging this issue (and for
submitting a different fix).
https://bugzilla.gnome.org/show_bug.cgi?id=768345
lib/qqwing-wrapper.cpp | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/lib/qqwing-wrapper.cpp b/lib/qqwing-wrapper.cpp
index 3c06312..f659732 100644
--- a/lib/qqwing-wrapper.cpp
+++ b/lib/qqwing-wrapper.cpp
@@ -22,7 +22,9 @@
#include "qqwing-wrapper.h"
#include <algorithm>
+#include <cstdlib>
#include <iostream>
+#include <mutex>
#include <glib.h>
#include <qqwing.hpp>
@@ -37,6 +39,11 @@ int* qqwing_generate_puzzle(int difficulty)
const int MAX_ITERATIONS = 1000;
const int BOARD_SIZE = 81;
qqwing::SudokuBoard board;
+ std::once_flag flag;
+
+ std::call_once(flag, [] {
+ srand(time(nullptr));
+ });
board.setRecordHistory(true);
board.setLogHistory(false);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]