The gomill.ascii_boards module contains functions for producing and interpreting ASCII diagrams of Go board positions.
Return type: | string |
---|
Returns an ASCII diagram of the position on the Board board.
The returned string does not end with a newline.
>>> b = boards.Board(9)
>>> b.play(2, 5, 'b')
>>> b.play(3, 6, 'w')
>>> print ascii_boards.render_board(b)
9 . . . . . . . . .
8 . . . . . . . . .
7 . . . . . . . . .
6 . . . . . . . . .
5 . . . . . . . . .
4 . . . . . . o . .
3 . . . . . # . . .
2 . . . . . . . . .
1 . . . . . . . . .
A B C D E F G H J
See also the show_sgf.py example script.
Return type: | Board |
---|
Returns the position given in an ASCII diagram.
diagram should be a string in the format returned by render_board(), representing a position with the specified size. Leading and trailing whitespace is ignored.
If the diagram is not in the right form, this function may raise ValueError or may return a ‘best guess’.
If the optional board parameter is provided, it must be an empty Board of the right size; the same object will be returned (this option is provided so you can use a different Board class).