aboutsummaryrefslogtreecommitdiff
path: root/solvitaire/archive/optimisation-test.py
diff options
context:
space:
mode:
authorTom Harley2019-01-29 19:12:22 +0000
committerTom Harley2019-01-29 19:12:22 +0000
commit7b4f42242d277adeaec7a40eaac7d178141d4621 (patch)
treeeacece268545df914d730ad80d6a1b69f1448296 /solvitaire/archive/optimisation-test.py
parentAdd support for reading gamestates from json files (diff)
downloadmetasol-7b4f42242d277adeaec7a40eaac7d178141d4621.tar.gz
metasol-7b4f42242d277adeaec7a40eaac7d178141d4621.zip

Reorganise submodules (and submodulise solvitaire)

The submodules should now point to repos I’ve made in order to produce static libraries from them. Also, solvitaire now points to a similar personal repo.

Diffstat (limited to 'solvitaire/archive/optimisation-test.py')
m---------solvitaire0
-rw-r--r--solvitaire/archive/optimisation-test.py75
2 files changed, 0 insertions, 75 deletions
diff --git a/solvitaire b/solvitaire
new file mode 160000
+Subproject b835e10bfb21a73b4f89e09ddeb400f41538483
diff --git a/solvitaire/archive/optimisation-test.py b/solvitaire/archive/optimisation-test.py
deleted file mode 100644
index 594b9eb..0000000
--- a/solvitaire/archive/optimisation-test.py
+++ /dev/null
@@ -1,75 +0,0 @@
-import sys
-from subprocess import run, CalledProcessError, DEVNULL, PIPE, Popen
-
-runCount = 100
-
-# Loops through each canonical solitaire
-
-for optimisation in [
- "-no-reduced-state",
- "-no-pile-symmetry",
- "-no-auto-foundations",
- "-no-symmetry"
-]:
-
- for preset in [
- "simple-alpha-star",
- "simple-bakers-dozen",
- "simple-black-hole",
- "simple-canfield",
- "simple-flower-garden",
- "simple-fortunes-favor",
- "simple-free-cell",
- "simple-somerset",
- "simple-spanish-patience"
- ]:
-
- differs = []
-
- for attempt in range(runCount):
- try:
- op_p = Popen("./cmake-build-release/bin/solvitaire" + optimisation
- + " --type " + preset + " --random " + str(attempt)
- + " --classify",
- shell=True,
- stdout=PIPE,
- stderr=DEVNULL)
- out_str = op_p.stdout.readline()
- if out_str == b'Solved\n':
- op_res = True
- elif out_str == b'No Possible Solution\n':
- op_res = False
- else:
- raise Exception('Invalid return value!')
-
- no_op_p = Popen("./cmake-build-release/bin/solvitaire"
- + " --type " + preset + " --random " + str(attempt)
- + " --classify",
- shell=True,
- stdout=PIPE,
- stderr=DEVNULL)
- out_str = no_op_p.stdout.readline()
- if out_str == b'Solved\n':
- no_op_res = True
- elif out_str == b'No Possible Solution\n':
- no_op_res = False
- else:
- raise Exception('Invalid return value!')
-
- if op_res != no_op_res:
- differs.append(attempt)
-
- except CalledProcessError:
- print("Error running " + preset + " with seed " + str(attempt) + "!")
- sys.exit()
- except Exception as e:
- print("Unknown error in script: ", e)
- sys.exit()
-
- run("pkill solvitaire", shell=True)
-
- if not differs :
- print(preset + ": No difference in solutions for " + optimisation)
- else :
- print(preset + ": Optimisation " + optimisation + " differs for the following seeds:")
- print(differs)