Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
* master:
  Cp is now adjustable
  • Loading branch information
TripleWhy committed May 11, 2014
2 parents f4ad2c1 + 27b6c65 commit c95ae63
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
17 changes: 9 additions & 8 deletions Carcasum/gui/playerselector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -193,39 +194,39 @@ Player *PlayerSelector::createPlayer()
switch (playout)
{
case PlayoutTypeRandom:
return new MCTSPlayer<Utilities::SimpleUtility, Playouts::RandomPlayout>(tileFactory, limit, useTimeout);
return new MCTSPlayer<Utilities::SimpleUtility, Playouts::RandomPlayout>(tileFactory, limit, useTimeout, Cp);
case PlayoutTypeEarlyCutoff:
return new MCTSPlayer<Utilities::SimpleUtility, Playouts::EarlyCutoff<>>(tileFactory, limit, useTimeout);
return new MCTSPlayer<Utilities::SimpleUtility, Playouts::EarlyCutoff<>>(tileFactory, limit, useTimeout, Cp);
}
}
case UtilityTypeHeyden:
{
switch (playout)
{
case PlayoutTypeRandom:
return new MCTSPlayer<Utilities::HeydensUtility, Playouts::RandomPlayout>(tileFactory, limit, useTimeout);
return new MCTSPlayer<Utilities::HeydensUtility, Playouts::RandomPlayout>(tileFactory, limit, useTimeout, Cp);
case PlayoutTypeEarlyCutoff:
return new MCTSPlayer<Utilities::HeydensUtilityEC, Playouts::EarlyCutoff<>>(tileFactory, limit, useTimeout);
return new MCTSPlayer<Utilities::HeydensUtilityEC, Playouts::EarlyCutoff<>>(tileFactory, limit, useTimeout, Cp);
}
}
case UtilityTypeComplex:
{
switch (playout)
{
case PlayoutTypeRandom:
return new MCTSPlayer<Utilities::ComplexUtility, Playouts::RandomPlayout>(tileFactory, limit, useTimeout);
return new MCTSPlayer<Utilities::ComplexUtility, Playouts::RandomPlayout>(tileFactory, limit, useTimeout, Cp);
case PlayoutTypeEarlyCutoff:
return new MCTSPlayer<Utilities::ComplexUtilityEC, Playouts::EarlyCutoff<>>(tileFactory, limit, useTimeout);
return new MCTSPlayer<Utilities::ComplexUtilityEC, Playouts::EarlyCutoff<>>(tileFactory, limit, useTimeout, Cp);
}
}
case UtilityTypeComplexNormalized:
{
switch (playout)
{
case PlayoutTypeRandom:
return new MCTSPlayer<Utilities::ComplexUtilityNormalized, Playouts::RandomPlayout>(tileFactory, limit, useTimeout);
return new MCTSPlayer<Utilities::ComplexUtilityNormalized, Playouts::RandomPlayout>(tileFactory, limit, useTimeout, Cp);
case PlayoutTypeEarlyCutoff:
return new MCTSPlayer<Utilities::ComplexUtilityNormalizedEC, Playouts::EarlyCutoff<>>(tileFactory, limit, useTimeout);
return new MCTSPlayer<Utilities::ComplexUtilityNormalizedEC, Playouts::EarlyCutoff<>>(tileFactory, limit, useTimeout, Cp);
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions Carcasum/gui/playerselector.ui
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,15 @@
</item>
<item>
<widget class="QDoubleSpinBox" name="CpSpinBox">
<property name="decimals">
<number>4</number>
</property>
<property name="maximum">
<double>10.000000000000000</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
Expand Down
7 changes: 3 additions & 4 deletions Carcasum/player/mctsplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
template<class UtilityProvider = Utilities::ComplexUtilityNormalized, class Playout = Playouts::RandomPlayout>
class MCTSPlayer : public Player
{
constexpr static qreal Cp = 1;

typedef typename UtilityProvider::RewardType RewardType;
typedef typename UtilityProvider::RewardListType RewardListType;

Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions Carcasum/player/mctsplayer.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down

0 comments on commit c95ae63

Please sign in to comment.