Giter VIP home page Giter VIP logo

Comments (3)

roy-t avatar roy-t commented on July 28, 2024 1

Ah, yes that is indeed the correct way. This comes because the actual library is based on nodes and edges, not a grid. The grid class is just an abstraction above it to help users with the common case of a grid. In this case that abstraction leaks through. Glad you have figured this out. I'll make a note of this and will see if in the next version I can make using grids more logical.

from astar.

roy-t avatar roy-t commented on July 28, 2024

Hey thanks for your question.

If I understand you correctly a connect method will connect that one node to all its neighbors. That is a bit problematic since some users want only lateral connections, or only diagonal, or both. While disconnect just disconnects everything.

I could create utility methods for connect for a few logical combinations. Just like I did for creating a grid. I just never thought about it. Do you think it would be useful to have those in the library?

Of course you can for now implement it using AddEdge several times. Or are you running into problems there?

from astar.

dch-GH avatar dch-GH commented on July 28, 2024

Hey thanks for your question.

If I understand you correctly a connect method will connect that one node to all its neighbors. That is a bit problematic since some users want only lateral connections, or only diagonal, or both. While disconnect just disconnects everything.

I could create utility methods for connect for a few logical combinations. Just like I did for creating a grid. I just never thought about it. Do you think it would be useful to have those in the library?

Of course you can for now implement it using AddEdge several times. Or are you running into problems there?

Thank you getting back to me!

Yes, I have stumbled into understanding how to use AddEdge to sort of get it working.

Feel free to tell me if this is not how I should be using AddEdge.

			var targetNode = Grid.GetNode( gridPos );
			var targetNodePosition = ToGrid( targetNode.Position );
			var neighbors = GetNeighbors( targetNode, true );

			foreach ( var n in neighbors )
			{
                                // Neighbors can be null at the edges of the map.
				if ( n is null )
					continue;

				var neighborPos = ToGrid( n.Position );
				Grid.AddEdge( targetNodePosition, neighborPos, Velocity.FromKilometersPerHour( 100 ) );
			}

I'm essentially trying to have the ability to tell the library that a node is not considered "walkable" and to flip that flag when I want (adding/removing obstacles). I figure Connecting/Disconnecting the Nodes I want to do that to is the idiomatic way. If such utility methods would make that easier for me, then yes I would definitely appreciate that.

from astar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.