C# Class TicTacToeLib.TicTacToeGame

A simple game of Tic-Tac-Toe.
Afficher le fichier Open project: tansey/sharpneat-tutorials Class Usage Examples

Méthodes publiques

Méthode 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

Méthode Description
getSquareType ( string squareString ) : SquareTypes

Method Details

GetBoardFromString() public static méthode

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
Résultat ].SquareTypes[

GetRandomBoard() public static méthode

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

GetWinner() public méthode

Gets the winner of the current game.
public GetWinner ( ) : SquareTypes
Résultat SquareTypes

GetWinner() public static méthode

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

IsEmpty() public méthode

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
Résultat bool

PlayGameToEnd() public static méthode

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.
Résultat SquareTypes

ResetGame() public méthode

Resets the current game by clearing the game board.
public ResetGame ( ) : void
Résultat void

TicTacToeGame() public méthode

public TicTacToeGame ( ) : System
Résultat System