Ok, so the first step will be calculating the ICM equities, I have found the following code in the archive:
Code:
#include <iostream>
using namespace std;
double getEquity(int player, int depth, int payouts, int stacks, double total, double* p_payouts, double* p_stacks)
{
/*
func doing the recursive ICM calculation
*/
double eq = p_stacks[player]/total*p_payouts[depth];
if(payouts > depth+1)
{
for(int j=0;j < stacks; j++)
{
if(j != player && p_stacks[j] > 0)
{
double c = p_stacks[j];
p_stacks[j] = 0;
eq += getEquity(player, depth+1, payouts, stacks, total-c, p_payouts, p_stacks)*c/total;
p_stacks[j] = c;
}
}
}
return eq;
}
double getEquity(int player, int payouts, int stacks, double* p_payouts, double* p_stacks)
{
/*
player - player index
payouts - amount of
stacks - amount of
p_payouts - pointer containing adress of the payout structure
p_stacks - pointer containing adress of the stack size structure
*/
double total = 0;
for(int j=0;j<stacks;j++) total += p_stacks[j];
return getEquity(player, 0, payouts, stacks, total, p_payouts, p_stacks);
}
int main()
{
//-----------------------------------------------------------------------------------------------------
// Test Examples
//-----------------------------------------------------------------------------------------------------
int payouts = 3, stacks = 6;
double p_stacks[6] = {5500, 3500, 3000, 1500, 1000, 500};
double p_payoutsSNG[3] = {0.5,0.3,0.2};
double p_payoutsDON[3] = {0.33,0.33,0.33};
double p_payouts1st[3] = {1,0,0};
//SNG structure
cout << "SNG Equities" << endl;
for(int j=0;j<stacks;j++)
{
cout << "Equity stack " << j << ": " << getEquity(j, payouts, stacks, p_payoutsSNG, p_stacks) << endl;
}
//DON structure
cout << "DON Equities" << endl;
for(int j=0;j<stacks;j++)
{
cout << "Equity stack " << j << ": " << getEquity(j, payouts, stacks, p_payoutsDON, p_stacks) << endl;
}
//Winner gets all structure
cout << "Winner gets all Equities" << endl;
for(int j=0;j<stacks;j++)
{
cout << "Equity stack " << j << ": " << getEquity(j, payouts, stacks, p_payouts1st, p_stacks) << endl;
}
system("PAUSE");
return 0;
}
It gives me the same results as Pio, so it's most likely correct.
My plan is to first compute how stacks change at each terminal node and then to compute the new ICM values for those terminal nodes. The difference in ICM values between the starting stacks and the stacks at the terminal node will then be the value of that terminal node for each player.
I have also read that there are ways to approximate the ICM values, does anyone know anything about that? I will first test it with this code, but an approximation might come in handy if the code isn't fast enough.