[TI-BASIC] Finding a path

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Post Reply
patz2009
New Member
Posts: 17
Joined: Wed 04 Apr, 2007 10:42 pm

[TI-BASIC] Finding a path

Post by patz2009 »

Say I have a 8x16 matrix of the current map, where 0 is a walkable tile, 1 is a wall, and 9 is the character. Now, pretend the X is the target location...

Code: Select all

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 X 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1
1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1
1 0 9 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
How would I calculate the most effective (meaning taking the least number of steps) path to get to the destination?
User avatar
calc84maniac
Regular Member
Posts: 112
Joined: Wed 18 Oct, 2006 7:34 pm
Location: The ex-planet Pluto
Contact:

Post by calc84maniac »

Count up the steps. :D Or did you mean in TI-Basic... :P
~calc84maniac has spoken.

Projects:
F-Zero 83+
Project M (Super Mario for 83+)
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

Have a look at this: http://www.policyalmanac.org/games/aStarTutorial.htm

If you don't understand it (which is unlikely, it isn't that hard) I would be glad to explain how and why it works.
User avatar
Dwedit
Maxcoderz Staff
Posts: 579
Joined: Wed 15 Dec, 2004 6:06 am
Location: Chicago!
Contact:

Post by Dwedit »

Do it in ASM. Pathfinding is a very slow operation which needs to be implemented as efficiently as possible. I'd expect that kind of pathfinding to take at least 30 seconds in TI-Basic.
You know your hexadecimal output routine is broken when it displays the character 'G'.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

It's a small map, but if it gets any bigger..
well TI BASIC is just so darned slow! and all those numbers that should really be booleans are 9byte floats..
If you're going to do this in asm then I'm afraid I can no longer help (don't let that keep you though)
User avatar
JoostinOnline
Regular Member
Posts: 133
Joined: Wed 11 Jul, 2007 10:42 pm
Location: Behind You

Post by JoostinOnline »

See if you can get someone to make you a routine in asm. That way you won't have to throw out all your other code. I bet there are some people out there who would be eager to help if you offered some recognition in your credits.
"Macs are the Perfect Computers", said the Perfect Idiot.
Image
Testing for:
Vera
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

JoostinOnline wrote:See if you can get someone to make you a routine in asm. That way you won't have to throw out all your other code. I bet there are some people out there who would be eager to help if you offered some recognition in your credits.
You know, that would not be half bad. Just have the input of x,y and run the program ;)
User avatar
calc84maniac
Regular Member
Posts: 112
Joined: Wed 18 Oct, 2006 7:34 pm
Location: The ex-planet Pluto
Contact:

Post by calc84maniac »

Or xstart, ystart, xdest, and ydest. :P
~calc84maniac has spoken.

Projects:
F-Zero 83+
Project M (Super Mario for 83+)
User avatar
JoostinOnline
Regular Member
Posts: 133
Joined: Wed 11 Jul, 2007 10:42 pm
Location: Behind You

Post by JoostinOnline »

I'm not saying put the whole thing in ASM. Is there not more to the program than what you have said so far? I just figured that it was a little piece of the code, so adding the ASM program would only be a small subroutine or somthing.
"Macs are the Perfect Computers", said the Perfect Idiot.
Image
Testing for:
Vera
Post Reply