cs-path-finding 1.0.1

Dijstra and Astar Path Finding

There is a newer version of this package available.
See the version list below for details.
Install-Package cs-path-finding -Version 1.0.1
dotnet add package cs-path-finding --version 1.0.1
<PackageReference Include="cs-path-finding" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add cs-path-finding --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

cs-path-finding

Path Finding library with Dijstra, A*

Install

Run the following command to install nuget package:

Install-Package cs-path-finding

Usage

The sample code below shows how to use the Dijstra Path finding:

using System;
using System.Collections.Generic;

namespace PathFinding
{
    class Program
    {
        static void Main(string[] args)
        {
            Random random = new Random();
            QuadTree space = new QuadTree(new Rectangle(0, 0, 2000, 2000));
            GridWorld pathFinder = new GridWorld(space);

            FVec2 target = new FVec2(1000, 1000);
            List<IAgent> population = new List<IAgent>();
            for (int i = 0; i < 10; ++i)
            {
                IAgent agent = new SimpleAgent(space);
                float y = 0; // vertical position
                float x = random.Next(2000);
                float z = random.Next(2000);
                agent.Position = new FVec3(x, y, z);
                agent.AgentID = i + 1;
                population.Add(agent);
            }

            for (int steps = 0; steps < 20; ++steps)
            {
                Dijstra paths = pathFinder.dijstra(target);

                foreach (IAgent agent in population)
                {
                    float y = 0; // vertical position
                    float x = random.Next(2000);
                    float z = random.Next(2000);
                    agent.Position = new FVec3(x, y, z);
                    List<FVec3> path = paths.GetPath(agent);
                    Console.WriteLine("Path for agent #{0} in step {1}: {2} navigation points", 
                        agent.AgentID, steps+1, path.Count);
                }

                target = new FVec2(random.Next(2000), random.Next(2000));
            }

        }
    }
}

cs-path-finding

Path Finding library with Dijstra, A*

Install

Run the following command to install nuget package:

Install-Package cs-path-finding

Usage

The sample code below shows how to use the Dijstra Path finding:

using System;
using System.Collections.Generic;

namespace PathFinding
{
    class Program
    {
        static void Main(string[] args)
        {
            Random random = new Random();
            QuadTree space = new QuadTree(new Rectangle(0, 0, 2000, 2000));
            GridWorld pathFinder = new GridWorld(space);

            FVec2 target = new FVec2(1000, 1000);
            List<IAgent> population = new List<IAgent>();
            for (int i = 0; i < 10; ++i)
            {
                IAgent agent = new SimpleAgent(space);
                float y = 0; // vertical position
                float x = random.Next(2000);
                float z = random.Next(2000);
                agent.Position = new FVec3(x, y, z);
                agent.AgentID = i + 1;
                population.Add(agent);
            }

            for (int steps = 0; steps < 20; ++steps)
            {
                Dijstra paths = pathFinder.dijstra(target);

                foreach (IAgent agent in population)
                {
                    float y = 0; // vertical position
                    float x = random.Next(2000);
                    float z = random.Next(2000);
                    agent.Position = new FVec3(x, y, z);
                    List<FVec3> path = paths.GetPath(agent);
                    Console.WriteLine("Path for agent #{0} in step {1}: {2} navigation points", 
                        agent.AgentID, steps+1, path.Count);
                }

                target = new FVec2(random.Next(2000), random.Next(2000));
            }

        }
    }
}

Release Notes

Dijstra and Astar Path Finding in .NET 4.6.1

Dependencies

This package has no dependencies.

Version History

Version Downloads Last updated
1.0.2 336 4/29/2018
1.0.1 301 4/29/2018