Skip to content

Instantly share code, notes, and snippets.

@lironsade
Created March 30, 2019 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lironsade/a5a2db05d48ef78fee0a98f4a84e09d5 to your computer and use it in GitHub Desktop.
Save lironsade/a5a2db05d48ef78fee0a98f4a84e09d5 to your computer and use it in GitHub Desktop.
from multiprocessing.dummy import Pool
from subprocess import check_output
NUMBER_OF_PROCESSES = 4
to_run = [
'-p tiny_set.txt -s 4 7 -z fill',
'-p tiny_set.txt -f bfs -s 4 7 -z fill',
'-p tiny_set_2.txt -f bfs -s 6 6 -z corners',
'-p tiny_set_2.txt -f ucs -s 6 6 -z corners',
'-p small_set.txt -f ucs -s 5 5 -z corners',
'-p tiny_set_2.txt -f astar -s 6 6 -z corners -H null_heuristic',
'-p tiny_set_2.txt -f astar -s 8 8 -z corners -H blokus_corners_heuristic',
'-p small_set.txt -f astar -s 6 6 -H null_heuristic -z cover -x 3 3 [(2,2),(5,5),(1,4)]',
'-p small_set.txt -f astar -s 10 10 -H blokus_cover_heuristic -z cover -x 3 3 [(2,2),(5,5),(6,7)]',
'-p valid_pieces.txt -s 10 10 -z sub-optimal -x 7 7 [(5,5),(8,8),(4,9)]',
'-p valid_pieces.txt -s 10 10 -z sub-optimal -x 5 5 [(3,4),(6,6),(7,5)]'
]
def run(command):
try:
header = ('\n' + command + '\n----------------------\n').encode('utf-8')
print(command.split())
return header + check_output(["python3", 'game.py'] + command.split()), None
except Exception as e:
return None, e
if __name__ == "__main__":
p = Pool(NUMBER_OF_PROCESSES)
with open("results.txt", "wb") as logfile:
for output, error in p.imap(run, to_run): # provide filenames
if error is None:
logfile.write(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment