Skip to content

Instantly share code, notes, and snippets.

Last active October 21, 2016 07:56
What would you like to do?
Script to find the "densest" Pro Game
from multiprocessing.dummy import Pool
import os
import re
from subprocess import Popen, PIPE
from threading import RLock
DIR = 'go4go'
def parse(fn):
fh = open(fn, 'r')
data =
res ='RE\[[BW]\+R]', data)
count = len(re.findall(r';[BW]\[', data))
return bool(res), count
def gnugo(fn):
fh = Popen(["gnugo", "-l", fn, "--mode", "gtp"], stdout=PIPE, stdin=PIPE)
fh.stdin.write('final_status_list alive\n')
res =
return len(res.split()) - 1
highest = 0
lock = RLock()
def handle_file(fn):
global lock, highest
resigned, moves = parse(fn)
if resigned or moves < highest:
count = gnugo(fn)
with lock:
if count > highest:
print fn, count, "%.3f" % (count / 361.)
highest = count
[os.path.join(DIR, path) for path in os.listdir(DIR)],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment