Пример #1
0
        private void btnPlay2_Click(object sender, EventArgs e)
        {
            //
            btnPlay2.Visible = false;
            //init
            Node init = initialState2();

            //
            //test
            Hanoi.State goalTest = new Hanoi.State(new int[] { }, new int[] { }, new int[] { 3, 2, 1, 0 });
            //
            //            //
            var limit = (int)Math.Pow(2, goalTest.Pegs[2].Count) - 1;

            //
            //
            lblDLS.Text = "SOLVED";
            Node goal = Hanoi.Program.DLS(init, goalTest, limit);
            //
            var solutionPath = Hanoi.Action.getSolutionPath(goal);

            //

            //for easy access using pointers
            FlowLayoutPanel[] pegs = { peg02, peg12, peg22 };
            //
            play(solutionPath, pegs);
        }
Пример #2
0
        private void btnPlay_Click(object sender, EventArgs e)
        {
            //
            btnPlay.Visible = false;
            //
            Node initState = initialState();

            //
            //goal state
            Hanoi.State goalTest = new Hanoi.State(new int[] { }, new int[] { }, new int[] { 2, 1, 0 });
            //
            //
            Node goal = Hanoi.Program.BFS(initState, goalTest);
            //
            var solutionPath = Hanoi.Action.getSolutionPath(goal);

            //
            //visualize
            //
            FlowLayoutPanel[] pegs = { peg0, peg1, peg2 };
            //
            play(solutionPath, pegs);
        }