示例#1
0
        private void button3_Click(object sender, EventArgs e)
        {
            // A Star
            AStar astar = new AStar();

            //Model.Point src = new Model.Point(1,1);

            if (this.src == null)
            {
                //Model.Point src = new Model.Point(1, 1);
            }

            Model.Point dest = this.goal;
            this.tileMap[dest.X, dest.Y] = 0;
            var         sw   = Stopwatch.StartNew();
            List <Node> path = astar.Search(this.tileMap, this.src, dest, xx1 - 1, yy2 - 1);

            sw.Stop();
            label8.Text = $"Time: {sw.Elapsed.TotalMilliseconds}ms";
            label2.Text = $"Path length: {path.Count}";
            foreach (var p in path)
            {
                this.tileMap[p.X, p.Y] = 2;
            }
            Refresh();
        }
示例#2
0
        private void button6_Click(object sender, EventArgs e)
        {
            // JPS
            JPS jps = new JPS();

            Model.Point src = new Model.Point(1, 1);

            Model.Point dest = new Model.Point(20, 1);
            this.tileMap[dest.X, dest.Y] = 0;

            List <Node> path = jps.Search(this.tileMap, src, dest, 99, 99);

            foreach (var p in path)
            {
                this.tileMap[p.X, p.Y] = 2;
                this.pathPlan.Add(new Point(p.X, p.Y));
            }
            Refresh();
        }