Game
- class sente.Game
The Sente Game object.
The
sente.GameObject differs from thesente.Boardobject 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 betweensente.Gameandsente.Boardsee 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).
- property comment
The comment associated with the given node
- 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_all_sequences(self: sente.Game) List[List[sente.Move | Set[sente.Move]]]
generates a list of all variations currently in the game
the “default” sequences is the first element in this list
- Returns:
a list of lists of moves where each move is the move sequence.
- get_board(self: sente.Game) sente::_board
Get a copy of the board object that the game is updating internally.
- Returns:
a
sente.Boardobject that represents the board to be played.
- get_branches(self: sente.Game) List[sente.Move | Set[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_current_sequence(self: sente.Game) List[sente.Move | Set[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_default_sequence(self: sente.Game) List[sente.Move | Set[sente.Move]]
generates a list of the moves in the default branch.
- Returns:
the sequence of moves that leads to the current board position.
- get_legal_moves(self: sente.Game) List[sente.Move]
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_properties(self: sente.Game) dict
Get all of the properties from the SGF file.
- Returns:
a python dictionary that maps from metadata parameters (ie. SZ[], FF[]) to their values
- get_result(self: sente.Game) str
returns a string representing the results of the game (ie. W+0.5)
Warning
Sente’s automatic scoring does not remove dead stones
- Returns:
sente.stone of the winner of the game.
- get_sequence(self: sente.Game) List[sente.Move | Set[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
Sente’s automatic scoring does not remove dead stones
- Returns:
sente.stone of the winner of the game. Returns sente.stone.EMPTY if the game is
still in progress
- 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.
- is_legal(*args, **kwargs)
Overloaded function.
is_legal(self: sente.Game, x: int, y: int) -> bool
Checks to see if a move is legal.
Sente checks five conditions to see if a move is illegal
Are the coordinates of the move located on the board?
Does the move lie on an occupied point?
Is it the person playing the stone’s turn?
Does the move result in self-capture?
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.
is_legal(self: sente.Game, x: int, y: int, stone: sente.stone) -> bool
Checks to see if a move is legal.
Sente checks five 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.
is_legal(self: sente.Game, move: sente.Move) -> bool
Checks to see if a move is legal.
Sente checks five 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.
is_legal(self: sente.Game, arg0: object) -> bool
An overloaded extension of the
is_legalmethod acceptsNoneas an argument. Usinggame.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.
numpy(self: sente.Game, arg0: List[str]) -> numpy.ndarray[numpy.uint8]
numpy(self: sente.Game) -> numpy.ndarray[numpy.uint8]
- play(*args, **kwargs)
Overloaded function.
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)
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)
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)
play(self: sente.Game, arg0: Set[sente.Move]) -> None
Sets a list of particular points on the board to the specified color
- param moves:
moves to play on the board
- raises IllegalMoveException:
If any stone cannot be added. Most move legality requirements are ignored.
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 | Set[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) dict
returns a dictionary containing the scores of the game
Warning
Sente’s automatic scoring does not remove dead stones
- Returns:
python dictionary containing the scores and result of the game
- set_active_player(self: sente.Game, arg0: sente.stone) None
Sets the active player
- Parameters:
player – the color of the player to set to be active
- Raises:
ValueError – If the color is set the EMPTY
- set_property(*args, **kwargs)
Overloaded function.
set_property(self: sente.Game, arg0: str, arg1: float) -> None
Adds the specified property to the game
- param property:
SGF property to set the value of
- param value:
value to set the metadata to
- return:
None
set_property(self: sente.Game, arg0: str, arg1: str) -> None
Adds the specified property to the game
- param property:
SGF property to set the value of
- param value:
value to set the metadata to
- return:
None
set_property(self: sente.Game, arg0: str, arg1: List[str]) -> None
Adds the specified property to the game
- param property:
SGF property to set the value of
- param value:
value to set the metadata to
- return:
None
- 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