Ejemplo n.º 1
0
def test_gibo():
    file = os.path.join(os.path.dirname(__file__), "data/test.gib")
    root = SGF.parse_file(file)
    assert {
        "PW": ["wildsim1"],
        "WR": ["2D"],
        "PB": ["kim"],
        "BR": ["2D"],
        "RE": ["W+T"],
        "KM": [6.5],
        "DT": ["2020-06-14"],
    } == root.properties
    assert "pd" == root.children[0].get_property("B")
Ejemplo n.º 2
0
def test_ngf():
    file = os.path.join(os.path.dirname(__file__), "data/handicap2.ngf")
    root = SGF.parse_file(file)
    root.properties["AB"].sort()
    assert {
        "AB": ["dp", "pd"],
        "DT": ["2017-03-16"],
        "HA": [2],
        "PB": ["p81587"],
        "PW": ["ace550"],
        "RE": ["W+"],
        "SZ": [19],
    } == root.properties
    assert "pq" == root.children[0].get_property("W")
Ejemplo n.º 3
0
def test_pandanet():
    file = os.path.join(os.path.dirname(__file__), "data/panda1.sgf")
    root = SGF.parse_file(file)
    root_props = {
        "GM",
        "EV",
        "US",
        "CoPyright",
        "GN",
        "RE",
        "PW",
        "WR",
        "NW",
        "PB",
        "BR",
        "NB",
        "PC",
        "DT",
        "SZ",
        "TM",
        "KM",
        "LT",
        "RR",
        "HA",
        "AB",
        "C",
    }
    assert root_props == root.properties.keys()

    move = root
    while move.children:
        move = move.children[0]
    assert 94 == len(move.get_list_property("TW"))
    assert "Trilan" == move.get_property("OS")
    while move.parent:
        move = move.parent
    assert move is root
Ejemplo n.º 4
0
def test_ogs():
    file = os.path.join(os.path.dirname(__file__), "data/ogs.sgf")
    tree = SGF.parse_file(file)
Ejemplo n.º 5
0
def test_alphago():
    file = os.path.join(os.path.dirname(__file__),
                        "data/LS vs AG - G4 - English.sgf")
    SGF.parse_file(file)
Ejemplo n.º 6
0
def test_old_long_properties():
    file = os.path.join(os.path.dirname(__file__), "data/xmgt97.sgf")
    SGF.parse_file(file)
Ejemplo n.º 7
0
if len(sys.argv) > 1:
    mode = sys.argv[1]

size = defaultdict(int)
player = defaultdict(int)
handicap = defaultdict(int)
weird_games = []
dir = "sgf_ogs"
for root, dirs, files in os.walk(dir):
    for f in tqdm(files):
        try:
            filename = os.path.join(dir, f)
            if os.path.getmtime(filename) < time.time() - mode_window.get(
                    mode, 4e9):
                continue
            game_tree = SGF.parse_file(filename)
            nmv = len(game_tree.nodes_in_tree)
            if nmv > 10:
                size[game_tree.get_property("SZ")] += 1
                player[game_tree.get_property("PW", "").replace("+", ":")] += 1
                player[game_tree.get_property("PB", "").replace("+", ":")] += 1
                handicap[len(game_tree.get_property("AB", []))] += 1

            if ":" in game_tree.get_property("SZ") or int(
                    game_tree.get_property("SZ")) not in [9, 13, 19]:
                weird_games.append((game_tree.get_property("SZ"), nmv, f))
        except Exception as e:
            print(f"{f}: {e}")

for k, v in sorted(list(size.items()), key=lambda kv: -kv[1]):
    print(k, ":", v)