Esempio n. 1
0
def test_serialise_game_tree(tc):
    serialised = ("(;AB[aa][ab][ac]C[comment \xa3];W[ab];C[];C[]"
                  "(;B[bc])(;B[bd];W[ca](;B[da])(;B[db];\n"
                  "W[ea])))\n")
    coarse_game = sgf_grammar.parse_sgf_game(serialised)
    tc.assertEqual(sgf_grammar.serialise_game_tree(coarse_game), serialised)
    tc.assertEqual(sgf_grammar.serialise_game_tree(coarse_game, wrap=None),
                   serialised.replace("\n", "") + "\n")
Esempio n. 2
0
def test_serialise_game_tree(tc):
    serialised = ("(;AB[aa][ab][ac]C[comment \xa3];W[ab];C[];C[]"
                  "(;B[bc])(;B[bd];W[ca](;B[da])(;B[db];\n"
                  "W[ea])))\n")
    coarse_game = sgf_grammar.parse_sgf_game(serialised)
    tc.assertEqual(sgf_grammar.serialise_game_tree(coarse_game), serialised)
    tc.assertEqual(sgf_grammar.serialise_game_tree(coarse_game, wrap=None),
                   serialised.replace("\n", "")+"\n")
Esempio n. 3
0
    def from_string(cls, s, override_encoding=None):
        """Alternative constructor: read a single Sgf_game from a string.

        s -- 8-bit string

        Raises ValueError if it can't parse the string. See parse_sgf_game()
        for details.

        See from_coarse_game_tree for details of size and encoding handling.

        """
        coarse_game = sgf_grammar.parse_sgf_game(s)
        return cls.from_coarse_game_tree(coarse_game, override_encoding)