Exemplo n.º 1
0
        private void button8_Click(object sender, EventArgs e)
        {
            label1.Text = "Solving ...";

            Queue <park> Q = new Queue <park>();

            Q.Enqueue(p1);

            searchResults r = parkSpaceLogic.SpaceSearch2(Q);

            if (r.solutions.Count == 0)
            {
                MessageBox.Show("No solutions found!", "Error");

                return;
            }

            searchResults r2 = parkSpaceLogic.SpaceSearch2(r.solutions);

            int current_steps_to_sol = r2.D[p1.GetHashCode()];

            int moveCount = 0;

            while (current_steps_to_sol > 0)
            {
                moveCount++;

                movesList L = parkLogic.generateMoves2(p1);

                for (int i = 0; i < L.count; i++)
                {
                    park p2 = p1.Clone();

                    p2 = parkLogic.makeMove2(p2, L.car_ind[i], L.dir[i]);

                    int steps_to_sol = r2.D[p2.GetHashCode()];

                    if (steps_to_sol < current_steps_to_sol)
                    {
                        current_steps_to_sol = steps_to_sol;

                        p1 = parkLogic.makeMove2(p1, L.car_ind[i], L.dir[i]);

                        pictureBox1.Refresh();

                        Application.DoEvents();

                        System.Threading.Thread.Sleep(250);

                        break;
                    }
                }
            }

            label1.Text = "Done1";
        }
Exemplo n.º 2
0
        public void listMoves(movesList l, ListBox lb)
        {
            lb.Items.Clear();

            for (int i = 0; i < l.count; i++)
            {
                string res = "car " + (l.car_ind[i] + 1).ToString() + " by " + l.dir[i].ToString();

                lb.Items.Add(res);
            }
        }
Exemplo n.º 3
0
    void Awake()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(gameObject);
        }
        else
        {
            Instance = this;
        }

        populateList();
    }