public GamePlayer(eType i_Type, GameBoardCell.eType i_CellType, string i_PlayerName) { m_Score = 0; r_Type = i_Type; r_CellType = i_CellType; r_PlayerName = i_PlayerName; }
public ReverseTicTacToeAlgo(GameBoardCell.eType i_CellType, GameState i_GameState, GameLogic i_GameLogic) { GameBoardCell.eType opponentCellType = (i_CellType == GameBoardCell.eType.X) ? GameBoardCell.eType.O : GameBoardCell.eType.X; r_GameLogic = i_GameLogic; r_GameState = i_GameState; r_OpponentIndex = i_GameLogic.CellTypeToPlayerIndex(opponentCellType); r_OwnIndex = i_GameLogic.CellTypeToPlayerIndex(i_CellType); }
public Point?MakeMove(Board <GameBoardCell> i_Board, GameBoardCell.eType i_CellType, GameLogic i_GameLogic) { if (m_IsFirstMakeMove) { m_IsFirstMakeMove = false; init(i_CellType, i_GameLogic); } return(m_Algorithm.GetMove()); }
// Makes a move. If bad input was recv, will return null. public Point?MakeMove(Board <GameBoardCell> i_Board, Point i_Input, GameBoardCell.eType i_CellType, GameLogic i_GameLogic) { Point?retMove = null; // checking if move is valid both here and in "GameManager". If the move is not valid in this stage, its the user's input fault. // If the move is not valid in "GameManager" Then its an error! if (i_GameLogic.IsMoveValid(i_Input)) { retMove = i_Input; } return(retMove); }
// Converts GameBoardCell to Player's index in the Player's array. public uint CellTypeToPlayerIndex(GameBoardCell.eType i_Type) { uint?retIndex = null; if (i_Type != GameBoardCell.eType.None) { for (uint i = 0; i < r_Players.Length; i++) { if (i_Type == r_Players[i].CellType) { retIndex = i; } } } return((uint)retIndex); }
// Converts GameBoardCell to Player's index in the Player's array. public uint CellTypeToPlayerIndex(GameBoardCell.eType i_Type) { return(r_Players.CellTypeToPlayerIndex(i_Type)); }
public void init(GameBoardCell.eType i_Sign, GameLogic i_GameLogic) { m_Algorithm = new ReverseTicTacToeAlgo(i_Sign, i_GameLogic.State, i_GameLogic); }