diff options
| author | Charlie Blake | 2018-09-28 08:04:37 +0100 |
|---|---|---|
| committer | GitHub | 2018-09-28 08:04:37 +0100 |
| commit | be3a5e2c2be51feceea87929e5233ec8f9d3739d (patch) | |
| tree | 9c29def64c404bcbd4e31d92253c291ed06ebe76 /canfield-check.py | |
| parent | Merge pull request #91 from thecharlesblake/fix-comma-bug-sol-percent (diff) | |
| parent | Canfield comparison with wolter (diff) | |
| download | metasol-be3a5e2c2be51feceea87929e5233ec8f9d3739d.tar.gz metasol-be3a5e2c2be51feceea87929e5233ec8f9d3739d.zip | |
Merge pull request #92 from thecharlesblake/canfield-comp
Canfield comparison with wolter
Diffstat (limited to 'canfield-check.py')
| -rw-r--r-- | canfield-check.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/canfield-check.py b/canfield-check.py new file mode 100644 index 0000000..2bfd974 --- /dev/null +++ b/canfield-check.py @@ -0,0 +1,40 @@ +import subprocess +import json +import re + +with open('sample100.txt', 'r') as myfile: + data = myfile.read() + +lines = data.splitlines() +deals = [] +for (i, line) in enumerate(lines): + # Get stuck starting positions + if line[:8] == "Canfield" and lines[i+12][:5] == "Stuck": + foundations = [] + reserve = [] + tableau = [] + stock = [] + for (j, line) in enumerate(lines[i+1:i+12]): + cards = line[6:].replace("T", "10") + + # Reserve + if j < 4 and cards != '': + foundations.append(cards) + elif j == 4: + reserve = list(filter(None, re.compile("\x1b\[[0-9]m ?").split(cards))) + elif j > 4 and j < 9: + tableau.append([cards]) + elif j == 9 or j == 10: + stock += cards.split(' ') + deals.append({ + "foundations": foundations, + "reserve": reserve, + "tableau piles": tableau, + "stock": stock + }) + +for (i, deal) in enumerate(deals): + print(json.dumps(deal), file=open("tmp.json", "wt")) + print("Attempting deal " + str(i)) + subprocess.run(["./cmake-build-release/bin/solvitaire", "--type", "canfield", "tmp.json", "--class", "--timeout", "600000"]) + |
