示例#1
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
        }
示例#2
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
        }