This is my tree:
Its not pretty, I programmed a treeDrawer quickly, but maybe you will see an error there. I stored the amount a player can win in the terminal nodes, not the overal potsize. I guess this should be ok, but I have been looking for a bug for hours, so I am not sure about anything anymore
Some code:
Code:
public class FoldNode extends Node {
@Override
public double[] trainVanilla(int trainPlayer, double[] p, double[] op) {
double pValue = trainPlayer == 0 ? payOff : -payOff;
double[] ev = new double[p.length];
for (int i = 0; i < p.length; i++) {
double sum = 0;
for (int j = 0; j < op.length; j++) {
if (!(Game.get(trainPlayer).get(i).overlaps(Game.get(trainPlayer^1).get(j))))
sum += op[j];
}
ev[i] = sum * pValue;
if(!(player==trainPlayer)){
ev[i] = ev[i] + sum * Game.pot;
}
}
return ev;
}
Code:
public class ShowdownNode extends Node{
public double[] trainVanilla(int trainPlayer, double[] p, double[] op) {
double[] ev = new double[p.length];
for (int i = 0; i < p.length; i++)
{
double sum = 0;
double sum2 = 0;
for (int j = 0; j < op.length; j++)
{
if (!(Game.get(trainPlayer).get(i).overlaps(Game.get(trainPlayer^1).get(j))))
{
if (Game.get(trainPlayer).get(i).getRank()
> Game.get(trainPlayer^1).get(j).getRank()){
sum += op[j];
sum2 += op[j];
}
else if (Game.get(trainPlayer).get(i).getRank()
< Game.get(trainPlayer^1).get(j).getRank()){
sum -= op[j];
}
else{
sum2 += 0.5*op[j];
}
}
}
ev[i] = sum * payOff + sum2*Game.pot;
}
return ev;
}
}
Code:
public class DecisionNode extends Node {
@Override
public double[] trainVanilla(int trainPlayer, double[] p, double[] op) {
double[][] s = new double[Game.get(player).getSize()][];
for (int i = 0; i < Game.get(player).getSize(); i++)
s[i] = getStrategy(i);
if (player == trainPlayer)
{
for (int i = 0; i < p.length; i++)
{
for (int j = 0; j < children.length; j++)
cumulativeStrategy[i][j] += p[i] * s[i][j];
}
double[][] u = new double[children.length][];
double[] ev = new double[p.length];
for (int j = 0; j < children.length; j++)
{
double[] newp = new double[p.length];
for (int i = 0; i < p.length; i++)
newp[i] = s[i][j] * p[i];
u[j] = children[j].trainVanilla(trainPlayer, newp, op);
for (int i = 0; i < p.length; i++)
ev[i] += u[j][i] * s[i][j];
}
for (int i = 0; i < p.length; i++)
{
for (int j = 0; j < children.length; j++){
regret[i][j] += u[j][i] - ev[i];
}
}
return ev;
}
else
{
double[] ev = new double[p.length];
for (int j = 0; j < children.length; j++)
{
double[] newop = new double[op.length];
for (int i = 0; i < op.length; i++)
newop[i] = s[i][j] * op[i];
double[] u = children[j].trainVanilla(trainPlayer, p, newop);
for (int i = 0; i < p.length; i++)
ev[i] += u[i];
}
return ev;
}
}
}
It all worked fine for Kuhn with each player posting an ante and an initial potsize of 0. It doesnt work for trees, that allow raises or for Kuhn with an initial potsize.
This is the result for Check=>Bet=>Raise on an AKQ98 board for instance.
As you can see, AA calls with a probability of 90%, which of course doesn't make sense with the nuts. If you need some other informations about my code, or results I am getting, just let me know.Statistics: Posted by HontoNiBaka — Wed May 08, 2013 3:36 am
]]>