Comments (3)
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.
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.
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)
- Considering the size of the agent
- Finding closest path to unreachable end cell HOT 4
- Deterministic? HOT 2
- Info: v2 WIP version available on Master HOT 2
- Hidden Connect method HOT 3
- Documentation / IntelliSense support HOT 5
- Isometric Support HOT 1
- Coming to v3 HOT 3
- Path. HOT 3
- No issue just a question. HOT 3
- Saving and loading graphs HOT 7
- TODO: release new minor version with save/load changes HOT 1
- just question HOT 2
- Question: GPS coordinates HOT 3
- Question HOT 1
- Explanation on how velocity is used HOT 6
- Question : Bidirectional graph search HOT 1
- Question: obstacles HOT 3
- Discussion on algorithms HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from astar.