示例#1
0
        public void QuoridorGame_Do()
        {
            #region 配置初始棋盘
            //NowGame.QuoridorEva.ThisChessBoard.ChessBoardAll[0, 3].GridStatus = Grid.GridInsideStatus.Empty;
            //NowGame.QuoridorEva.ThisChessBoard.ChessBoardAll[1, 3].GridStatus = Grid.GridInsideStatus.Have_Player1;
            //NowGame.QuoridorEva.ThisChessBoard.ChessBoardAll[6, 3].GridStatus = Grid.GridInsideStatus.Empty;
            //NowGame.QuoridorEva.ThisChessBoard.ChessBoardAll[5, 3].GridStatus = Grid.GridInsideStatus.Have_Player2;

            //NowGame.QuoridorEva.ThisChessBoard.ChessBoardAll[1, 3].IfUpBoard = true;
            //NowGame.QuoridorEva.ThisChessBoard.ChessBoardAll[1, 4].IfUpBoard = true;
            //NowGame.QuoridorEva.ThisChessBoard.ChessBoardAll[6, 2].IfUpBoard = true;
            //NowGame.QuoridorEva.ThisChessBoard.ChessBoardAll[6, 3].IfUpBoard = true;

            ////NowQuoridor.ThisChessBoard.ChessBoardAll[2, 3].IfLeftBoard = true;
            ////NowQuoridor.ThisChessBoard.ChessBoardAll[3, 3].IfLeftBoard = true;
            ////NowQuoridor.ThisChessBoard.ChessBoardAll[2, 4].IfLeftBoard = true;
            ////NowQuoridor.ThisChessBoard.ChessBoardAll[3, 4].IfLeftBoard = true;

            //NowGame.QuoridorEva.ThisChessBoard.NumPlayer1Board = 16 - 2;
            //NowGame.QuoridorEva.ThisChessBoard.NumPlayer2Board = 16 - 2;


            //NowGame.QuoridorEva.ThisChessBoard.Player1Location = new Point(1, 3);
            //NowGame.QuoridorEva.ThisChessBoard.Player2Location = new Point(5, 3);
            #endregion
            BlackBoardNumLB.Text = NowGame.QuoridorEva.ThisChessBoard.NumPlayer2Board.ToString();
            WhiteBoardNumLB.Text = NowGame.QuoridorEva.ThisChessBoard.NumPlayer1Board.ToString();

            //刷新初始棋盘
            NowGame.QuoridorEva.ThisChessBoard.DrawNowChessBoard(ref Gr, ChessWhitePB, ChessBlackPB);
            ChessBoardPB.Refresh();

            EnumNowPlayer NowPlayer = EnumNowPlayer.Player1;
            while (true)
            {
                string Hint = NowGame.DoOncePolicy(ref NowPlayer);
                if (Hint == "Player1 Success!" || Hint == "Player2 Success!")
                {
                    NowGame.QuoridorEva.ThisChessBoard.DrawNowChessBoard(ref Gr, ChessWhitePB, ChessBlackPB);
                    ChessBoardPB.Refresh();
                    MessageBox.Show(Hint);
                    System.Environment.Exit(0);
                    break;
                }
                else if (Hint != "OK")
                {
                    TestTB.Text = Hint;
                    #region 取消放置挡板
                    IfPlaceBoard = false;
                    if (NowPlayer == EnumNowPlayer.Player1)
                    {
                        PlayerNowAction = NowAction.Action_Move_Player1;
                    }
                    if (NowPlayer == EnumNowPlayer.Player2)
                    {
                        PlayerNowAction = NowAction.Action_Move_Player2;
                    }
                    PlaceVerticalBoardBTN.Enabled   = true;
                    PlaceHorizontalBoardBTN.Enabled = true;

                    IfShowFollow      = false;
                    VBoardPB.Visible  = false;
                    VBoardPB.Location = new Point(837, 569);
                    HBoardPB.Visible  = false;
                    HBoardPB.Location = new Point(837, 569);
                    #endregion
                    continue;
                }
                #region 取消放置挡板
                IfPlaceBoard = false;
                if (NowPlayer == EnumNowPlayer.Player1)
                {
                    PlayerNowAction = NowAction.Action_Move_Player1;
                }
                if (NowPlayer == EnumNowPlayer.Player2)
                {
                    PlayerNowAction = NowAction.Action_Move_Player2;
                }
                PlaceVerticalBoardBTN.Enabled   = true;
                PlaceHorizontalBoardBTN.Enabled = true;

                IfShowFollow      = false;
                VBoardPB.Visible  = false;
                VBoardPB.Location = new Point(837, 569);
                HBoardPB.Visible  = false;
                HBoardPB.Location = new Point(837, 569);
                #endregion
                if (NowPlayer == EnumNowPlayer.Player2 && NowGame.P1Type == QuoridorGame.Enum_PlayerType.AI)
                {
                    NowGame.PolicyRootNodeList.Add(NowGame.NodeToTreeView);
                }
                else if (NowPlayer == EnumNowPlayer.Player1 && NowGame.P2Type == QuoridorGame.Enum_PlayerType.AI)
                {
                    NowGame.PolicyRootNodeList.Add(NowGame.NodeToTreeView);
                }
                TestTB.Text = Hint;
                NowGame.QuoridorEva.ThisChessBoard.DrawNowChessBoard(ref Gr, ChessWhitePB, ChessBlackPB);
                ChessBoardPB.Refresh();
                #region 更新状态提示界面
                if (NowPlayer == EnumNowPlayer.Player1)
                {
                    ActionPlayerLabel.Text = "白子";
                    BlackBoardNumLB.Text   = NowGame.QuoridorEva.ThisChessBoard.NumPlayer2Board.ToString();
                    WhiteBoardNumLB.Text   = NowGame.QuoridorEva.ThisChessBoard.NumPlayer1Board.ToString();
                }
                if (NowPlayer == EnumNowPlayer.Player2)
                {
                    ActionPlayerLabel.Text = "黑子";
                    BlackBoardNumLB.Text   = NowGame.QuoridorEva.ThisChessBoard.NumPlayer2Board.ToString();
                    WhiteBoardNumLB.Text   = NowGame.QuoridorEva.ThisChessBoard.NumPlayer1Board.ToString();
                }
                #endregion
            }
        }
示例#2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Form1.CheckForIllegalCrossThreadCalls = false;
            AllocConsole();
            this.Size = new System.Drawing.Size(1024, 720);
            _FormDraw FD = new _FormDraw();

            QueenList.Add(Queen1PB);
            QueenList.Add(Queen2PB);
            QueenList.Add(Queen3PB);
            QueenList.Add(Queen4PB);
            QueenList.Add(Queen5PB);
            QueenList.Add(Queen6PB);
            QueenList.Add(Queen7PB);
            QueenList.Add(Queen8PB);

            foreach (CCWin.SkinControl.SkinPictureBox SPB in QueenList)
            {
                SPB.Size = new Size(58, 58);
                ChessBoardPB.Controls.Add(SPB);
                SPB.Visible   = false;
                SPB.BackColor = Color.Transparent;
                QueenChessLocation.Add(new Point(-1, -1));
            }

            QueenChessList.Add(QueenChess1PB);
            QueenChessList.Add(QueenChess2PB);
            QueenChessList.Add(QueenChess3PB);
            QueenChessList.Add(QueenChess4PB);
            QueenChessList.Add(QueenChess5PB);
            QueenChessList.Add(QueenChess6PB);
            QueenChessList.Add(QueenChess7PB);
            QueenChessList.Add(QueenChess8PB);

            foreach (CCWin.SkinControl.SkinPictureBox SPB in QueenChessList)
            {
                SPB.Size = new Size(58, 58);
                ChessBoardPB.Controls.Add(SPB);
                SPB.Visible   = false;
                SPB.BackColor = Color.Transparent;
            }

            if (GameMode == GameModeStatus.DoublePlay || GameMode == GameModeStatus.SinglePlay)
            {
                //this.Text = "步步为营游戏_" + GameMode.ToString() + "模式_上海海事大学";
                this.Text = "步步为营游戏_" + "单人游戏" + "模式_上海海事大学";

                RandomPlaceBTN.Dispose();
                CustomPlaceBTN.Dispose();
                Test2BTN.Dispose();

                ChessBoardPB.Size  = new Size(630, 630);
                ChessBoardPB.Image = Resource1.qipan;
                Gr = Graphics.FromImage(ChessBoardPB.Image);
                FD.DrawChessBoard(Gr, 630, 630, 10, 83.5F);

                ChessWhitePB.Size = new Size(58, 58);
                ChessBoardPB.Controls.Add(ChessWhitePB);
                ChessWhitePB.Location  = new Point(0, 0);
                ChessWhitePB.BackColor = Color.Transparent;
                ChessBlackPB.Size      = new Size(58, 58);
                ChessBoardPB.Controls.Add(ChessBlackPB);
                ChessBlackPB.Location  = new Point(100, 100);
                ChessBlackPB.BackColor = Color.Transparent;

                ChessWhitePB.Location = FD.DrawChess(Gr, 0, 3, Color.White);
                ChessBlackPB.Location = FD.DrawChess(Gr, 6, 3, Color.Black);

                VBoardPB.Size = new System.Drawing.Size(10, 170);
                HBoardPB.Size = new System.Drawing.Size(170, 10);

                HideQueen(QueenList);

                TestTB.Location = new Point(ChessBoardPB.Location.X, ChessBoardPB.Size.Height + ChessBoardPB.Location.Y);
                #region 打开DebugView窗体
                //IfOpenDebugViewForm = true;
                Rectangle rect = new Rectangle();
                rect = Screen.GetWorkingArea(this);

                DV      = new DebugView();
                DV.Size = new System.Drawing.Size(rect.Width, rect.Height);
                DV.Show();
                #endregion

                #region 配置算法选择控件
                ConfigTabPageInit();
                #endregion
                Console.WriteLine("棋盘HashCode为:" + GameTreeNode.InitChessBoardHashCode.ToString());
            }
            else
            {
                this.Text = "八皇后路径寻优仿真平台_上海海事大学";

                FD.DrawChessBoard(Gr, 630, 630, 7, 74.5F);

                ChessBoardPB.Size  = new Size(630, 630);
                ChessBoardPB.Image = Resource1.qipan2019;
                Gr = Graphics.FromImage(ChessBoardPB.Image);

                ChessWhitePB.Dispose();
                ChessBlackPB.Dispose();
                PlaceVerticalBoardBTN.Dispose();
                PlaceHorizontalBoardBTN.Dispose();
                TestBTN.Dispose();

                ConfigTabControl.Visible = false;
                ConfigTabControl.Enabled = false;
                TestTB.Visible           = false;
                skinToolStrip1.Visible   = false;
                skinToolStrip1.Enabled   = false;

                ChessBoardPB.Refresh();

                //this.Location = new Point(0, 0);
                DT = new DebugTool(this);
                //DT1.Location = new Point(this.Size.Width, 0);
                DT.Show();
            }
        }