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

  • SEARCH
  • Home
  • 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 6350843
In Process

The Archive Base Latest Questions

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

My AS3 A* pathfinding implementation sometimes doesn’t returns the most efficient route, rather like

  • 0

My AS3 A* pathfinding implementation sometimes doesn’t returns the most efficient route, rather like this:

[E][X][ ][ ][ ]
[.][X][.][.][ ]
[ ][.][ ][i][S]

(where . is the node walked, and X is walls. S = start, E = end, i = my imaginary marker)

The problem: i should have a total score of (distance to end) 30 + (distance from start) 10 = 40, while the tile above i should have a total score of (distance to end) 40 + (distance from start) 14 = 54. Why is 54 being picked instead of 40, I don’t know – I use this to find the node with lowest total score on the open list:

        var lowestTScore:int = 10000;
        var pointerTo:PathNode;
        for each (var Cur:PathNode in openList) {
            //loops through each node in openlist and finds the one with lowest total score.
            if (Cur.distS + Cur.distE < lowestTScore) {
                lowestTScore = Cur.distS + Cur.distE;
                pointerTo = Cur;
            }
        }

(which I can’t see any problems with.)

I thought, maybe it’s a error with me calculating distance to the end. So I checked my code for that:

theNode.distE = (Math.abs(theNode.xpos - endPts[0]) + Math.abs(theNode.ypos - endPts[1])) * 10;

(which, again I can’t see any problems with.)

I’m really stumped on this.

Main.as: http://pastebin.com/ZKQJwY4S
PathSearcher:as: http://pastebin.com/KnmWGbQw

(I understand that it is better to post directly the problem code, but I don’t know where is the problem code 🙁 Sorry)

Thanks for any help!

  • 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-24T21:53:20+00:00Added an answer on May 24, 2026 at 9:53 pm

    Found the problem! I didn’t add

        theNode.distS = theNode.parentNode.distS + cost;
    

    when changing parents of theNode. I only changed parentNode, but not the distS score.

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

Sidebar

Related Questions

the e4x implementation in as3 doesn't seem to be able to handle node names
In AS3, from a division I get a number like this one: 0.9130406010219044. Is
I have movieClip (in as3) and I'd like to know is this movieClip playing
In AS3 you have a function on a string with this signature: function replace(pattern:*,
In AS3 I can write this[foo] for access to a variable foo . I
This AS3 function works for normal methods and getter methods: public function MyClassTestAPI(functionName:String, ...rest):*
I stumbled accroos the AS3 to JS compiler Jangaroo , which looks like it
AS3 Webservice I'm using this library to connect to a database where I store
In AS3, I know how to accomplish this. One needs only to click ActionScript
I'm low level as3 programmer and I need help whit this code: I have

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.