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 9226269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:47:21+00:00 2026-06-18T04:47:21+00:00

For pathfinding in a small 2D game I use an A* algorithm, by now

  • 0

For pathfinding in a small 2D game I use an A* algorithm, by now based on a simple euclidean distance heuristic. My game world is represented as a grid of cells, either occuppied by an obstacle or not. The character for which a path has to be calculated using A* can move in any direction (if not blocked), not only N/E/S/W.

Ok, so that basically works fine. Now I need to add another parameter to the A* heuristic function, a cost value tied to each grid cell. The higher this cost value, the more our character should try to avoid that cell.

However, I can’t change the heuristic function to solely use this cost value per grid cell, because the cell’s distance to the A* target location is still important. The character should try to avoid any high cost cells, but at the same time it also must not get too far away from the target position. I therefore need kind of a “trade off” between the cell’s distance and its cost value.

Ideally, I would like to find a solution that allows me to easilly adjust/optimize such a relation between the cell’s distance and its cost value, so that I can fine tune the heuristic.

Any ideas how to achieve this?

  • 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-06-18T04:47:22+00:00Added an answer on June 18, 2026 at 4:47 am

    When you use any shortest path algorithm (A* or Dijkstrs) you need one cost value for each node.
    So you must think yourself a formula how to combine distance (your cells) with obstacle costs.
    You could create a cost() function which takes the length cost plus adds obstacle costs.

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

Sidebar

Related Questions

I'm in the process of developing a simple 2d grid based sim game, and
I am developing a game and implemented pathfinding algorithm. My pathfinding returns me a
I am developing a pathfinding algorithm for an Android game, and I can write
I'm using a A* pathfinding script in a simple JavaScript 2D (canvas) game. I
I'm using a A* pathfinding script in a simple JavaScript 2D (canvas) game. I
I am doing pathfinding on a 2D grid. I need to calculate distance as
So, I have a simple pathfinding algorithm which precalculates the shortest route to several
I'm using a A* pathfinding script in a simple JavaScript 2D (canvas) game. I
I'm using a A* pathfinding script in a simple JavaScript. I broke my game
I'm developing a small game in python. I am using a 2D rectangular grid.

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.