C# Class Go.Game

Show file Open project: paviad/GoSharp Class Usage Examples

Public Properties

Property Type Description
PassMove Point
SuperKoComparer SuperKoComparer

Public Methods

Method Description
Game ( Go.GameInfo gi ) : System

Constructs a root game object based on a GameInfo object.

Game ( Go.SGFGameTree sgfGameTree ) : System

Constructs a root game object, along with a complete game tree from the specified SGFGameTree object.

MakeMove ( Point n ) : Game

Makes a move and returns a new Game object representing the state after the move. The move is carried out whether it is legal or illegal (for example, an overwrite move). The color of the move is determined by the Turn property. The legality of the move may be determined by examining the IsLegal property of the returned object.

MakeMove ( Point n, bool &legal ) : Game

Makes a move and returns a new Game object representing the state after the move. The move is carried out whether it is legal or illegal (for example, an overwrite move). The color of the move is determined by the Turn property. If the move was illegal (suicide, violating super-ko, or an overwrite), the method sets the legal parameter to false, otherwise it is set to true.

MakeMove ( int x, int y ) : Game

Makes a move and returns a new Game object representing the state after the move. The move is carried out whether it is legal or illegal (for example, an overwrite move). The color of the move is determined by the Turn property. The legality of the move may be determined by examining the IsLegal property of the returned object.

MakeMove ( int x, int y, bool &legal ) : Game

Makes a move and returns a new Game object representing the state after the move. The move is carried out whether it is legal or illegal (for example, an overwrite move). The color of the move is determined by the Turn property. If the move was illegal (suicide, violating super-ko, or an overwrite), the method sets the legal parameter to false, otherwise it is set to true.

Pass ( ) : Game

Makes a 'pass' move and returns a new Game object representing the state after the move. The color of the move is determined by the Turn property.

SerializeFromSGF ( string path ) : List

Parses an SGF game file and creates a list of games.

SerializeToSGF ( TextWriter s ) : string

Converts the game tree into SGF format.

SetupMove ( Point p, Content c ) : void

Adds a stone to the board as a setup move.

SetupMove ( Point p1, Point p2, Content c ) : void

Adds stones to the board in a rectangular area.

SetupMove ( int x, int y, Content c ) : void

Adds a stone to the board as a setup move.

SetupMove ( int x1, int y1, int x2, int y2, Content c ) : void

Adds stones to the board in a rectangular area.

Protected Methods

Method Description
Game ( Board bs, Content turn ) : System

Constructs a Game object from a Board object and a turn to play.

Game ( Game fromGame ) : System

Constructs a Game object from an existing Game object. This constructor is used when making game moves.

InternalMakeMove ( int x, int y ) : bool

Perform the necessary operations for a move, check liberties, capture, etc. Also updates the Move and IsLegal properties.

Private Methods

Method Description
CreateGameTree ( Go.SGFGameTree root, Game p ) : void
Game ( ) : System
HandleBoardSize ( Go.SGFProperty p ) : Game
HandleHandicap ( Go.SGFProperty p ) : Game
HandleKomi ( Go.SGFProperty p ) : Game
HandleMove ( Go.SGFProperty p ) : Game
HandlePlayerTurn ( Go.SGFProperty p ) : Game
HandleSetup ( Go.SGFProperty p ) : Game
InitializeFromGameInfo ( ) : void
RemoveProperty ( string name ) : void
SerializeMove ( TextWriter s, Point pnt ) : void
SerializeSGFProperties ( TextWriter s ) : void
SerializeToSGFInternal ( TextWriter s ) : void
SetHandicap ( int handicap ) : void
SetProperty ( string name, string value, bool create ) : void

Method Details

Game() protected method

Constructs a Game object from a Board object and a turn to play.
protected Game ( Board bs, Content turn ) : System
bs Board The source Board.
turn Content The color of the player whose turn it is to play.
return System

Game() protected method

Constructs a Game object from an existing Game object. This constructor is used when making game moves.
protected Game ( Game fromGame ) : System
fromGame Game The Game object before the move.
return System

Game() public method

Constructs a root game object based on a GameInfo object.
public Game ( Go.GameInfo gi ) : System
gi Go.GameInfo The GameInfo object.
return System

Game() public method

Constructs a root game object, along with a complete game tree from the specified SGFGameTree object.
public Game ( Go.SGFGameTree sgfGameTree ) : System
sgfGameTree Go.SGFGameTree The SGF game tree object.
return System

InternalMakeMove() protected method

Perform the necessary operations for a move, check liberties, capture, etc. Also updates the Move and IsLegal properties.
protected InternalMakeMove ( int x, int y ) : bool
x int The X coordinate of the move.
y int The Y coordinate of the move.
return bool

MakeMove() public method

Makes a move and returns a new Game object representing the state after the move. The move is carried out whether it is legal or illegal (for example, an overwrite move). The color of the move is determined by the Turn property. The legality of the move may be determined by examining the IsLegal property of the returned object.
public MakeMove ( Point n ) : Game
n Point The coordinates of the move.
return Game

MakeMove() public method

Makes a move and returns a new Game object representing the state after the move. The move is carried out whether it is legal or illegal (for example, an overwrite move). The color of the move is determined by the Turn property. If the move was illegal (suicide, violating super-ko, or an overwrite), the method sets the legal parameter to false, otherwise it is set to true.
public MakeMove ( Point n, bool &legal ) : Game
n Point The coordinates of the move.
legal bool Set to true if the move was legal, false otherwise.
return Game

MakeMove() public method

Makes a move and returns a new Game object representing the state after the move. The move is carried out whether it is legal or illegal (for example, an overwrite move). The color of the move is determined by the Turn property. The legality of the move may be determined by examining the IsLegal property of the returned object.
public MakeMove ( int x, int y ) : Game
x int The X coordinate of the move.
y int The Y coordinate of the move.
return Game

MakeMove() public method

Makes a move and returns a new Game object representing the state after the move. The move is carried out whether it is legal or illegal (for example, an overwrite move). The color of the move is determined by the Turn property. If the move was illegal (suicide, violating super-ko, or an overwrite), the method sets the legal parameter to false, otherwise it is set to true.
public MakeMove ( int x, int y, bool &legal ) : Game
x int The X coordinate of the move.
y int The Y coordinate of the move.
legal bool Set to true if the move was legal, false otherwise.
return Game

Pass() public method

Makes a 'pass' move and returns a new Game object representing the state after the move. The color of the move is determined by the Turn property.
public Pass ( ) : Game
return Game

SerializeFromSGF() public static method

Parses an SGF game file and creates a list of games.
public static SerializeFromSGF ( string path ) : List
path string The path to the SGF file.
return List

SerializeToSGF() public method

Converts the game tree into SGF format.
public SerializeToSGF ( TextWriter s ) : string
s TextWriter A TextWriter object that will receive the output. /// If null, the output is returned as a string.
return string

SetupMove() public method

Adds a stone to the board as a setup move.
public SetupMove ( Point p, Content c ) : void
p Point The coordinates of the setup move.
c Content The color of the stone to add (or empty to clear).
return void

SetupMove() public method

Adds stones to the board in a rectangular area.
public SetupMove ( Point p1, Point p2, Content c ) : void
p1 Point The top left coordinates of the rectangle.
p2 Point The bottom right coordinates of the rectangle.
c Content The color of the stone to add (or empty to clear).
return void

SetupMove() public method

Adds a stone to the board as a setup move.
public SetupMove ( int x, int y, Content c ) : void
x int The X coordinate of the setup move.
y int The Y coordinate of the setup move.
c Content The color of the stone to add (or empty to clear).
return void

SetupMove() public method

Adds stones to the board in a rectangular area.
public SetupMove ( int x1, int y1, int x2, int y2, Content c ) : void
x1 int The left coordinate of the rectangle.
y1 int The top coordinate of the rectangle.
x2 int The right coordinate of the rectangle.
y2 int The bottom coordinate of the rectangle.
c Content The color of the stone to add (or empty to clear).
return void

Property Details

PassMove public static property

Represents a 'pass' move.
public static Point PassMove
return Point

SuperKoComparer public static property

The singleton comparer for super-ko cases. There is no need for more than one instance of this.
public static SuperKoComparer SuperKoComparer
return SuperKoComparer