Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Mapping paths?...

by DrZaius (Monk)
on May 17, 2001 at 22:27 UTC ( [id://81327]=note: print w/replies, xml ) Need Help??


in reply to Mapping paths?...

You should probably use a hash instead of an array for your coordinates. If I remember correctly, if you have an index of 100 as your first entry, perl will create @array[0..99] as well as $array[100].

Although, you may have all the entries in your grid filled in anyway :)

I imagine the best way to calculate the path would be determine the slop of the line between the two points and try plotting until you get there.

If that isn't the best way, I imagine the solution does involve find slopes between two points in fragments.

good luck.

Replies are listed 'Best First'.
Re: Re: Mapping paths?...
by no_slogan (Deacon) on May 17, 2001 at 22:48 UTC
    If you're using the "Manhattan metric" (each step north, south, east, or west counts as one unit of distance) as seems likely in this case, the slope isn't going to be useful for reducing the distance. OTOH, if the grid is mostly unobstructed, Dijkstra's will try to search outward in a diamond pattern, which could be a lot slower than something that simply tries to connect the dots. That could be important in, for example, a video game AI. Depends on what your exact requirements are.

    BTW, that prohosting website is really and truly ugly. Turn on my cookies and try again? Not likely.

      Heh, thanks :-)

      I implemented the cookie requirement because the program tracks individual browsers to enable submitted tiles to be viewed per poster, and to assign special tile colours to people, and to count the number of different visitors it gets each day.

      If you know of a way to do that without cookies or logging in, you're welcome. The target audience largely has cookies and JavaScript enabled anyway, so I figured I could get away with it. People without cookies would get a Set-cookie header with a different UNIQUE_ID every time they accessed the site (used to be only when they posted), but now, I want to be able to count the number of different browsers that access the site each day, which is a good approximation of the size of the audience, IMHO.

Re: Re: Mapping paths?...
by orkysoft (Friar) on May 18, 2001 at 16:57 UTC
    No, the co-ordinates range from 1 to 30, exactly.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://81327]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-03-28 19:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found