예제 #1
0
    public eTypeOfMove DoMove(Point i_SourcePoint, Point i_TargetPoint)
    {
        eTypeOfMove i_MoveType = eTypeOfMove.IllegalMove;

        int[]     i_Source   = { i_SourcePoint.X, i_SourcePoint.Y };
        int[]     i_Target   = { i_TargetPoint.X, i_TargetPoint.Y };
        eCoinSign i_CoinSign = GameBoard.Matrix[i_Source[0], i_Source[1]].Sign;

        if (i_CoinSign == eCoinSign.PlayerX)
        {
            i_MoveType = moveDownToUp(i_Source, i_Target);
        }
        else if (i_CoinSign == eCoinSign.PlayerO)
        {
            i_MoveType = moveUpToDown(i_Source, i_Target);
        }
        else if ((i_CoinSign == eCoinSign.PlayerOKing) || (i_CoinSign == eCoinSign.PlayerXKing))
        {
            if (i_Source[0] > i_Target[0])
            {
                i_MoveType = moveDownToUp(i_Source, i_Target);
            }
            else
            {
                i_MoveType = moveUpToDown(i_Source, i_Target);
            }
        }

        return(i_MoveType);
    }
예제 #2
0
    private bool checkIfExistRegularMoveAndFillMovesList(int i_Row, int i_Col)
    {
        bool      v_CanMove       = false;
        eCoinSign i_CurSign       = GameBoard.Matrix[i_Row, i_Col].Sign;
        eStatus   i_NotExistCoin  = eStatus.NotExistCoin;
        eStatus   i_UpRightCell   = (i_Row > 0 && i_Col < GameBoard.NumOfRowsAndCols - 1) ? GameBoard.Matrix[i_Row - 1, i_Col + 1].Status : eStatus.Illegal;
        eStatus   i_UpLeftCell    = (i_Row > 0 && i_Col > 0) ? GameBoard.Matrix[i_Row - 1, i_Col - 1].Status : eStatus.Illegal;
        eStatus   i_DownRightCell = (i_Row < GameBoard.NumOfRowsAndCols - 1 && i_Col < GameBoard.NumOfRowsAndCols - 1) ? GameBoard.Matrix[i_Row + 1, i_Col + 1].Status : eStatus.Illegal;
        eStatus   i_DownLeftCell  = (i_Row < GameBoard.NumOfRowsAndCols - 1 && i_Col > 0) ? GameBoard.Matrix[i_Row + 1, i_Col - 1].Status : eStatus.Illegal;

        if (i_CurSign == eCoinSign.PlayerO)
        {
            v_CanMove = i_DownLeftCell == i_NotExistCoin || i_DownRightCell == i_NotExistCoin;
        }

        if (i_CurSign == eCoinSign.PlayerX)
        {
            v_CanMove = i_UpLeftCell == i_NotExistCoin || i_UpRightCell == i_NotExistCoin;
        }

        if ((i_CurSign == eCoinSign.PlayerXKing) || (i_CurSign == eCoinSign.PlayerOKing))
        {
            v_CanMove = i_UpLeftCell == i_NotExistCoin || i_UpRightCell == i_NotExistCoin || i_DownLeftCell == i_NotExistCoin || i_DownRightCell == i_NotExistCoin;
        }

        if ((GameBoard.Matrix[i_Row, i_Col].Owner == eOwner.Player2) && (Players[1].TypeOfPlayer == eTypeOfPlayer.Computer))
        {
            if (i_UpLeftCell == i_NotExistCoin)
            {
                Players[1].LigalMovesList.Add(new SourceAndTargetMove(i_Row, i_Col, i_Row - 1, i_Col - 1, -1, -1, eTypeOfMove.RegularMove));
            }

            if (i_UpRightCell == i_NotExistCoin)
            {
                Players[1].LigalMovesList.Add(new SourceAndTargetMove(i_Row, i_Col, i_Row - 1, i_Col + 1, -1, -1, eTypeOfMove.RegularMove));
            }

            if (i_CurSign == eCoinSign.PlayerXKing)
            {
                if (i_DownLeftCell == i_NotExistCoin)
                {
                    Players[1].LigalMovesList.Add(new SourceAndTargetMove(i_Row, i_Col, i_Row + 1, i_Col - 1, -1, -1, eTypeOfMove.RegularMove));
                }

                if (i_DownRightCell == i_NotExistCoin)
                {
                    Players[1].LigalMovesList.Add(new SourceAndTargetMove(i_Row, i_Col, i_Row + 1, i_Col + 1, -1, -1, eTypeOfMove.RegularMove));
                }
            }
        }

        return(v_CanMove);
    }
예제 #3
0
 public Cell(eCoinSign i_Sign)
 {
     this.m_Sign   = i_Sign;
     this.m_Status = eStatus.Illegal;
     if (i_Sign == eCoinSign.PlayerO)
     {
         this.m_Owner = eOwner.Player1;
     }
     else
     {
         this.m_Owner = eOwner.Player2;
     }
 }
예제 #4
0
    public Player(string i_Name, eTypeOfPlayer i_TypeOfPlayer, int i_NumOfCoins, eCoinSign i_CoinSign)
    {
        this.m_TypeOfPlayer = i_TypeOfPlayer;
        this.m_PlayerName   = i_Name;
        this.m_Score        = 0;
        this.m_CoinSign     = i_CoinSign;
        if (this.m_CoinSign == eCoinSign.PlayerX)
        {
            this.m_KingSign = eCoinSign.PlayerXKing;
        }
        else if (this.m_CoinSign == eCoinSign.PlayerO)
        {
            this.m_KingSign = eCoinSign.PlayerOKing;
        }

        this.m_ListOfLigalMove = new List <SourceAndTargetMove>();
    }
예제 #5
0
    private void fillMustEatMovesListUpToDown(int i_RowSource, int i_ColSource)
    {
        eOwner      i_CurOwner = GameBoard.Matrix[i_RowSource, i_ColSource].Owner;
        eTypeOfMove i_MoveType = eTypeOfMove.MustToEat;
        eCoinSign   i_CoinSign = GameBoard.Matrix[i_RowSource, i_ColSource].Sign;

        if (checkIfMustToEatUpToDownRight(i_CurOwner, i_RowSource, i_ColSource))
        {
            i_MoveType = checkIfMustToEatDownToUp(i_CurOwner, i_RowSource + 2, i_ColSource + 2) || checkIfMustToEatUpToDown(i_CurOwner, i_RowSource + 2, i_ColSource + 2) ? eTypeOfMove.CanMoreSkip : eTypeOfMove.MustToEat;
            Players[1].LigalMovesList.Add(new SourceAndTargetMove(i_RowSource, i_ColSource, i_RowSource + 2, i_ColSource + 2, i_RowSource + 1, i_ColSource + 1, i_MoveType));
        }

        if (checkIfMustToEatUpToDownLeft(i_CurOwner, i_RowSource, i_ColSource))
        {
            i_MoveType = checkIfMustToEatDownToUp(i_CurOwner, i_RowSource + 2, i_ColSource - 2) || checkIfMustToEatUpToDown(i_CurOwner, i_RowSource + 2, i_ColSource - 2) ? eTypeOfMove.CanMoreSkip : eTypeOfMove.MustToEat;
            Players[1].LigalMovesList.Add(new SourceAndTargetMove(i_RowSource, i_ColSource, i_RowSource + 2, i_ColSource - 2, i_RowSource + 1, i_ColSource - 1, i_MoveType));
        }
    }
예제 #6
0
    private eTypeOfMove eatAndUpdateCellMoveDownToUp(eTypeOfMove i_MoveType, int[] i_Source, int[] i_Terget, int i_ColSource)
    {
        resetCell(i_Source[0] - 1, i_ColSource);
        updateSourceAndTargetCells(i_Source, i_Terget);
        eCoinSign i_CurrentPlayer = GameBoard.Matrix[i_Terget[0], i_Terget[1]].Sign;
        eOwner    i_CurrentOwner  = GameBoard.Matrix[i_Terget[0], i_Terget[1]].Owner;

        if (i_CurrentPlayer == eCoinSign.PlayerX)
        {
            i_MoveType = checkIfMustToEatDownToUp(i_CurrentOwner, i_Terget[0], i_Terget[1]) ? eTypeOfMove.CanMoreSkip : eTypeOfMove.SkipMove;
        }

        if ((i_CurrentPlayer == eCoinSign.PlayerXKing) || (i_CurrentPlayer == eCoinSign.PlayerOKing))
        {
            i_MoveType = checkIfMustToEatUpToDown(i_CurrentOwner, i_Terget[0], i_Terget[1]) || checkIfMustToEatDownToUp(i_CurrentOwner, i_Terget[0], i_Terget[1]) ? eTypeOfMove.CanMoreSkip : eTypeOfMove.SkipMove;
        }

        return(i_MoveType);
    }
예제 #7
0
    private bool checkIfCanMove(eOwner i_CurOwner, int i_Row, int i_Col)
    {
        bool      v_CanMove = false;
        eCoinSign i_CurSign = GameBoard.Matrix[i_Row, i_Col].Sign;

        if (i_CurSign == eCoinSign.PlayerO)
        {
            v_CanMove = checkIfMustToEatUpToDown(i_CurOwner, i_Row, i_Col) || checkIfExistRegularMoveAndFillMovesList(i_Row, i_Col);
        }

        if (i_CurSign == eCoinSign.PlayerX)
        {
            v_CanMove = checkIfMustToEatDownToUp(i_CurOwner, i_Row, i_Col) || checkIfExistRegularMoveAndFillMovesList(i_Row, i_Col);
        }

        if ((i_CurSign == eCoinSign.PlayerXKing) || (i_CurSign == eCoinSign.PlayerOKing))
        {
            v_CanMove = checkIfMustToEatUpToDown(i_CurOwner, i_Row, i_Col) || checkIfMustToEatDownToUp(i_CurOwner, i_Row, i_Col) || checkIfExistRegularMoveAndFillMovesList(i_Row, i_Col);
        }

        return(v_CanMove);
    }