Exemplo n.º 1
0
        public override void CreateMoves()
        {
            listMove = new List <Move>();
            Piece p;

            int[] dir = { -1, 1 };
            foreach (int i in dir)
            {
                foreach (int j in dir)
                {
                    int r = this.Row + i;
                    int c = this.Col + j;
                    if (r >= 0 && r <= 9 && c >= 3 && c <= 5)
                    {
                        p = Game.bBoard[r, c];
                        if (p.Trong == true || p.Color != this.Color)
                        {
                            if (BoardControl.CoQuanCheTuong(this, r, c))
                            {
                                int value = Evaluate.GetValuePiece(this, r, c);
                                listMove.Add(new Move(this, this.Row, this.Col, r, c, value));
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 public override void CreateMoves()
 {
     listMove = new List <Move>();
     int[] X = { -1, -2, -2, -1, 1, 2, 2, 1 };
     int[] Y = { -2, -1, 1, 2, 2, 1, -1, -2 };
     for (int i = 0; i < 8; i++)
     {
         int r = this.Row + X[i];
         int c = this.Col + Y[i];
         if (r >= 0 && c >= 0 && r < 10 && c < 9)
         {
             if (BoardControl.CoQuanCheTuong(this, r, c))
             {
                 if (Game.bBoard[this.Row + X[i] / 2, this.Col + Y[i] / 2].Trong == true)
                 {
                     if (Game.bBoard[r, c].Status == false)
                     {
                         int value = Evaluate.GetValuePiece(this, r, c);
                         listMove.Add(new Move(this, this.Row, this.Col, r, c, value));
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
        public override void CreateMoves()
        {
            listMove = new List <Move>();
            int startRow = 0, endRow = 9;

            if (this.Color == ECons.Color.Black)
            {
                startRow = 0;
                endRow   = 2;
            }
            else if (this.Color == ECons.Color.Red)
            {
                startRow = 7;
                endRow   = 9;
            }
            if (this.Row - 1 >= startRow && this.Col >= 3 && this.Col <= 5)
            {
                if (Game.bBoard[this.Row - 1, this.Col].Trong == true || Game.bBoard[this.Row - 1, this.Col].Color != this.Color)
                {
                    int value = Evaluate.GetValuePiece(this, this.Row - 1, this.Col);
                    listMove.Add(new Move(this, this.Row, this.Col, this.Row - 1, this.Col, value));
                }
            }
            if (this.Row + 1 <= endRow && this.Col >= 3 && this.Col <= 5)
            {
                if (Game.bBoard[this.Row + 1, this.Col].Trong == true || Game.bBoard[this.Row + 1, this.Col].Color != this.Color)
                {
                    int value = Evaluate.GetValuePiece(this, this.Row + 1, this.Col);
                    listMove.Add(new Move(this, this.Row, this.Col, this.Row + 1, this.Col, value));
                }
            }
            if (this.Col - 1 >= 3)
            {
                if (Game.bBoard[this.Row, this.Col - 1].Trong == true || Game.bBoard[this.Row, this.Col - 1].Color != this.Color)
                {
                    if (BoardControl.CoQuanCheTuong(this, this.Row, this.Col - 1))
                    {
                        int value = Evaluate.GetValuePiece(this, this.Row, this.Col - 1);
                        listMove.Add(new Move(this, this.Row, this.Col, this.Row, this.Col - 1, value));
                    }
                }
            }
            if (this.Col + 1 <= 5)
            {
                if (Game.bBoard[this.Row, this.Col + 1].Trong == true || Game.bBoard[this.Row, this.Col + 1].Color != this.Color)
                {
                    if (BoardControl.CoQuanCheTuong(this, this.Row, this.Col + 1))
                    {
                        int value = Evaluate.GetValuePiece(this, this.Row, this.Col + 1);
                        listMove.Add(new Move(this, this.Row, this.Col, this.Row, this.Col + 1, value));
                    }
                }
            }
        }
Exemplo n.º 4
0
 public override void CreateMoves()
 {
     listMove = new List <Move>();
     int[] dir = { -2, 2 };
     foreach (int i in dir)
     {
         foreach (int j in dir)
         {
             int startRow = 0, endRow = 9;
             if (this.Color == ECons.Color.Black)
             {
                 startRow = 0;
                 endRow   = 4;
             }
             else if (this.Color == ECons.Color.Red)
             {
                 startRow = 5;
                 endRow   = 9;
             }
             if (this.Row + i >= startRow && this.Row + i <= endRow && this.Col + j >= 0 && this.Col + j <= 8)
             {
                 int r = this.Row + i;
                 int c = this.Col + j;
                 if (Game.bBoard[this.Row + i / 2, this.Col + j / 2].Trong == true)
                 {
                     if (Game.bBoard[r, c].Trong == true || Game.bBoard[r, c].Color != this.Color)
                     {
                         if (BoardControl.CoQuanCheTuong(this, r, c))
                         {
                             int value = Evaluate.GetValuePiece(this, r, c);
                             listMove.Add(new Move(this, this.Row, this.Col, r, c, value));
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
        public override void CreateMoves()
        {
            listMove = new List <Move>();
            ECons.Color pheDich = ECons.Color.Red;
            if (this.Color == ECons.Color.Red)
            {
                pheDich = ECons.Color.Black;
            }

            #region Cùng cột
            int iRow = Row - 1;
            while (iRow >= 0 && Game.bBoard[iRow, Col].Trong == true)
            {
                if (BoardControl.CoQuanCheTuong(this, iRow, Col))
                {
                    int value = Evaluate.GetValuePiece(this, iRow, this.Col);
                    listMove.Add(new Move(this, this.Row, this.Col, iRow, this.Col, value));
                }
                iRow--;
            }
            if (iRow >= 0)
            {
                int i = iRow - 1;
                while (i >= 0 && Game.bBoard[i, this.Col].Trong == true)
                {
                    i--;
                }
                if (i >= 0 && Game.bBoard[i, this.Col].Color == pheDich)
                {
                    if (BoardControl.CoQuanCheTuong(this, i, this.Col))
                    {
                        int value = Evaluate.GetValuePiece(this, i, this.Col);
                        listMove.Add(new Move(this, this.Row, this.Col, i, this.Col, value));
                    }
                }
            }
            iRow = Row + 1;
            while (iRow < 10 && Game.bBoard[iRow, Col].Trong == true)
            {
                if (BoardControl.CoQuanCheTuong(this, iRow, Col))
                {
                    int value = Evaluate.GetValuePiece(this, iRow, this.Col);
                    listMove.Add(new Move(this, this.Row, this.Col, iRow, this.Col, value));
                }
                iRow++;
            }
            if (iRow < 10)
            {
                int i = iRow + 1;
                while (i < 10 && Game.bBoard[i, this.Col].Trong == true)
                {
                    i++;
                }
                if (i < 10 && Game.bBoard[i, this.Col].Color == pheDich)
                {
                    if (BoardControl.CoQuanCheTuong(this, i, this.Col))
                    {
                        int value = Evaluate.GetValuePiece(this, i, this.Col);
                        listMove.Add(new Move(this, this.Row, this.Col, i, this.Col, value));
                    }
                }
            }
            #endregion

            #region Cùng hàng
            int iCol = Col - 1;
            while (iCol >= 0 && Game.bBoard[Row, iCol].Trong == true)
            {
                if (BoardControl.CoQuanCheTuong(this, Row, iCol))
                {
                    int value = Evaluate.GetValuePiece(this, Row, iCol);
                    listMove.Add(new Move(this, this.Row, this.Col, this.Row, iCol, value));
                }
                iCol--;
            }
            if (iCol >= 0)
            {
                int i = iCol - 1;
                while (i >= 0 && Game.bBoard[this.Row, i].Trong == true)
                {
                    i--;
                }
                if (i >= 0 && Game.bBoard[Row, iCol].Color == pheDich)
                {
                    if (BoardControl.CoQuanCheTuong(this, Row, i))
                    {
                        int value = Evaluate.GetValuePiece(this, Row, i);
                        listMove.Add(new Move(this, this.Row, this.Col, this.Row, i, value));
                    }
                }
            }
            iCol = Col + 1;
            while (iCol < 9 && Game.bBoard[Row, iCol].Trong == true)
            {
                if (BoardControl.CoQuanCheTuong(this, Row, iCol))
                {
                    int value = Evaluate.GetValuePiece(this, Row, iCol);
                    listMove.Add(new Move(this, this.Row, this.Col, this.Row, iCol, value));
                }
                iCol++;
            }
            if (iCol < 9)
            {
                int i = iCol + 1;
                while (i < 9 && Game.bBoard[this.Row, i].Trong == true)
                {
                    i++;
                }
                if (i < 9 && Game.bBoard[Row, iCol].Color == pheDich)
                {
                    if (BoardControl.CoQuanCheTuong(this, Row, i))
                    {
                        int value = Evaluate.GetValuePiece(this, Row, i);
                        listMove.Add(new Move(this, this.Row, this.Col, this.Row, i, value));
                    }
                }
            }
            #endregion
        }
Exemplo n.º 6
0
        public override void CreateMoves()
        {
            listMove = new List <Move>();
            #region Black
            if (this.Color == ECons.Color.Black)
            {
                if (this.Row >= 0 && this.Row <= 4)
                {
                    Piece p = Game.bBoard[this.Row + 1, this.Col];
                    if (p.Trong == true || p.Color != this.Color)
                    {
                        if (BoardControl.CoQuanCheTuong(this, this.Row + 1, this.Col))
                        {
                            int value = Evaluate.GetValuePiece(this, this.Row + 1, this.Col);
                            listMove.Add(new Move(this, this.Row, this.Col, this.Row + 1, this.Col, value));
                        }
                    }
                }
                else if (this.Row >= 5 && this.Row <= 9)
                {
                    Piece p;
                    if (this.Row + 1 <= 9)
                    {
                        p = Game.bBoard[this.Row + 1, this.Col];
                        if (p.Trong == true || p.Color != this.Color)
                        {
                            if (BoardControl.CoQuanCheTuong(this, this.Row + 1, this.Col))
                            {
                                int value = Evaluate.GetValuePiece(this, this.Row + 1, this.Col);
                                listMove.Add(new Move(this, this.Row, this.Col, this.Row + 1, this.Col, value));
                            }
                        }
                    }
                    if (this.Col - 1 >= 0)
                    {
                        p = Game.bBoard[this.Row, this.Col - 1];
                        if (p.Trong == true || p.Color != this.Color)
                        {
                            if (BoardControl.CoQuanCheTuong(this, this.Row, this.Col - 1))
                            {
                                int value = Evaluate.GetValuePiece(this, this.Row, this.Col - 1);
                                listMove.Add(new Move(this, this.Row, this.Col, this.Row, this.Col - 1, value));
                            }
                        }
                    }
                    if (this.Col + 1 <= 8)
                    {
                        p = Game.bBoard[this.Row, this.Col + 1];
                        if (p.Trong == true || p.Color != this.Color)
                        {
                            if (BoardControl.CoQuanCheTuong(this, this.Row, this.Col + 1))
                            {
                                int value = Evaluate.GetValuePiece(this, this.Row, this.Col + 1);
                                listMove.Add(new Move(this, this.Row, this.Col, this.Row, this.Col + 1, value));
                            }
                        }
                    }
                }
            }
            #endregion

            #region Red
            else if (this.Color == ECons.Color.Red)
            {
                if (this.Row >= 5 && this.Row <= 9)
                {
                    Piece p = Game.bBoard[this.Row - 1, this.Col];
                    if (p.Trong == true || p.Color != this.Color)
                    {
                        if (BoardControl.CoQuanCheTuong(this, this.Row - 1, this.Col))
                        {
                            int value = Evaluate.GetValuePiece(this, this.Row - 1, this.Col);
                            listMove.Add(new Move(this, this.Row, this.Col, this.Row - 1, this.Col, value));
                        }
                    }
                }
                else if (this.Row >= 0 && this.Row <= 4)
                {
                    Piece p;
                    if (this.Row - 1 >= 0)
                    {
                        p = Game.bBoard[this.Row - 1, this.Col];
                        if (p.Trong == true || p.Color != this.Color)
                        {
                            if (BoardControl.CoQuanCheTuong(this, this.Row - 1, this.Col))
                            {
                                int value = Evaluate.GetValuePiece(this, this.Row - 1, this.Col);
                                listMove.Add(new Move(this, this.Row, this.Col, this.Row - 1, this.Col, value));
                            }
                        }
                    }
                    if (this.Col - 1 >= 0)
                    {
                        p = Game.bBoard[this.Row, this.Col - 1];
                        if (p.Trong == true || p.Color != this.Color)
                        {
                            if (BoardControl.CoQuanCheTuong(this, this.Row, this.Col - 1))
                            {
                                int value = Evaluate.GetValuePiece(this, this.Row, this.Col - 1);
                                listMove.Add(new Move(this, this.Row, this.Col, this.Row, this.Col - 1, value));
                            }
                        }
                    }
                    if (this.Col + 1 <= 8)
                    {
                        p = Game.bBoard[this.Row, this.Col + 1];
                        if (p.Trong == true || p.Color != this.Color)
                        {
                            if (BoardControl.CoQuanCheTuong(this, this.Row, this.Col + 1))
                            {
                                int value = Evaluate.GetValuePiece(this, this.Row, this.Col + 1);
                                listMove.Add(new Move(this, this.Row, this.Col, this.Row, this.Col + 1, value));
                            }
                        }
                    }
                }
            }
            #endregion
        }
Exemplo n.º 7
0
        public override void CreateMoves()
        {
            listMove = new List <Move>();
            #region Cùng cột
            int iRow = Row - 1;
            while (iRow >= 0 && Game.bBoard[iRow, Col].Trong == true)
            {
                if (BoardControl.CoQuanCheTuong(this, iRow, Col))
                {
                    int value = Evaluate.GetValuePiece(this, iRow, this.Col);
                    listMove.Add(new Move(this, this.Row, this.Col, iRow, this.Col, value));
                }
                iRow--;
            }
            if (iRow >= 0)
            {
                if (BoardControl.CoQuanCheTuong(this, iRow, Col))
                {
                    if (Game.bBoard[iRow, Col].Color != this.Color)
                    {
                        int value = Evaluate.GetValuePiece(this, iRow, this.Col);
                        listMove.Add(new Move(this, this.Row, this.Col, iRow, this.Col, value));
                    }
                }
            }

            iRow = Row + 1;
            while (iRow < 10 && Game.bBoard[iRow, Col].Trong == true)
            {
                if (BoardControl.CoQuanCheTuong(this, iRow, Col))
                {
                    int value = Evaluate.GetValuePiece(this, iRow, this.Col);
                    listMove.Add(new Move(this, this.Row, this.Col, iRow, this.Col, value));
                }
                iRow++;
            }
            if (iRow < 10)
            {
                if (BoardControl.CoQuanCheTuong(this, iRow, Col))
                {
                    if (Game.bBoard[iRow, Col].Color != this.Color)
                    {
                        int value = Evaluate.GetValuePiece(this, iRow, this.Col);
                        listMove.Add(new Move(this, this.Row, this.Col, iRow, this.Col, value));
                    }
                }
            }
            #endregion

            #region Cùng hàng
            int iCol = Col - 1;
            while (iCol >= 0 && Game.bBoard[Row, iCol].Trong == true)
            {
                if (BoardControl.CoQuanCheTuong(this, Row, iCol))
                {
                    int value = Evaluate.GetValuePiece(this, this.Row, iCol);
                    listMove.Add(new Move(this, this.Row, this.Col, this.Row, iCol, value));
                }
                iCol--;
            }
            if (iCol >= 0)
            {
                if (BoardControl.CoQuanCheTuong(this, Row, iCol))
                {
                    if (Game.bBoard[Row, iCol].Color != this.Color)
                    {
                        int value = Evaluate.GetValuePiece(this, this.Row, iCol);
                        listMove.Add(new Move(this, this.Row, this.Col, this.Row, iCol, value));
                    }
                }
            }

            iCol = Col + 1;
            while (iCol < 9 && Game.bBoard[Row, iCol].Trong == true)
            {
                if (BoardControl.CoQuanCheTuong(this, Row, iCol))
                {
                    int value = Evaluate.GetValuePiece(this, this.Row, iCol);
                    listMove.Add(new Move(this, this.Row, this.Col, this.Row, iCol, value));
                }
                iCol++;
            }
            if (iCol < 9)
            {
                if (BoardControl.CoQuanCheTuong(this, Row, iCol))
                {
                    if (Game.bBoard[Row, iCol].Color != this.Color)
                    {
                        int value = Evaluate.GetValuePiece(this, this.Row, iCol);
                        listMove.Add(new Move(this, this.Row, this.Col, this.Row, iCol, value));
                    }
                }
            }
            #endregion
        }