internal OpponentDecision(byte i_RowOfOpponentDecision, byte i_ColOfOpponentDecision, OthelloGame.eGameToken[,] i_MatrixOfOpponentDecision, OthelloGame.eGameToken i_TokenOfOpponent) { m_RowOfOpponentDecision = i_RowOfOpponentDecision; m_ColOfOpponentDecision = i_ColOfOpponentDecision; m_MatrixOfOpponentDecision = new OthelloGame.eGameToken[s_MatrixSize, s_MatrixSize]; Computer.CopyTokensMatrice(i_MatrixOfOpponentDecision, m_MatrixOfOpponentDecision, s_MatrixSize); m_TokenOfOpponent = i_TokenOfOpponent; ValueOfopponentDecisionMatrix = calculateValueOfOpponentDecision(); }
internal Decision(byte i_RowOfDecision, byte i_ColOfDecision, OthelloGame.eGameToken[,] i_currGameMatrix, OthelloGame.eGameToken i_Token) { RowOfDecision = i_RowOfDecision; ColumnOfDecision = i_ColOfDecision; m_MatrixOfDecision = new OthelloGame.eGameToken[s_MatrixSize, s_MatrixSize]; Computer.CopyTokensMatrice(i_currGameMatrix, m_MatrixOfDecision, s_MatrixSize); m_TokenOfComputer = i_Token; m_OpponentDecisions = new LinkedList <OpponentDecision>(); setDecisionInsideMatrix(); }
private int calculateCornersValues() { OthelloGame.eGameToken leftUpCorner = m_MatrixOfOpponentDecision[0, 0]; OthelloGame.eGameToken leftDownCorner = m_MatrixOfOpponentDecision[Minimax.s_MatrixSize - 1, 0]; OthelloGame.eGameToken RightUpCorner = m_MatrixOfOpponentDecision[0, Minimax.s_MatrixSize - 1]; OthelloGame.eGameToken RightDownCorner = m_MatrixOfOpponentDecision[Minimax.s_MatrixSize - 1, Minimax.s_MatrixSize - 1]; int valueOfCorners = 0; valueOfCorners += calculateCurrentTokenInMatrixAccordingToSpecificValue(leftUpCorner, k_CornerValue); valueOfCorners += calculateCurrentTokenInMatrixAccordingToSpecificValue(leftDownCorner, k_CornerValue); valueOfCorners += calculateCurrentTokenInMatrixAccordingToSpecificValue(RightUpCorner, k_CornerValue); valueOfCorners += calculateCurrentTokenInMatrixAccordingToSpecificValue(RightDownCorner, k_CornerValue); return(valueOfCorners); }
private int calculateCurrentTokenInMatrixAccordingToSpecificValue(OthelloGame.eGameToken i_CurrTokenInMatrix, int i_SpecificValue) { int tokenValue = 0; if (i_CurrTokenInMatrix == m_TokenOfOpponent) { tokenValue -= i_SpecificValue; } else { if (i_CurrTokenInMatrix != OthelloGame.eGameToken.Empty) { tokenValue += i_SpecificValue; } } return(tokenValue); }
private void setOpponentDecisions() { foreach (Minimax.Decision decisionOfOpponent in m_MinimaxTree.Decisions) { byte row = decisionOfOpponent.RowOfDecision; byte col = decisionOfOpponent.ColumnOfDecision; OthelloGame.eGameToken[,] matrixOfTheGameToOpponentsDecisionsTree = m_TheGame.GameStatus; OthelloGame.eGameToken[,] matrixOfTheGameToRemember = new OthelloGame.eGameToken[m_TheGame.GameBoardSize, m_TheGame.GameBoardSize]; OthelloGame.eGameToken[,] matrixToRememberBeforeOpponentsTurn = new OthelloGame.eGameToken[m_TheGame.GameBoardSize, m_TheGame.GameBoardSize]; CopyTokensMatrice(matrixOfTheGameToOpponentsDecisionsTree, matrixOfTheGameToRemember, m_TheGame.GameBoardSize); m_TheGame.AddTokenFromUserToBoard(row, col); m_TheGame.AddWonTokensToBoard(row, col); m_TheGame.ChangePlayerTurn(); findDecisionsForOpponent(matrixOfTheGameToOpponentsDecisionsTree, matrixToRememberBeforeOpponentsTurn, decisionOfOpponent); CopyTokensMatrice(matrixOfTheGameToRemember, matrixOfTheGameToOpponentsDecisionsTree, m_TheGame.GameBoardSize); m_TheGame.ChangePlayerTurn(); } }
private void setComputerDecisions() { OthelloGame.eGameToken[,] matrixOfTheGameToRemember = new OthelloGame.eGameToken[m_TheGame.GameBoardSize, m_TheGame.GameBoardSize]; OthelloGame.eGameToken[,] matrixOfTheGameToDecisionsTree = m_TheGame.GameStatus; for (byte i = 0; i < m_TheGame.GameBoardSize; ++i) { for (byte j = 0; j < m_TheGame.GameBoardSize; ++j) { CopyTokensMatrice(matrixOfTheGameToDecisionsTree, matrixOfTheGameToRemember, m_TheGame.GameBoardSize); if (m_TheGame.IsLegalMovement(i, j)) { m_TheGame.AddTokenFromUserToBoard(i, j); m_TheGame.AddWonTokensToBoard(i, j); m_MinimaxTree.AddDesicionToTree(i, j, matrixOfTheGameToDecisionsTree, ComputerToken); CopyTokensMatrice(matrixOfTheGameToRemember, matrixOfTheGameToDecisionsTree, m_TheGame.GameBoardSize); } } } }
private char displayToken(OthelloGame.eGameToken i_Token) { char tokenRep; switch (i_Token) { case OthelloGame.eGameToken.BlackToken: tokenRep = k_BlackTokenRep; break; case OthelloGame.eGameToken.WhiteToken: tokenRep = k_WhiteTokenRep; break; default: tokenRep = k_EmptyTokenRep; break; } return(tokenRep); }
public Computer(OthelloGame.eGameToken i_Token, OthelloGame i_Game) { r_ComputerToken = i_Token; m_TheGame = i_Game; m_MinimaxTree = new Minimax(m_TheGame.GameBoardSize); }
internal void AddDesicionToTree(byte i_Row, byte i_Col, OthelloGame.eGameToken[,] i_MatrixOfDecision, OthelloGame.eGameToken i_Token) { m_Decisions.AddLast(new Decision(i_Row, i_Col, i_MatrixOfDecision, i_Token)); }
internal void AddOpponentDecision(byte i_RowOfOpponentDecision, byte i_ColOfOpponentDecision, OthelloGame.eGameToken[,] i_MatrixOfDecision, OthelloGame.eGameToken i_OpponentToken) { OpponentDecision opp = new OpponentDecision(i_RowOfOpponentDecision, i_ColOfOpponentDecision, i_MatrixOfDecision, i_OpponentToken); this.m_OpponentDecisions.AddLast(opp); }
public Board(byte i_BoardSize) { BoardSize = i_BoardSize; GameBoard = new OthelloGame.eGameToken[i_BoardSize, i_BoardSize]; }
public Player(string i_PlayerName, OthelloGame.eGameToken i_PlayerToken, byte i_PlayerScore) { r_PlayerName = i_PlayerName; r_PlayerToken = i_PlayerToken; PlayerScore = i_PlayerScore; }
public Player(string i_PlayerName, OthelloGame.eGameToken i_PlayerToken) : this(i_PlayerName, i_PlayerToken, 0) { }