Revision: 7a42aea5a8
Author: thijs
Date: Wed Nov 17 06:48:20 2010
Log: Constant now adapted to the range of the profit/loss
http://code.google.com/p/opentestbed/source/detail?r=7a42aea5a8
Revision: 3a1aed6d66
Author: thijs
Date: Tue Nov 23 03:03:57 2010
Log: added Weighted UCT Selector based on the range of profit and loss
http://code.google.com/p/opentestbed/source/detail?r=3a1aed6d66
Revision: add6a25e56
Author: thijs
Date: Tue Nov 23 03:05:26 2010
Log: reverted to original
http://code.google.com/p/opentestbed/source/detail?r=add6a25e56
Revision: a37eec0ff0
Author: thijs
Date: Tue Nov 23 03:07:06 2010
Log: Merge with abc30a54f898ad1b6b7f64486d89d6ba68ecd5a3
http://code.google.com/p/opentestbed/source/detail?r=a37eec0ff0
==============================================================================
Revision: 7a42aea5a8
Author: thijs
Date: Wed Nov 17 06:48:20 2010
Log: Constant now adapted to the range of the profit/loss
http://code.google.com/p/opentestbed/source/detail?r=7a42aea5a8
Modified:
/src/bots/mctsbot/ai/bots/bot/gametree/mcts/strategies/selection/UCTSelector.java
=======================================
---
/src/bots/mctsbot/ai/bots/bot/gametree/mcts/strategies/selection/UCTSelector.java
Sat Apr 24 00:33:47 2010
+++
/src/bots/mctsbot/ai/bots/bot/gametree/mcts/strategies/selection/UCTSelector.java
Wed Nov 17 06:48:20 2010
@@ -16,6 +16,9 @@
package bots.mctsbot.ai.bots.bot.gametree.mcts.strategies.selection;
import bots.mctsbot.ai.bots.bot.gametree.mcts.nodes.INode;
+import bots.mctsbot.client.common.gamestate.GameState;
+import bots.mctsbot.client.common.playerstate.PlayerState;
+import bots.mctsbot.common.elements.player.PlayerId;
public class UCTSelector extends MaxFunctionSelector {
@@ -24,13 +27,41 @@
public UCTSelector(double C) {
this.C = C;
}
-
+
@Override
protected double evaluate(INode node) {
int nbSamples = node.getNbSamples();
- if(nbSamples==0) return 0;
+ if (nbSamples == 0)
+ return 0;
int nbParentSamples = node.getParent().getNbSamples();
- return node.getEV()+C*Math.sqrt(Math.log(nbParentSamples)/nbSamples);
+ return node.getEV() + getC2(node) * Math.sqrt(Math.log(nbParentSamples)
/ nbSamples);
}
-}
+ // C2 = C * (maxProfit - maxLoss) maxLoss is negative
+ private double getC2(INode node) {
+ GameState gameState = node.getGameState();
+ PlayerId bot = node.getParent().bot;
+
+ //wrong assumption if bot is already all-in and doesn't match opponents
bets
+ int maxProfit = gameState.getGamePotSize();
+
+ int botStack = gameState.getPlayer(bot).getStack();
+
+ int maxOpponentStack = 0;
+
+ for (PlayerState playerState : gameState.getAllSeatedPlayers()) {
+ if (playerState.getPlayerId() != bot && !playerState.hasFolded()) {
+ int stack = playerState.getStack();
+ // from each player you can win nothing more than the minimum of his
stack and yours
+ maxProfit += Math.min(botStack, stack);
+
+ maxOpponentStack = Math.max(maxOpponentStack, stack);
+ }
+ }
+
+ int maxLoss = Math.min(botStack, maxOpponentStack);
+
+ //we add up because we took the maxLoss positive here
+ return C * (maxProfit + maxLoss);
+ }
+}
==============================================================================
Revision: 3a1aed6d66
Author: thijs
Date: Tue Nov 23 03:03:57 2010
Log: added Weighted UCT Selector based on the range of profit and loss
http://code.google.com/p/opentestbed/source/detail?r=3a1aed6d66
Added:
/src/bots/mctsbot/ai/bots/bot/gametree/mcts/strategies/selection/WeightedUCTSelector.java
=======================================
--- /dev/null
+++
/src/bots/mctsbot/ai/bots/bot/gametree/mcts/strategies/selection/WeightedUCTSelector.java
Tue Nov 23 03:03:57 2010
@@ -0,0 +1,67 @@
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.
+ */
+package bots.mctsbot.ai.bots.bot.gametree.mcts.strategies.selection;
+
+import bots.mctsbot.ai.bots.bot.gametree.mcts.nodes.INode;
+import bots.mctsbot.client.common.gamestate.GameState;
+import bots.mctsbot.client.common.playerstate.PlayerState;
+import bots.mctsbot.common.elements.player.PlayerId;
+
+public class WeightedUCTSelector extends MaxFunctionSelector {
+
+ private final double C;
+
+ public WeightedUCTSelector(double C) {
+ this.C = C;
+ }
+
+ @Override
+ protected double evaluate(INode node) {
+ int nbSamples = node.getNbSamples();
+ if (nbSamples == 0)
+ return 0;
+ int nbParentSamples = node.getParent().getNbSamples();
+ return node.getEV() + getC2(node) * Math.sqrt(Math.log(nbParentSamples)
/ nbSamples);
+ }
+
+ // C2 = C * (maxProfit - maxLoss) maxLoss is negative
+ private double getC2(INode node) {
+ GameState gameState = node.getGameState();
+ PlayerId bot = node.getParent().bot;
+
+ //wrong assumption if bot is already all-in and doesn't match opponents
bets
+ int maxProfit = gameState.getGamePotSize();
+
+ int botStack = gameState.getPlayer(bot).getStack();
+
+ int maxOpponentStack = 0;
+
+ for (PlayerState playerState : gameState.getAllSeatedPlayers()) {
+ if (playerState.getPlayerId() != bot && !playerState.hasFolded()) {
+ int stack = playerState.getStack();
+ // from each player you can win nothing more than the minimum of his
stack and yours
+ maxProfit += Math.min(botStack, stack);
+
+ maxOpponentStack = Math.max(maxOpponentStack, stack);
+ }
+ }
+
+ int maxLoss = Math.min(botStack, maxOpponentStack);
+
+ //we add up because we took the maxLoss positive here
+ return C * (maxProfit + maxLoss);
+ }
+}
==============================================================================
Revision: add6a25e56
Author: thijs
Date: Tue Nov 23 03:05:26 2010
Log: reverted to original
http://code.google.com/p/opentestbed/source/detail?r=add6a25e56
Modified:
/src/bots/mctsbot/ai/bots/bot/gametree/mcts/strategies/selection/UCTSelector.java
=======================================
---
/src/bots/mctsbot/ai/bots/bot/gametree/mcts/strategies/selection/UCTSelector.java
Wed Nov 17 06:48:20 2010
+++
/src/bots/mctsbot/ai/bots/bot/gametree/mcts/strategies/selection/UCTSelector.java
Tue Nov 23 03:05:26 2010
@@ -16,9 +16,6 @@
package bots.mctsbot.ai.bots.bot.gametree.mcts.strategies.selection;
import bots.mctsbot.ai.bots.bot.gametree.mcts.nodes.INode;
-import bots.mctsbot.client.common.gamestate.GameState;
-import bots.mctsbot.client.common.playerstate.PlayerState;
-import bots.mctsbot.common.elements.player.PlayerId;
public class UCTSelector extends MaxFunctionSelector {
@@ -34,34 +31,7 @@
if (nbSamples == 0)
return 0;
int nbParentSamples = node.getParent().getNbSamples();
- return node.getEV() + getC2(node) * Math.sqrt(Math.log(nbParentSamples)
/ nbSamples);
+ return node.getEV() + C * Math.sqrt(Math.log(nbParentSamples) /
nbSamples);
}
- // C2 = C * (maxProfit - maxLoss) maxLoss is negative
- private double getC2(INode node) {
- GameState gameState = node.getGameState();
- PlayerId bot = node.getParent().bot;
-
- //wrong assumption if bot is already all-in and doesn't match opponents
bets
- int maxProfit = gameState.getGamePotSize();
-
- int botStack = gameState.getPlayer(bot).getStack();
-
- int maxOpponentStack = 0;
-
- for (PlayerState playerState : gameState.getAllSeatedPlayers()) {
- if (playerState.getPlayerId() != bot && !playerState.hasFolded()) {
- int stack = playerState.getStack();
- // from each player you can win nothing more than the minimum of his
stack and yours
- maxProfit += Math.min(botStack, stack);
-
- maxOpponentStack = Math.max(maxOpponentStack, stack);
- }
- }
-
- int maxLoss = Math.min(botStack, maxOpponentStack);
-
- //we add up because we took the maxLoss positive here
- return C * (maxProfit + maxLoss);
- }
-}
+}
==============================================================================
Revision: a37eec0ff0
Author: thijs
Date: Tue Nov 23 03:07:06 2010
Log: Merge with abc30a54f898ad1b6b7f64486d89d6ba68ecd5a3
http://code.google.com/p/opentestbed/source/detail?r=a37eec0ff0
Modified:
/src/bots/mctsbot/ai/bots/bot/gametree/mcts/strategies/selection/UCTSelector.java