Port away from deprecated KRandomSequence

GIT_SILENT
parent a69e1e09
......@@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(kreversi)
set (QT_MIN_VERSION "5.7.0")
set (KF5_MIN_VERSION "5.30.0")
set (QT_MIN_VERSION "5.10.0")
set (KF5_MIN_VERSION "5.55.0")
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
......
......@@ -265,9 +265,10 @@ static const int BC_WEIGHT = 3;
Engine::Engine(int st, int sd)/* : SuperEngine(st, sd) */
: m_strength(st), m_computingMove(false)
: m_strength(st)
, m_random(sd)
, m_computingMove(false)
{
m_random.setSeed(sd);
m_score = new Score;
m_bc_score = new Score;
SetupBcBoard();
......@@ -276,9 +277,10 @@ Engine::Engine(int st, int sd)/* : SuperEngine(st, sd) */
Engine::Engine(int st) //: SuperEngine(st)
: m_strength(st), m_computingMove(false)
: m_strength(st)
, m_random(QRandomGenerator::global()->generate())
, m_computingMove(false)
{
m_random.setSeed(0);
m_score = new Score;
m_bc_score = new Score;
SetupBcBoard();
......@@ -287,9 +289,10 @@ Engine::Engine(int st) //: SuperEngine(st)
Engine::Engine()// : SuperEngine(1)
: m_strength(1), m_computingMove(false)
: m_strength(1)
, m_random(QRandomGenerator::global()->generate())
, m_computingMove(false)
{
m_random.setSeed(0);
m_score = new Score;
m_bc_score = new Score;
SetupBcBoard();
......@@ -441,7 +444,7 @@ KReversiMove Engine::computeMove(const KReversiGame& game, bool competitive)
// and not always lose. However, we only do this if the
// user wants a casual game, which is set in the settings
// dialog.
int randi = m_random.getLong(7);
int randi = m_random.bounded(7);
if (maxval == -LARGEINT
|| m_competitive
|| randi < (int) m_strength) {
......@@ -465,7 +468,7 @@ KReversiMove Engine::computeMove(const KReversiGame& game, bool competitive)
// If there are more than one best move, the pick one randomly.
if (number_of_maxval > 1) {
int r = m_random.getLong(number_of_maxval) + 1;
int r = m_random.bounded(number_of_maxval) + 1;
int i;
for (i = 0; i < number_of_moves; ++i) {
......@@ -496,7 +499,7 @@ KReversiMove Engine::ComputeFirstMove(const KReversiGame& game)
int r;
ChipColor color = game.currentPlayer();
r = m_random.getLong(4) + 1;
r = m_random.bounded(4) + 1;
if (color == White) {
if (r == 1) return KReversiMove(color, 4, 2);
......
......@@ -119,7 +119,7 @@
#ifndef KREVERSI_ENGINE_H
#define KREVERSI_ENGINE_H
#include <KRandomSequence>
#include <QRandomGenerator>
#include "commondefs.h"
#include "kreversigame.h"
......@@ -239,7 +239,7 @@ private:
bool m_competitive;
uint m_strength;
KRandomSequence m_random;
QRandomGenerator m_random;
bool m_interrupt;
quint64 m_coord_bit[9][9];
......
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