Giter Club home page Giter Club logo

Comments (1)

nanodeath avatar nanodeath commented on August 24, 2024

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:

  1. 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.
  2. distanceToNeighbor returns the actual distance between two adjacent cells.
  3. 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)

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.