Gotchas¶
This page contains some easy-to-make mistakes that come up when writing code using sente. These Issues may lead to sleeper
Boards vs Games¶
Sente provides two different constructs that represent go boards: the sente.Game object and the various sente.Board<9, 13, 19> objects.
On the surface it seems like these objects are similar to each other because both represent a position on a go board and both have a play method.
TL;DR just use sente.Game.¶
The difference between the two is that a sente.Board contains only the location of the stones on the board and nothing else.
The sente.Board Objects do not know anything about capturing stones, Whose turn it is or Kos.
sente.Board objects only exist in sente if for some reason you need to ignore the rules of the game for some reason which is rarely the case.
Internal vs external Co-ordinates¶
Internally, Sente represents co-ordinates on a go board with zero based indexing.
This means that internally, a stone on the 1-1 corner point would actually be located at the index (0, 0) rather than (1, 1).
The Game.play() method hides this from you by automatically subtracting 1 from the co-ordinates that you specify.
However sente.Move objects use Internal Indexing and thus, if you wish to instantiate a sente.Move Object, the co-ordinates must zero-indexed.
>>> move = sente.Move(0, 0, sente.stone.WHITE) # move is actually on the 1-1 point
>>> game.play(1, 1)
>>> game.play(move)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
sente.exceptions.IllegalMoveException: The Desired move W[aa] lies on an occupied point
Because of this, Instantiating the sente.Move object directly is inadvisable and using sente.play(x, y) is prefered.
Slicing Sequences of Moves¶
As mentioned in game tree navigation, sequences of moves obtained using the game.get_sequence() method are python lists of sente.Move objects which means that python list slicing may be used on them.
However, when you make a slice, you must be very careful about the indices you slice at to ensure that it starts with a move belonging to the correct player.
For example,