Esempio n. 1
0
 private void BtnOK_Click(object sender, EventArgs e)
 {
     if (checkBoxSel.Checked)
     {
         if (radioBtnSelN.Checked && !(checkBoxSwap.Checked && radioBtnSwap3.Checked))
         {
             BoardOfFIR.ShowInfo("五手N打:\n必须选中三手交换规则");
             return;
         }
         if (radioBtnSelx.Checked)
         {
             short x;
             try
             {
                 x = Convert.ToInt16(TBoxSelC.Text);
             }
             catch (Exception ex)
             {
                 MessageBox.Show("请输入一个整数", "五子棋");
                 TBoxSelC.Focus();
                 TBoxSelC.SelectAll();
                 return;
             }
             if (x > 10 || x < 2)
             {
                 MessageBox.Show("请输入一个2-10的数", "五子棋");
                 TBoxSelC.Focus();
                 TBoxSelC.SelectAll();
                 return;
             }
         }
     }
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
        protected Point FindMove()
        {
            Point move;

            searchtimes = 0;
            if (turnCount == 0)
            {
                return(new Point(7, 7));
            }
            else if (turnCount == 1)
            {
                Random rand = new Random();
                for (int i = 0; i < 15; i++)
                {
                    for (int j = 0; j < 15; j++)
                    {
                        if (board[i, j] != PieceType.Empty)
                        {
                            return(new Point(i + 1, j + 1));
                        }
                    }
                }
                return(new Point(7, 7));
            }
            else
            {
                BoardOfFIR newBd = new BoardOfFIR();
                newBd.boardCopy(this);
                Evalute e = getEvalute();
                newBd.FindBestMove(-10000, 10000, AIdepth, turn, out move, e);
                //ShowInfo(newBd.searchtimes);
            }
            return(move);
        }
Esempio n. 3
0
 private void Form1_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         Point tP = new Point();
         tP = coordinateToBd(e.X, e.Y);
         if (room.running)
         {
             return;
         }
         if (BoardOfFIR.checkP(tP))
         {
             room.select(tP);
             Invalidate();
             textBox1.Text = room.record.mainvariation.varToString();
             if (MenuItemAutoMove.Checked)
             {
                 room.AI();
             }
             ToolStripAutoRedo.Checked = false;
         }
     }
     if (e.Button == MouseButtons.Right)
     {
         if (MenuItemRightBtnUndo.Checked)
         {
             room.Undo();
             Invalidate();
         }
         else
         {
             contextMenuStrip1.Show(e.Location);
         }
     }
 }
Esempio n. 4
0
        }//返回是否成功

        public void ToBoard(BoardOfFIR board, Move move)
        {
            board.clearBoard();
            Variation v = this.TopresentVar(move);

            foreach (Move m in v.movelist)
            {
                board.setPieceType(m.getP(), (PieceType)(m.turnCount % 2));
                board.stepRecord[m.getP().X, m.getP().Y] = m.turnCount + 1;
            }
            board.setTurn(move.turnCount + 1);
        }
        public void boardCopy(BoardOfFIR formerBoard)
        {
            int i, j;

            for (i = 0; i < 15; i++)
            {
                for (j = 0; j < 15; j++)
                {
                    this.board[i, j] = formerBoard.board[i, j];
                }
            }
            turnCount = formerBoard.turnCount;
            turn      = formerBoard.turn;
        }
Esempio n. 6
0
        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            Point tP = new Point();

            tP = coordinateToBd(e.X, e.Y);
            if (room.getStatus() == Status.DeleteSel && BoardOfFIR.checkP(tP))
            {
                this.Cursor = Cursors.No;
            }
            else
            {
                this.Cursor = Cursors.Default;
            }
        }
        bool isOpenThree(Point p, direction dir, PieceType color)
        {
            int        left, right, mid;
            int        leftC, rightC;
            BoardOfFIR newBd = new BoardOfFIR();
            Point      tP;

            mid = countLine(p, dir, color, out left, out right) + 1;
            tP  = p;
            if ((fixPosition(ref tP, dir, false, left + 1) && (int)board[tP.X, tP.Y] >= 2))
            {
                leftC = countLine(tP, dir, color, false);
                if ((mid + leftC) == 3)
                {
                    newBd.boardCopy(this);
                    newBd.board[p.X, p.Y] = color;
                    if (newBd.isOpenFour(tP, dir, color) && (!newBd.isBanned(tP) || color != PieceType.Black))
                    {
                        return(true);
                    }
                }
            }
            tP = p;
            if ((fixPosition(ref tP, dir, true, right + 1) && (int)board[tP.X, tP.Y] >= 2))
            {
                rightC = countLine(tP, dir, color, true);
                if ((mid + rightC) == 3)
                {
                    newBd.boardCopy(this);
                    newBd.board[p.X, p.Y] = color;
                    if (newBd.isOpenFour(tP, dir, color) && (!newBd.isBanned(tP) || color != PieceType.Black))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }