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
MrNiceStatistics: Posted by MrNice — Mon Jan 27, 2014 12:22 pm
]]>