Giter VIP home page Giter VIP logo

Comments (5)

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

Hey @rm-code,

Previous version of this library used abstract units. (A grid cell was '1' unit wide and '1' unit high.) Traversing a cell would have a cost. Also an abstract unit. The path finding algorithm tried to find a path with the lowest cost. Unfortunately it was very hard to reason how cost would affect the path, since all these abstract units are not found in real life.

Because of this the latest version uses real units. A cell has a certain size. (For example it is 10 meters wide, or maybe 2 kilometers wide, whatever fits your game) and cells are connected through edges, which go from the center of one cell, to the center of another cell. Each edge has a speed limit. You could see these edges like a road, with a speed limit. Some roads are municipal roads and some roads are highways.

This makes it easier to reason about paths in an intuitive way. A direct route over a dirt road might not always be faster than an indirect route over a highway. The path finding algorithm tries to find the path that takes the least amount of time.

In your rogue-like everything also has a size. You might be using abstract units. But I could image that a single grid cell in your game's grid can hold a large monster. So we could use a cellSize of 2 by 2 meters. Your monster might have a normal walking speed on paved ground. We could take 5KM/h (https://en.wikipedia.org/wiki/Preferred_walking_speed) as the default traversal velocity. Now some grid cells might be difficult terrain, maybe they are covered with ice. You could set the traversal velocity of these cells to a lower value. Maybe 2KM/h.

I hope this helps thinking about how you should set up this library to work for you. Does this help? Or do you have more questions? Feel free to ask them here. I will check regularly :).

from astar.

bradzoob avatar bradzoob commented on July 28, 2024 1

Oooh new version! Thanks Roy! "Like A Bishop, Like A Queen" best GitHub lyrics 2020.

from astar.

rm-code avatar rm-code commented on July 28, 2024

@roy-t Thanks for the thorough explanation, but I'm still not sure how I would translate your system to my (indeed) abstract units. Let's say I have the following situation

The Character is standing in front of a door + and wants to move to the empty tile .
C + .

Opening the door costs 3 AP, moving onto the door tile and to the empty tile costs two more AP so all in all this would cost 5 AP.

How would I set your library up to get this information? Is it possible at all?

from astar.

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

@rm-code ah that makes your question a lot clearer. I think I would solve it like this:

Let's think of AP as a measure for 'how many seconds it takes to perform an action'. And let's define that every tile is 1 by 1 meters long.

Traversing a normal tile costs 2 AP which is 2 seconds. So the traversal velocity of a normal tile is 1/2 meter per second. Traversing a tile that has a closed door on it takes 3AP (for opening the door) + 2AP for traversing the tile the door is on), so 5 seconds. So the traversal velocity of a tile with a closed door is 1/5 meter per second.

Using this logic the path finding algorithm will generate the fastest path, and the units make sense.

If you prefer to use cost instead of velocity you can always try downloading version 2.1.0. It is slightly less fast than this version. (see the benchmark history) but I doubt that you would notice the difference in a rogue like.

from astar.

rm-code avatar rm-code commented on July 28, 2024

Thank you, I'll try it out 👍

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.