Comments (1)
Hi cidic,
Yeah, this should work fine for hex grids as well -- the main thing that differs between a square grid and a hex grid is the number of neighboring cells each cell has. Right now, there is no built-in implementation of hex grids, but it's trivial to add (designed that way!). If you look at the Quick Start Recipes under I want to find the shortest distance between 10 points on a grid, you'll see mention of creating a class that extends crow.GridNode
. This is what you'd do if you had a square grid; however, since you don't, you'll want to instead subclass crow.Node
and implement the "abstract" methods in that class -- you can follow GridNode as an example. Do note you'll have to compile CrowLib yourself -- I don't think you'll be able to make use of the prebuilt minified library. The documentation on this particular task is admittedly not great, so I'll give you a couple pointers here:
- getNeighbors does exactly what it sounds like -- returns an array of adjacent cells. It accepts a graph, and you call graph.getNode on it as much as you need to populate the array.
- distanceToNeighbor returns the actual distance between two adjacent cells.
- distanceToGoal returns the estimated distance to the goal; doesn't have to be 100% accurate, but know that the algorithms will often be trying to minimize this value in order to make progress towards the goal.
Let me know if you have other questions.
from crowlib.
Related Issues (18)
- Algorithm autoselection HOT 1
- ConnectedNode missing when using crow.mini.js built with rake HOT 1
- Doesn't build with Ruby 1.9 HOT 1
- calcdeps.py is deprecated
- Node.js Support
- Deletion of connected edges or vertices
- Missing deps.js for crow.mini.js
- Array.prototype.shuffle HOT 10
- Code preprocessing HOT 2
- Rewrite to remove Google Closure integration
- LPA* HOT 1
- Perf tests broken HOT 1
- Provide better tutorial, specifically info about getting Crow on the page HOT 1
- Better visualization examples
- Make Crow work better with non-grid use cases HOT 2
- Implement BFS-as-shortest-path algorithm HOT 3
- Implement DFS
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 crowlib.