From 27b6c65ff52558fa121bd2bb7824109bfa194a54 Mon Sep 17 00:00:00 2001 From: TripleWhy Date: Sun, 11 May 2014 03:16:39 +0200 Subject: [PATCH] Cp is now adjustable --- Carcasum/gui/playerselector.cpp | 17 +++++++++-------- Carcasum/gui/playerselector.ui | 6 ++++++ Carcasum/player/mctsplayer.h | 7 +++---- Carcasum/player/mctsplayer.tpp | 5 +++-- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Carcasum/gui/playerselector.cpp b/Carcasum/gui/playerselector.cpp index fc1db9f..b05ce65 100644 --- a/Carcasum/gui/playerselector.cpp +++ b/Carcasum/gui/playerselector.cpp @@ -38,6 +38,7 @@ Player *PlayerSelector::createPlayer() PlayoutType playout = playoutData[ui->playoutBox->currentIndex()].type; bool useTimeout = ui->timeLimitRB->isChecked(); int limit = ui->limitSpinBox->value(); + double Cp = ui->CpSpinBox->value(); switch (player) { @@ -193,9 +194,9 @@ Player *PlayerSelector::createPlayer() switch (playout) { case PlayoutTypeRandom: - return new MCTSPlayer(tileFactory, limit, useTimeout); + return new MCTSPlayer(tileFactory, limit, useTimeout, Cp); case PlayoutTypeEarlyCutoff: - return new MCTSPlayer>(tileFactory, limit, useTimeout); + return new MCTSPlayer>(tileFactory, limit, useTimeout, Cp); } } case UtilityTypeHeyden: @@ -203,9 +204,9 @@ Player *PlayerSelector::createPlayer() switch (playout) { case PlayoutTypeRandom: - return new MCTSPlayer(tileFactory, limit, useTimeout); + return new MCTSPlayer(tileFactory, limit, useTimeout, Cp); case PlayoutTypeEarlyCutoff: - return new MCTSPlayer>(tileFactory, limit, useTimeout); + return new MCTSPlayer>(tileFactory, limit, useTimeout, Cp); } } case UtilityTypeComplex: @@ -213,9 +214,9 @@ Player *PlayerSelector::createPlayer() switch (playout) { case PlayoutTypeRandom: - return new MCTSPlayer(tileFactory, limit, useTimeout); + return new MCTSPlayer(tileFactory, limit, useTimeout, Cp); case PlayoutTypeEarlyCutoff: - return new MCTSPlayer>(tileFactory, limit, useTimeout); + return new MCTSPlayer>(tileFactory, limit, useTimeout, Cp); } } case UtilityTypeComplexNormalized: @@ -223,9 +224,9 @@ Player *PlayerSelector::createPlayer() switch (playout) { case PlayoutTypeRandom: - return new MCTSPlayer(tileFactory, limit, useTimeout); + return new MCTSPlayer(tileFactory, limit, useTimeout, Cp); case PlayoutTypeEarlyCutoff: - return new MCTSPlayer>(tileFactory, limit, useTimeout); + return new MCTSPlayer>(tileFactory, limit, useTimeout, Cp); } } } diff --git a/Carcasum/gui/playerselector.ui b/Carcasum/gui/playerselector.ui index a527eda..366810d 100644 --- a/Carcasum/gui/playerselector.ui +++ b/Carcasum/gui/playerselector.ui @@ -90,9 +90,15 @@ + + 4 + 10.000000000000000 + + 0.010000000000000 + 1.000000000000000 diff --git a/Carcasum/player/mctsplayer.h b/Carcasum/player/mctsplayer.h index 142b61c..bd0ab0b 100644 --- a/Carcasum/player/mctsplayer.h +++ b/Carcasum/player/mctsplayer.h @@ -12,8 +12,6 @@ template class MCTSPlayer : public Player { - constexpr static qreal Cp = 1; - typedef typename UtilityProvider::RewardType RewardType; typedef typename UtilityProvider::RewardListType RewardListType; @@ -104,6 +102,7 @@ class MCTSPlayer : public Player UtilityProvider utilityProvider = UtilityProvider(); const int M; const bool useTimeout; + const qreal Cp; #if MCTS_COUNT_EXPAND_HITS @@ -114,9 +113,9 @@ class MCTSPlayer : public Player public: #ifdef TIMEOUT - constexpr MCTSPlayer(jcz::TileFactory * tileFactory, int m = TIMEOUT, bool mIsTimeout = true); + constexpr MCTSPlayer(jcz::TileFactory * tileFactory, int const m = TIMEOUT, bool const mIsTimeout = true, qreal const Cp = 1.0); #else - constexpr MCTSPlayer(jcz::TileFactory * tileFactory, int m = 5000, bool mIsTimeout = true); + constexpr MCTSPlayer(jcz::TileFactory * tileFactory, int const m = 5000, bool const mIsTimeout = true, qreal const Cp = 1.0); #endif void applyChance(int action, Game & g); diff --git a/Carcasum/player/mctsplayer.tpp b/Carcasum/player/mctsplayer.tpp index 4727249..113309d 100644 --- a/Carcasum/player/mctsplayer.tpp +++ b/Carcasum/player/mctsplayer.tpp @@ -49,11 +49,12 @@ MCTSPlayer MCTS_TU::MCTSChanceNode::MCTSChanceNode(uchar player, TileCountType c MCTS_T -constexpr MCTSPlayer MCTS_TU::MCTSPlayer(jcz::TileFactory * tileFactory, int m, bool mIsTimeout) +constexpr MCTSPlayer MCTS_TU::MCTSPlayer(jcz::TileFactory * tileFactory, const int m, const bool mIsTimeout, qreal const Cp) : tileFactory(tileFactory), typeName(QString("MCTSPlayer<%1, %2>").arg(UtilityProvider::name).arg(Playout::name)), M(m), - useTimeout(mIsTimeout) + useTimeout(mIsTimeout), + Cp(Cp) { }