Game

class sente.Game

The Sente Game object.

The sente.Game Object differs from the sente.Board object in that it accounts for the rules of Go and is capable of capturing stones and deeming ko moves invalid. For more on the difference between sente.Game and sente.Board see Boards vs Games.

advance_to_root(self: sente.Game) None

Advance the board tree position to the root of the tree (ie. an empty board).

get_active_player(self: sente.Game) sente.stone

get the stone color of the active player (the player whose turn it is right now).

Returns

the stone color of the active player.

get_board(self: sente.Game) sente::_board

Get the board object that the game is updating internally.

Returns

a sente.Board object that represents the board to be played.

get_branches(self: sente.Game) List[sente.Move]

generates a list of the branches at the current node of the game tree.

Returns

list of branches at the current node of the tree

get_default_sequence(self: sente.Game) List[sente.Move]

generates a list of the moves in the default branch.

Returns

the sequence of moves that leads to the current board position.

generates a list of all legal moves

Returns

list of legal moves on the current board

get_point(self: sente.Game, x: int, y: int) sente.stone

get move played at the specified position.

Parameters
  • x – x co-ordinate of the point to locate.

  • y – y co-ordinate of the point to locate.

Returns

a sente.stone object representing the specified point

get_results(self: sente.Game) sente.results

returns a results object for a game.

Warning

This method does not remove dead stones

Returns

sente.results object.

get_sequence(self: sente.Game) List[sente.Move]

generate the sequence of moves that leads to the current board position

Returns

a python list containing the moves that lead to this position.

get_winner(self: sente.Game) sente.stone

determines the winner of the game.

Warning

This method does not remove dead stones.

Returns

sente.stone of the winner of the game.

is_at_root(self: sente.Game) bool

Determine if the board is currently at the root of the tree.

Returns

whether or not the board is at the root of the tree.

Overloaded function.

  1. is_legal(self: sente.Game, x: int, y: int) -> bool

    Checks to see if a move is legal.

    Sente checks 5 conditions to see if a move is illegal

    1. Are the co-ordinates of the move located on the board?

    2. Does the move lie on an occupied point?

    3. Is it the person playing the stone’s turn?

    4. Does the move result in self-capture?

    5. Is the move illegal because of a Ko?

    param x

    The x co-ordinate of the move.

    param y

    The y co-ordinate of the move.

    return

    whether or not the move satisfies the above conditions.

  2. is_legal(self: sente.Game, x: int, y: int, stone: sente.stone) -> bool

    Checks to see if a move is legal.

    Sente checks 5 conditions to see if a move is illegal (see above).

    param x

    The x co-ordinate of the move.

    param y

    The y co-ordinate of the move.

    param stone

    The color of the player making the move.

    return

    whether or not the move satisfies the above conditions.

  3. is_legal(self: sente.Game, move: sente.Move) -> bool

    Checks to see if a move is legal.

    Sente checks 5 conditions to see if a move is illegal (see above).

    param move

    A move object to play

    return

    whether or not the move satisfies the above conditions.

  4. is_legal(self: sente.Game, arg0: object) -> bool

    An overloaded extension of the is_legal method that accepts None as an argument. using game.play(None) is interpreted as passing and this method ensures that such a move is legal.

    param move

    A move object to play

    return

    whether or not the move satisfies the above conditions.

is_over(self: sente.Game) bool

determine if the game is over yet

Returns

whether or not the game has ended

numpy(*args, **kwargs)

Overloaded function.

  1. numpy(self: sente.Game, arg0: List[str]) -> numpy.ndarray[numpy.uint8]

  2. numpy(self: sente.Game) -> numpy.ndarray[numpy.uint8]

play(*args, **kwargs)

Overloaded function.

  1. play(self: sente.Game, x: int, y: int) -> None

    Plays a stone on the board at the specified location and Captures and stones

    param x

    The x co-ordinate of the move to play.

    param y

    The y co-ordinate of the move to play:

    raises IllegalMoveException

    If the move is illegal. (see Game.is_legal)

  2. play(self: sente.Game, x: int, y: int, stone: sente.stone) -> None

    Plays a stone on the board at the specified location and Captures and stones

    param x

    The x co-ordinate of the move to play.

    param y

    The y co-ordinate of the move to play:

    param stones

    The color of the stone to play.

    raises IllegalMoveException

    If the move is illegal. (see Game.is_legal)

  3. play(self: sente.Game, move: sente.Move) -> None

    Plays a stone on the board at the specified location and Captures and stones

    param move

    The Move object to play

    raises IllegalMoveException

    If the move is illegal. (see Game.is_legal)

  4. play(self: sente.Game, arg0: object) -> None

    Plays a stone on the board at the specified location and Captures and stones

    param move

    The Move object to play

    raises IllegalMoveException

    If the move is illegal. (see Game.is_legal)

    raises ValueError

    If a valid Move object is not passed

play_default_sequence(self: sente.Game) None

plays out the moves in the default (first) branch of the tree

play_sequence(self: sente.Game, moves: List[sente.Move]) None

plays all of the moves in a given list of moves

Parameters

moves – a list of move objects to play

Raises

IllegalMoveException – If any move in the sequence is illegal

pss(self: sente.Game) None

causes the current active player to pass.

resign(self: sente.Game) None

causes the current active player to resign.

score(self: sente.Game) sente.results

scores a game and returns the results.

Warning

This method does not remove dead stones

Returns

sente.results object.

step_up(self: sente.Game, steps: int = 1) None

step up the tree the specified number of steps. ie. undo the specified number of moves

Parameters

steps – the number to steps to step up