C# Class TicTacToeLib.TicTacToeGame

A simple game of Tic-Tac-Toe.
Mostrar archivo Open project: tansey/sharpneat-tutorials Class Usage Examples

Public Methods

Method Description
GetBoardFromString ( string boardString ) : ].SquareTypes[

Takes a string description of a game board and returns the board array. A valid board example is: X|O|X |X| O|X|O Note that there should be a space in blank squares.

GetRandomBoard ( int moves ) : ].SquareTypes[

Gets a random game board played for a specified number of moves.

GetWinner ( ) : SquareTypes

Gets the winner of the current game.

GetWinner ( SquareTypes Board ) : SquareTypes

Gets the winner based on the specified board.

IsEmpty ( int x, int y ) : bool

Checks if the square located at [x,y] on the game board is empty.

PlayGameToEnd ( IPlayer xPlayer, IPlayer oPlayer ) : SquareTypes

A helper method for competing two players against each other.

ResetGame ( ) : void

Resets the current game by clearing the game board.

TicTacToeGame ( ) : System

Private Methods

Method Description
getSquareType ( string squareString ) : SquareTypes

Method Details

GetBoardFromString() public static method

Takes a string description of a game board and returns the board array. A valid board example is: X|O|X |X| O|X|O Note that there should be a space in blank squares.
public static GetBoardFromString ( string boardString ) : ].SquareTypes[
boardString string
return ].SquareTypes[

GetRandomBoard() public static method

Gets a random game board played for a specified number of moves.
public static GetRandomBoard ( int moves ) : ].SquareTypes[
moves int
return ].SquareTypes[

GetWinner() public method

Gets the winner of the current game.
public GetWinner ( ) : SquareTypes
return SquareTypes

GetWinner() public static method

Gets the winner based on the specified board.
public static GetWinner ( SquareTypes Board ) : SquareTypes
Board SquareTypes
return SquareTypes

IsEmpty() public method

Checks if the square located at [x,y] on the game board is empty.
public IsEmpty ( int x, int y ) : bool
x int
y int
return bool

PlayGameToEnd() public static method

A helper method for competing two players against each other.
public static PlayGameToEnd ( IPlayer xPlayer, IPlayer oPlayer ) : SquareTypes
xPlayer IPlayer The player to act first.
oPlayer IPlayer The player to act second.
return SquareTypes

ResetGame() public method

Resets the current game by clearing the game board.
public ResetGame ( ) : void
return void

TicTacToeGame() public method

public TicTacToeGame ( ) : System
return System