示例#1
0
        //kiem tra xem quan 0 cua ben color co bi chieu khong
        public bool isChecked(int color)
        {
            int x1, y1;

            if (color == 1)
            {
                quan0 xanh0 = new quan0(1);
                return(xanh0.isChecked(this, out x1, out y1));
            }
            else
            {
                quan0 do0 = new quan0(2);
                return(do0.isChecked(this, out x1, out y1));
            }
        }
示例#2
0
        //tra lai true neu nhu co the phong ngu duoc, false neu nhu het co
        public bool canDefend(int color)
        {
            if (this.isChecked(3 - color))
            {
                return(true);
            }

            int   x1, y1;
            quan0 quan_0 = new quan0(color);

            if (!quan_0.isChecked(this, out x1, out y1))
            {
                return(true);
            }

            if (color == 1)
            {
                if (x1 == 4)
                {
                    //co the phong ngu duoc neu nhu an duoc quan (4, y1) hoac (4, y1-1)
                    //hoac co the di duoc quan vao o nam giua (4,1) va (4,y1-1)
                    for (int i = 0; i < 9; i++)
                    {
                        for (int j = 0; j < 11; j++)
                        {
                            if (this.getInfo(i, j) != -1 && this.getInfo(i, j) < 10 && this.getInfo(i, j) > 0)
                            {
                                quan19 quan_minh = new quan19(1, this.getInfo(i, j), i, j);
                                if (quan_minh.capture(this, 4, y1) || quan_minh.capture(this, 4, y1 - 1))
                                {
                                    return(true);
                                }
                                for (int t = 2; t <= y1 - 2; t++)
                                {
                                    if (quan_minh.move(this, 4, t))
                                    {
                                        return(true);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (y1 == 1)
                    {
                        if (x1 < 3)
                        {
                        }
                        if (x1 > 5)
                        {
                        }
                    }
                    else
                    {
                        if (y1 - x1 == 3)
                        {
                            //chan duoc neu an duoc quan(x1,y1) hoac (x1-1,y1-1)
                            //hoac co the di duoc vao o nam giua (4,1) va (x1-1,y1-1)
                        }
                        else
                        {
                            if (x1 + y1 == 5)
                            {
                                //chan duoc neu an duoc quan (x1,y1) hoac (x1+1,y1-1)
                                //hoac co the di duoc vao o nam giua (x1+1,y1-1) va (4,1)
                            }
                        }
                    }
                }
            }
            if (color == 2)
            {
                if (x1 == 4)
                {
                    //chan duoc neu an duoc quan (4,y1) hoac (4,y1+1)
                    //hoac co the di duoc vao o nam giua (4,y1+1) va (4,9)
                }
                else
                {
                    if (y1 == 9)
                    {
                        if (x1 < 3)
                        {
                        }
                        if (x1 > 5)
                        {
                        }
                    }
                    else
                    {
                        if (y1 - x1 == 5)
                        {
                            //chan duoc neu co the an duoc quan (x1,y1) hoac (x1+1,y1+1)
                            //hoac co the di duoc vao o nam giua (x1+1,y1+1) va (4,9)
                        }
                        else
                        {
                            if (x1 + y1 == 13)
                            {
                                //chan duoc neu co the an duoc quan (x1,y1) hoac (x1-1,y1+1)
                                //hoac co the di duoc vao o nam giua (4,9) va (x1-1, y1+1)
                            }
                        }
                    }
                }
            }
            return(false);
        }