I don't want to reinvent the wheel, so I am reaching out for some feedback on this question. I find the text-based interface to Eric Farmer's BJ combinatorial analysis program a bit difficult to work with when automating batch analysis. The current interface is totally dependent on the order of the input tokens. For example, an input file to specify a partially depleted 6-deck shoe and some rules would look like this:
Code:
0
24 23 24 23 24 24 22 24 24 93
y
y
y
n
y
y
n
n
n
n
1.5
prob.txt
1 2 5 6
0 0
This file is hard to understand or edit. This interface only really works for small batches or when the input is created by a separate software program in a master/slave relationship. For example, a GUI could create text output delegate tasks to strategy.exe and present the results from stdout.
Has anyone provided a open-source GUI or JSON interface to make it easier to communicate with the input and output of the strategy.exe process? I modified the interface to parse JSON so I could use input files like this:
Code:
{ "bjPayoff": 1.5,
"double9": true,
"doubleAfterHit": false,
"doubleAfterSplit": true,
"doubleAnyTotal": true,
"doubleSoft": true,
"hitSoft17": false,
"lateSurrender": false,
"noSplits": false,
"numDecks": 8,
"outFileName": "out.txt",
"resplitAces": false,
"resplitOther": true,
"useCDP1": true,
"useCDZ": true
}
Not that the order of the parameters is no longer important, and humans should have fewer problems editing the file to change the analysis parameters.
I used the nlohmann::json library which is rather simple to incorporate into a C++ program. Here is some example code:
Code:
#include <iostream>#include <fstream>
#include <nlohmann/json.hpp>
#include <string>
#include <vector>
using json = nlohmann::json;
using namespace std;
int main() {
int numDecks = 6;
bool hitSoft17 = true;
bool doubleAnyTotal = true;
bool double9 = true;
bool doubleSoft = true;
bool doubleAfterHit = false;
bool doubleAfterSplit = true;
bool resplitAces = false;
bool resplitOther = true;
bool useCDZ = true;
bool useCDP1 = true;
bool lateSurrender = false;
double bjPayoff = 1.5;
string outFileName = "chronoOut.txt";
json j;
j["numDecks"] = numDecks;
j["hitSoft17"] = hitSoft17;
j["doubleAnyTotal"] = doubleAnyTotal;
j["double9"] = double9;
j["doubleSoft"] = doubleSoft;
j["doubleAfterHit"] = doubleAfterHit;
j["doubleAfterSplit"] = doubleAfterSplit;
j["resplitAces"] = resplitAces;
j["resplitOther"] = resplitOther;
j["lateSurrender"] = lateSurrender;
j["useCDZ"] = useCDZ;
j["useCDP1"] = useCDP1;
j["bjPayoff"] = bjPayoff;
j["outFileName"] = outFileName;
ofstream ofs("write.json");
ofs << j.dump(4) << endl;
ifstream ifs("read.json");
json jObj = json::parse(ifs);
cout << jObj["numDecks"] << endl;
cout << jObj["hitSoft17"] << endl;
cout << jObj["outFileName"] << endl;
return 0;
}
Bookmarks