Poker-AI.org Poker AI and Botting Discussion Forum 2014-01-27T12:22:58+00:00 http://poker-ai.org/phpbb/feed.php?f=24&t=2682 2014-01-27T12:22:58+00:00 2014-01-27T12:22:58+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2682&p=5651#p5651 <![CDATA[Re: GameTreez]]>
As promised my code :

Code:

NodeArray = new Node[8801];

void initializeGameTree()
{
   NodeArray = new Node[8801];
}


void save_average_probability(char* filename)
{
   int maxbucket[4] = {8, 8, 8, 8};
   fstream f_bin(filename, ios::out|ios::binary);
   
   f_bin.seekg(ios::beg);
   
   for(int i=0; i<8801; i++)
   {
      f_bin.write((char*)NodeArray[i].average_probability, (getnumberofbuckets(NodeArray[i].Round, maxbucket, 2, 3))*sizeof(double));
      
   }
   
   f_bin.close();
}

void load_average_probability(char* filename)
{
   int maxbucket[4] = {8, 8, 8, 8};
   fstream f_bin(filename, ios::in|ios::binary);
   
   f_bin.seekg(ios::beg);
   
   for(int i=0; i<8801; i++)
   {
      NodeArray[i].regret = new double[getnumberofbuckets(NodeArray[i].Round, maxbucket, 2, 3)];
      NodeArray[i].average_probability = new double[getnumberofbuckets(NodeArray[i].Round, maxbucket, 2, 3)];
      f_bin.read((char*)NodeArray[i].average_probability, (getnumberofbuckets(NodeArray[i].Round, maxbucket, 2, 3))*sizeof(double));
   }
   
   f_bin.close();
}

void saveGameTreetoFile(char* filename)
{
   fstream f_bin(filename, ios::out|ios::binary);
   
   f_bin.seekg(ios::beg);
   
   f_bin.write((char*)NodeArray, 8801*sizeof(Node));
   
   f_bin.close();

}
void loadGameTreefromFile(char* filename)
{

   fstream f_bin(filename, ios::in|ios::binary);
   
   f_bin.seekg(ios::beg);
   
   f_bin.read((char*)NodeArray, 8801*sizeof(Node));
   
   f_bin.close();

}



Saving the tree :
Code:
//Create GameTree
//Compute regret and average probability
saveGameTreetoFile("FLNU_GameTree.bin");
save_average_probability("PR-8-8-8-8-750k_avgprob.bin");


Loading the tree :
Code:
initializeGameTree();
loadGameTreefromFile("FLNU_GameTree.bin");
load_average_probability("PR-8-8-8-8-750k_avgprob.bin");



Thanks for your help and advices ;)


MrNice

Statistics: Posted by MrNice — Mon Jan 27, 2014 12:22 pm


]]>
2014-01-17T19:34:50+00:00 2014-01-17T19:34:50+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2682&p=5605#p5605 <![CDATA[Re: GameTreez]]>

Thanks for your advices.


I will post my code shortly (I hope :D)

Regards,

Statistics: Posted by MrNice — Fri Jan 17, 2014 7:34 pm


]]>
2014-01-17T09:09:42+00:00 2014-01-17T09:09:42+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2682&p=5601#p5601 <![CDATA[Re: GameTreez]]> int noBuckets() // returns the length of regret
void save() // write noBuckets, regret and av_probability to a file, then invokes save() on each child node
void restore() // read noBuckets, regret and av_probability from file, then invokes restore() on each child node

// Assume tree is constructed before restore is invoked. Maybe restore can be put in constructor.

Statistics: Posted by spears — Fri Jan 17, 2014 9:09 am


]]>
2014-01-16T19:01:43+00:00 2014-01-16T19:01:43+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2682&p=5597#p5597 <![CDATA[Re: GameTreez]]> I'm mostly writing in plain C.
I am aware that I'm wasting a bit of memory by impossible nodes (each node will be a triple even if fold or raise is not possible) but memory is cheap, and with my current abstraction, the tables are only about 3GB each.
Since I have perfect recall of the actions, I don't need to store the pot, player etc..

#define MAX_FLOP_INDEX 1000
#define MAX_TURN_INDEX 1000
#define MAX_RIVER_INDEX 98
#define MAX_TURN_BOARDS 6
#define MAX_FLOP_BOARDS 18
#define MAX_PREFLOP_ACTION_NODES 8
#define MAX_ACTION_NODES 10
#define MAX_HISTORY_NODES 9
#define MAX_PREFLOP_HISTORY_NODES 7

typedef struct
{
double preflop[MAX_PREFLOP_INDEX][MAX_PREFLOP_ACTION_NODES][3];
double flop [MAX_FLOP_INDEX][MAX_FLOP_BOARDS][MAX_PREFLOP_HISTORY_NODES][MAX_ACTION_NODES][3];
double turn [MAX_TURN_INDEX][MAX_FLOP_BOARDS][MAX_TURN_BOARDS][MAX_PREFLOP_HISTORY_NODES][MAX_HISTORY_NODES][MAX_ACTION_NODES][3];
double river[MAX_RIVER_INDEX][MAX_FLOP_BOARDS][MAX_TURN_BOARDS][MAX_PREFLOP_HISTORY_NODES][MAX_HISTORY_NODES][MAX_HISTORY_NODES][MAX_ACTION_NODES][3];
}

Statistics: Posted by epo — Thu Jan 16, 2014 7:01 pm


]]>
2014-01-15T16:39:42+00:00 2014-01-15T16:39:42+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2682&p=5593#p5593 <![CDATA[GameTreez]]>
I'm finishing my AI for FLHUNE but i'm stucked at how to represent gametree and save it to binary... The problem is coming from the fact for each round the number of buckets for regret and average probability will be different specially in perfect recall... so I will have to store it in array of different size...

So for the moment I have a class Node :

Code:
class Node
{
   public:
      Node();
      int PreviousAction;
      int PreviousNode;
      int NextNodes[3];
      int Round;
      int Player;
      int Pot[2];
      
      double* regret;
      double* average_probability;

};


All nodes are stored in an array :

Code:
NodeArray = new Node[8801];


And based on the round I will create a dynamic array to store regret and average probability...

Till now that's fine but how will I save it ?

Are you working in a different way ?

any suggestion to my problem ?

Thanks for your help.

MrNice

Statistics: Posted by MrNice — Wed Jan 15, 2014 4:39 pm


]]>