public bool isValidDiagonalKingMove(Player.eShapeType i_ShapeOfMove) { bool isValidKingMove = false; if ((m_FromSquare.Row - 1 == m_ToSquare.Row) && (m_FromSquare.Column - 1 == m_ToSquare.Column)) { isValidKingMove = true; } if ((m_FromSquare.Row - 1 == m_ToSquare.Row) && (m_FromSquare.Column + 1 == m_ToSquare.Column)) { isValidKingMove = true; } if ((m_FromSquare.Row + 1 == m_ToSquare.Row) && (m_FromSquare.Column - 1 == m_ToSquare.Column)) { isValidKingMove = true; } if ((m_FromSquare.Row + 1 == m_ToSquare.Row) && (m_FromSquare.Column + 1 == m_ToSquare.Column)) { isValidKingMove = true; } return(isValidKingMove); }
public bool isValidDiagonalMove(Player.eShapeType i_Shape) { bool isValidMove = false; switch (i_Shape) { case Player.eShapeType.X: if ((m_FromSquare.Row - 1 == m_ToSquare.Row) && (m_FromSquare.Column - 1 == m_ToSquare.Column)) { isValidMove = true; } if ((m_FromSquare.Row - 1 == m_ToSquare.Row) && (m_FromSquare.Column + 1 == m_ToSquare.Column)) { isValidMove = true; } break; case Player.eShapeType.O: if ((m_FromSquare.Row + 1 == m_ToSquare.Row) && (m_FromSquare.Column - 1 == m_ToSquare.Column)) { isValidMove = true; } if ((m_FromSquare.Row + 1 == m_ToSquare.Row) && (m_FromSquare.Column + 1 == m_ToSquare.Column)) { isValidMove = true; } break; } return(isValidMove); }
internal int GetPointsOfPlayer(Player.eShapeType i_Piece) { int countPlayerPoints = 0; switch (i_Piece) { case Player.eShapeType.X: for (int i = 0; i < this.m_Size; i++) { for (int j = 0; j < this.m_Size; j++) { Square currentSquare = this.m_Board[i, j]; if (currentSquare.Type == Square.eSquareType.X) { countPlayerPoints += 1; } if (currentSquare.Type == Square.eSquareType.K) { countPlayerPoints += 4; } } } break; case Player.eShapeType.O: for (int i = 0; i < this.m_Size; i++) { for (int j = 0; j < this.m_Size; j++) { Square currentSquare = this.m_Board[i, j]; if (currentSquare.Type == Square.eSquareType.O) { countPlayerPoints += 1; } if (currentSquare.Type == Square.eSquareType.U) { countPlayerPoints += 4; } } } break; } return(countPlayerPoints); }
private List <Move> getListOfJumpsForPiece(Player.eShapeType i_Shape, Square i_Square) { int squareRow = i_Square.Row; int squareColumn = i_Square.Column; Move currentMove; List <Move> leggalJumpsForPiece = m_BoardGame.GetListOfPlayerJumps(i_Shape); for (int i = 0; i < leggalJumpsForPiece.Count; i++) { currentMove = leggalJumpsForPiece[i]; if (currentMove.FromSquare.Row != squareRow || currentMove.FromSquare.Column != squareColumn) { leggalJumpsForPiece.Remove(currentMove); } } return(leggalJumpsForPiece); }
public List <Move> GetListOfPlayerJumps(Player.eShapeType i_Shape) { List <Move> leggalJumps = new List <Move>(); short boardSize = this.GetSize(); for (int r = 0; r < boardSize; r++) { for (int c = 0; c < boardSize; c++) { switch (i_Shape) { case Player.eShapeType.O: // regular piece of O if (getTypeOfSquareInBoard(r, c) == Square.eSquareType.O) { if ((getTypeOfSquareInBoard(r + 2, c - 2) == Square.eSquareType.None) && (getTypeOfSquareInBoard(r + 1, c - 1) == Square.eSquareType.X || getTypeOfSquareInBoard(r + 1, c - 1) == Square.eSquareType.K)) { leggalJumps.Add(new Move(GetSquare(r, c), GetSquare(r + 2, c - 2))); } if ((getTypeOfSquareInBoard(r + 2, c + 2) == Square.eSquareType.None) && (getTypeOfSquareInBoard(r + 1, c + 1) == Square.eSquareType.X || getTypeOfSquareInBoard(r + 1, c + 1) == Square.eSquareType.K)) { leggalJumps.Add(new Move(GetSquare(r, c), GetSquare(r + 2, c + 2))); } } // King of O if (getTypeOfSquareInBoard(r, c) == Square.eSquareType.U) { if ((getTypeOfSquareInBoard(r + 2, c - 2) == Square.eSquareType.None) && (getTypeOfSquareInBoard(r + 1, c - 1) == Square.eSquareType.X || getTypeOfSquareInBoard(r + 1, c - 1) == Square.eSquareType.K)) { leggalJumps.Add(new Move(GetSquare(r, c), GetSquare(r + 2, c - 2))); } if ((getTypeOfSquareInBoard(r + 2, c + 2) == Square.eSquareType.None) && (getTypeOfSquareInBoard(r + 1, c + 1) == Square.eSquareType.X || getTypeOfSquareInBoard(r + 1, c + 1) == Square.eSquareType.K)) { leggalJumps.Add(new Move(GetSquare(r, c), GetSquare(r + 2, c + 2))); } if ((getTypeOfSquareInBoard(r - 2, c - 2) == Square.eSquareType.None) && (getTypeOfSquareInBoard(r - 1, c - 1) == Square.eSquareType.X || getTypeOfSquareInBoard(r - 1, c - 1) == Square.eSquareType.K)) { leggalJumps.Add(new Move(GetSquare(r, c), GetSquare(r - 2, c - 2))); } if ((getTypeOfSquareInBoard(r - 2, c + 2) == Square.eSquareType.None) && (getTypeOfSquareInBoard(r - 1, c + 1) == Square.eSquareType.X || getTypeOfSquareInBoard(r - 1, c + 1) == Square.eSquareType.K)) { leggalJumps.Add(new Move(GetSquare(r, c), GetSquare(r - 2, c + 2))); } } break; case Player.eShapeType.X: // regular piece of X if (getTypeOfSquareInBoard(r, c) == Square.eSquareType.X) { if ((getTypeOfSquareInBoard(r - 2, c - 2) == Square.eSquareType.None) && (getTypeOfSquareInBoard(r - 1, c - 1) == Square.eSquareType.O || getTypeOfSquareInBoard(r - 1, c - 1) == Square.eSquareType.U)) { leggalJumps.Add(new Move(GetSquare(r, c), GetSquare(r - 2, c - 2))); } if ((getTypeOfSquareInBoard(r - 2, c + 2) == Square.eSquareType.None) && (getTypeOfSquareInBoard(r - 1, c + 1) == Square.eSquareType.O || getTypeOfSquareInBoard(r - 1, c + 1) == Square.eSquareType.U)) { leggalJumps.Add(new Move(GetSquare(r, c), GetSquare(r - 2, c + 2))); } } // king of X if (getTypeOfSquareInBoard(r, c) == Square.eSquareType.K) { if ((getTypeOfSquareInBoard(r + 2, c - 2) == Square.eSquareType.None) && (getTypeOfSquareInBoard(r + 1, c - 1) == Square.eSquareType.O || getTypeOfSquareInBoard(r + 1, c - 1) == Square.eSquareType.U)) { leggalJumps.Add(new Move(GetSquare(r, c), GetSquare(r + 2, c - 2))); } if ((getTypeOfSquareInBoard(r + 2, c + 2) == Square.eSquareType.None) && (getTypeOfSquareInBoard(r + 1, c + 1) == Square.eSquareType.O || getTypeOfSquareInBoard(r + 1, c + 1) == Square.eSquareType.U)) { leggalJumps.Add(new Move(GetSquare(r, c), GetSquare(r + 2, c + 2))); } if ((getTypeOfSquareInBoard(r - 2, c - 2) == Square.eSquareType.None) && (getTypeOfSquareInBoard(r - 1, c - 1) == Square.eSquareType.O || getTypeOfSquareInBoard(r - 1, c - 1) == Square.eSquareType.U)) { leggalJumps.Add(new Move(GetSquare(r, c), GetSquare(r - 2, c - 2))); } if ((getTypeOfSquareInBoard(r - 2, c + 2) == Square.eSquareType.None) && (getTypeOfSquareInBoard(r - 1, c + 1) == Square.eSquareType.O || getTypeOfSquareInBoard(r - 1, c + 1) == Square.eSquareType.U)) { leggalJumps.Add(new Move(GetSquare(r, c), GetSquare(r - 2, c + 2))); } } break; } } } return(leggalJumps); }
internal List <Move> GetListOfPlayerDiagonalMoves(Player.eShapeType i_Shape) { List <Move> leggalMoves = new List <Move>(); short boardSize = this.GetSize(); for (int r = 0; r < boardSize; r++) { for (int c = 0; c < boardSize; c++) { switch (i_Shape) { case Player.eShapeType.O: // Regular piece of O if (getTypeOfSquareInBoard(r, c) == Square.eSquareType.O) { if (getTypeOfSquareInBoard(r + 1, c - 1) == Square.eSquareType.None) { leggalMoves.Add(new Move(GetSquare(r, c), GetSquare(r + 1, c - 1))); } if (getTypeOfSquareInBoard(r + 1, c + 1) == Square.eSquareType.None) { leggalMoves.Add(new Move(GetSquare(r, c), GetSquare(r + 1, c + 1))); } } // King of O if (getTypeOfSquareInBoard(r, c) == Square.eSquareType.U) { if (getTypeOfSquareInBoard(r + 1, c - 1) == Square.eSquareType.None) { leggalMoves.Add(new Move(GetSquare(r, c), GetSquare(r + 1, c - 1))); } if (getTypeOfSquareInBoard(r + 1, c + 1) == Square.eSquareType.None) { leggalMoves.Add(new Move(GetSquare(r, c), GetSquare(r + 1, c + 1))); } if (getTypeOfSquareInBoard(r - 1, c - 1) == Square.eSquareType.None) { leggalMoves.Add(new Move(GetSquare(r, c), GetSquare(r - 1, c - 1))); } if (getTypeOfSquareInBoard(r - 1, c + 1) == Square.eSquareType.None) { leggalMoves.Add(new Move(GetSquare(r, c), GetSquare(r - 1, c + 1))); } } break; // regular piece for X case Player.eShapeType.X: if (getTypeOfSquareInBoard(r, c) == Square.eSquareType.X) { if (getTypeOfSquareInBoard(r - 1, c - 1) == Square.eSquareType.None) { leggalMoves.Add(new Move(GetSquare(r, c), GetSquare(r - 1, c - 1))); } if (getTypeOfSquareInBoard(r - 1, c + 1) == Square.eSquareType.None) { leggalMoves.Add(new Move(GetSquare(r, c), GetSquare(r - 1, c + 1))); } } // King of X if (getTypeOfSquareInBoard(r, c) == Square.eSquareType.K) { if (getTypeOfSquareInBoard(r + 1, c - 1) == Square.eSquareType.None) { leggalMoves.Add(new Move(GetSquare(r, c), GetSquare(r + 1, c - 1))); } if (getTypeOfSquareInBoard(r + 1, c + 1) == Square.eSquareType.None) { leggalMoves.Add(new Move(GetSquare(r, c), GetSquare(r + 1, c + 1))); } if (getTypeOfSquareInBoard(r - 1, c - 1) == Square.eSquareType.None) { leggalMoves.Add(new Move(GetSquare(r, c), GetSquare(r - 1, c - 1))); } if (getTypeOfSquareInBoard(r - 1, c + 1) == Square.eSquareType.None) { leggalMoves.Add(new Move(GetSquare(r, c), GetSquare(r - 1, c + 1))); } } break; } } } return(leggalMoves); }
public bool CheckIsValidMove(Player.eShapeType i_ShapeOfPlayer) { bool isValidMove = true; switch (i_ShapeOfPlayer) { case Player.eShapeType.X: if (m_FromSquare.Type != Square.eSquareType.X && m_FromSquare.Type != Square.eSquareType.K) { isValidMove = false; } else { if (m_ToSquare.Type != Square.eSquareType.None) { isValidMove = false; } else { if (m_FromSquare.Type == Square.eSquareType.X) { isValidMove = isValidDiagonalMove(Player.eShapeType.X); } else { isValidMove = isValidDiagonalKingMove(Player.eShapeType.X); } } } break; case Player.eShapeType.O: if (m_FromSquare.Type != Square.eSquareType.O && m_FromSquare.Type != Square.eSquareType.U) { isValidMove = false; } else { if (m_ToSquare.Type != Square.eSquareType.None) { isValidMove = false; } else { if (m_FromSquare.Type == Square.eSquareType.O) { isValidMove = isValidDiagonalMove(Player.eShapeType.O); } else { isValidMove = isValidDiagonalKingMove(Player.eShapeType.O); } } } break; } return(isValidMove); }