예제 #1
0
        private void SetBegin()
        {
            if (this.txtBegin.Text.Trim() == string.Empty || IsNum(this.txtBegin.Text.Trim()) == false)
            {
                MessageBox.Show("初始状态输入有误!");
                this.txtBegin.Focus();
                return;
            }
            if (this.txtEnd.Text.Trim() == string.Empty || IsNum(this.txtEnd.Text.Trim()) == false)
            {
                MessageBox.Show("目标状态输入有误!");
                this.txtEnd.Focus();
                return;
            }

            Dictionary <int, int> lsBegin = GetBeginEnd(this.txtBegin.Text.Trim());

            //Setting all the values of the xPuzzle array to represent the final state

            GetLableLocation(1, lsBegin[1]);
            GetLableLocation(2, lsBegin[2]);
            GetLableLocation(3, lsBegin[3]);
            GetLableLocation(4, lsBegin[4]);
            GetLableLocation(5, lsBegin[5]);
            GetLableLocation(6, lsBegin[6]);
            GetLableLocation(7, lsBegin[7]);
            GetLableLocation(8, lsBegin[8]);
            GetLableLocation(0, lsBegin[0]);

            //Setting all the values of the yPuzzle array to represent the final state
            PuzzleData.resetPuzzle(PuzzleData.xBeginPuzzle, PuzzleData.yBeginPuzzle);

            SetEnd();
        }
예제 #2
0
파일: FrmMain.cs 프로젝트: meloht/DemoCode
        private void btnReset_Click(object sender, EventArgs e)
        {
            PuzzleData.resetPuzzle();
            // SetBegin();
            UpdatePuzzle();

            DFS.resetAll();
            ProgDFS.resetAll();
            AStar.resetAll();

            lblStatus.Text = "Puzzle Reset!";
        }