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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:37:17+00:00 2026-06-03T05:37:17+00:00

So, I’m working with A* Pathfinding . I got it working however it doesn’t

  • 0

So, I’m working with A* Pathfinding. I got it working however it doesn’t work all the way. It works all the way until the last 4 columns to the right. Weird.

It works all the way until X is 10 or less. Which is weird because Y‘s max is 10. Maybe it’s together? I don’t know. But my map is 15 columns by 10 rows. Here is an online example: http://mystikrpg.com/html5/

An interesting error I get is Uncaught TypeError: Cannot read property '8' of undefined.

The 8 is the Y of where you clicked. If you click a the very first gray block on the right-side (since row 0 is walled off). Then that 8 would say 1.

Here’s the part where it lays out the nodes.

// Creates a Graph class used in the astar search algorithm.
function Graph(grid) {
    var nodes = [];

    var row, rowLength, len = grid.length;

            for (x = 0; x <= 10; x++) {
             row = grid[x];
             nodes[x] = new Array(15);
                for (y = 0; y <= 15; y++) {
                   nodes[x][y] = new GraphNode(x, y, row[y]); 
                }
            }

    this.input = grid;
    this.nodes = nodes;
}

However, you can download it offline and put it on localhost, if you’d like here http://mystikrpg.com/html5/Ethios.rar

Anyway… something else I found:

My loadMap() function returns an array of 11 elements.

And when x_block is 13 (clicking on X axis of map) for example, graph.nodes[x_block][y_block] returns undefined.

Here is my loadMap() function:

    function loadMap(map) {
        if (map == 1) {
            return [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 
[1, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 1], 
[1, 13, 1, 13, 13, 13, 13, 13, 1, 1, 1, 1, 1, 13, 13, 1], 
[1, 13, 1, 1, 13, 1, 1, 13, 1, 13, 13, 1, 13, 13, 13, 1], 
[1, 13, 13, 1, 1, 1, 13, 13, 1, 13, 13, 1, 1, 1, 13, 1], 
[1, 13, 13, 1, 13, 1, 13, 13, 13, 13, 13, 1, 13, 13, 13, 1], 
[1, 13, 13, 13, 13, 1, 13, 13, 13, 13, 13, 1, 13, 13, 13, 1], 
[1, 13, 1, 13, 13, 13, 13, 13, 1, 1, 1, 1, 13, 13, 13, 1], 
[1, 13, 1, 1, 1, 1, 13, 13, 13, 13, 1, 13, 13, 13, 13, 1], 
[1, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 1], 
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]];
        }
    }

As you can see, it’s 15 columns across and 10 rows down.

What am I doing wrong?

UPDATE NEW

for (y = 0; y <= 10; y++) {

    row = grid[y];
    nodes[y] = new Array(15);

    for (x = 0; x <= 15; x++) {

        console.log("X: " + x + " Y: " + y);
        //console.log("Row: " + row[x]);
        nodes[x][y] = new GraphNode(x, y, row[x]);
    }
}
  • 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-03T05:37:18+00:00Added an answer on June 3, 2026 at 5:37 am

    You have your x and y nomenclature the wrong way around.

    The x axis should be the second dimension in your table, e.g. nodes[y][x]:

    for (y = 0; y <= 10; x++) {
        row = grid[y];
        nodes[y] = [];
        for (x = 0; x <= 15; x++) {
            nodes[y][x] = new GraphNode(x, y, row[y]); 
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
i got an object with contents of html markup in it, for example: string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.