Page 1 of 1

[TI-BASIC] Finding a path

Posted: Tue 11 Sep, 2007 3:46 pm
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?

Posted: Tue 11 Sep, 2007 3:54 pm
by calc84maniac
Count up the steps. :D Or did you mean in TI-Basic... :P

Posted: Tue 11 Sep, 2007 4:18 pm
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.

Posted: Tue 11 Sep, 2007 6:18 pm
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.

Posted: Tue 11 Sep, 2007 6:44 pm
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)

Posted: Tue 11 Sep, 2007 10:21 pm
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.

Posted: Tue 11 Sep, 2007 10:47 pm
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 ;)

Posted: Tue 11 Sep, 2007 10:57 pm
by calc84maniac
Or xstart, ystart, xdest, and ydest. :P

Posted: Tue 11 Sep, 2007 11:08 pm
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.