The common module

The gomill.common module provides Go-related utility functions, used throughout Gomill.

It is designed to be safe to use as from common import *.

Return type:colour

Returns the other colour:

>>> opponent_of('b')
Return type:string

Returns the (lower-case) full name of a colour:

>>> colour_name('b')
Return type:string

Returns a string describing a move in conventional notation:

>>> format_vertex((3, 0))
>>> format_vertex(None)

The result is suitable for use directly in GTP responses. Note that I is omitted from the letters used to indicate columns, so the maximum supported column value is 25.

Return type:string

Returns a string describing a sequence of moves:

>>> format_vertex_list([(0, 1), (2, 3), None])
>>> format_vertex_list([])
gomill.common.move_from_vertex(vertex, board_size)[source]
Return type:move

Interprets the string vertex as conventional notation, assuming a square board whose side is board_size:

>>> move_from_vertex("A4", 9)
(3, 0)
>>> move_from_vertex("a4", 9)
(3, 0)
>>> move_from_vertex("pass", 9)

Raises ValueError if it can’t parse the string, or if the resulting point would be off the board.

Treats vertex case-insensitively.