Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6200185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:19:20+00:00 2026-05-24T04:19:20+00:00

I work on a hexagon map based browser game. I have this: http://www.dark-project.cz/wesnoth/map-view/1 and

  • 0

I work on a hexagon map based browser game. I have this: http://www.dark-project.cz/wesnoth/map-view/1 and now I have a problem I want to mark the fields at which the unit can go (it has limited movement).
If the movement is 1 there isn’t any problem but if it’s higher it doesn’t work right (try it).

I work with a coordinates system http://www.dark-project.cz/wesnoth/coor.png

My actual js is here: http://www.dark-project.cz/wesnoth/js/map/base.js

In other question ( Movement algorithm on a hexagon map) @unkulunkulu recommend me to use the BFS algorithm. But I have no experience with algorythms like this and its implementing into javascript and then its use on hexagon map. He say that the BFS algorithm is better for that because I can easy expand it later (add some obstacles etc.).

If you have some link to a javascript tutorial about this or something similar it will be amazing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:19:21+00:00Added an answer on May 24, 2026 at 4:19 am

    The algotithm being suggested is roughly this:

    1. Take start square and mark it as distance 0. Add it to a list of processed hexes.

    2. Find all valid adjacent hexes (ie ones you can move into).

    3. Mark all these squares as distance 1. Add them to a list of processed hexes.

    4. Find all valid hexes adjacent to the distance 1 hexesthat are not in the processed hexes list.

    5. Mark all these squares as distance 2. Add them to a list of processed hexes.

    …

    X. Find all valid hexes adjacent to the distance N hexesthat are not in the processed hexes list.

    X+1. Mark all these squares as distance N+1. Add them to a list of processed hexes.

    The idea of the breadth first searching is that you iterate all the possibilities out from the inside so you will always find the shortest distance to each hex.

    After comments from Unkulunkulu I have rethought the best implementation for this (and may change again after further input). You should have a list of processed hexes as above and also a queue of hexes awaiting processing. The unprocessed hexes list starts with just the start hex with distance 0 and you go through this list until it is exhausted. When processing a hex all new found unprocessed hexes get added to this list with their distance in. So once you have processed the distance 0 hex you should have added all the distance 1 hexes. They get processed and by the time they are done you will have all your distance 2 hexes in there…

    For what its worth I think my original suggestion of recursion fails from an efficiency point of view and depending on the distance you want to go a potential stack overflow issue. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem on this site: http://www.dark-project.cz/wesnoth/map-view/1 (click on the unit). In my
Work on this small test application to learn threading/locking. I have the following code,
Work on C# linq.I have a list to list .From this list I want
Work on ASP.NET Visual Studio 2008 C#. I have a page. From this page
I work in VBA, and want to parse a string eg <PointN xsi:type='typens:PointN' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
I work in already compiled (in debug mode) C++ project. I have its exe
Work on asp.net vs05. I have three type of value Like:IsDesign,IsPrinting,IsInstall they are bit
Work on the following website: http://cetcolor.com The masthead graphic with the Read About It
At work I have two XP PCs. On one, I can click with the
I work on an ASP.Net project which we build with VS 2010. We use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.