This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-11-25 18:42:47

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

A* Pathfinder - The Best on Scratch

I worked on this a while ago. Although when I saw shadow_7283's project, and I told them I was working on this, than they sorta got desprate saying 'Upload this please!'. So I finished this, and uploaded this.

This is A* pathfinding for scratch. It is based on a 11 by 15 grid, and it works pretty well. In mode one, you can click on tiles to change it between a block and no block, and use left and right arrow keys to move the start block, and A and D to move the destination. In mode 2, it will actually go to the place. If you close it all up, it's smart enough to say 'Error!' and stop the project. Its not perfect, but its the best you can find in scratch.

Keep in mind though, that only use this method of pathfinding, for scratch games that are tilebased. If you want to make a different non-tilebased game, which requires pathfinding, use http://scratch.mit.edu/projects/AddZero/186736 , Addzero's AI Navigate 1, which can be used for racing games. tower defence, etc.

How the A* method works: First it finds out which blocks its possible to go to. this can be from 0 if its all closed in, to 8 if theres no walls next to it. Then it calculates for each one, if it is in a diagonal direction, or vertical/horizontal. If its diagonal is 14 (10 x sqrt. of 2 approx.), or else its just 10. Then it calculates how many blocks it is from the destination. It multiplies that by 10, and keeps track of it. Then for each block it adds the two together, and it goes to the block with the lowest value.

Enjoy!


http://i.imgur.com/WBkM2QQ.png

Offline

 

#2 2009-11-25 18:44:10

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: A* Pathfinder - The Best on Scratch

You can take out the part about me being desperate, please...

Last edited by shadow_7283 (2009-11-25 18:44:22)

Offline

 

#3 2009-11-25 19:04:34

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: A* Pathfinder - The Best on Scratch

shadow_7283 wrote:

You can take out the part about me being desperate, please...

Nah  tongue


http://i.imgur.com/WBkM2QQ.png

Offline

 

#4 2009-11-25 19:11:25

Zelda123
Scratcher
Registered: 2007-11-21
Posts: 1000+

Re: A* Pathfinder - The Best on Scratch

Lucario621 wrote:

shadow_7283 wrote:

You can take out the part about me being desperate, please...

Nah  tongue

Lucario's kindheartedness is overwhelming.

Offline

 

#5 2009-11-25 19:12:45

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: A* Pathfinder - The Best on Scratch

Zelda123 wrote:

Lucario621 wrote:

shadow_7283 wrote:

You can take out the part about me being desperate, please...

Nah  tongue

Lucario's kindheartedness is overwhelming.

Lol...


http://i.imgur.com/WBkM2QQ.png

Offline

 

#6 2009-11-25 19:17:16

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: A* Pathfinder - The Best on Scratch

Seriously, PLEASE take it out. It is virtually an outright lie. I used something I like to call manners by using please and not trying to sound demanding.

Offline

 

#7 2009-11-25 19:20:13

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: A* Pathfinder - The Best on Scratch

Zelda123 wrote:

Lucario621 wrote:

shadow_7283 wrote:

You can take out the part about me being desperate, please...

Nah  tongue

Lucario's kindheartedness is overwhelming.

Zelda! Your back! Why don't you post projects anymore?!

Offline

 

#8 2009-11-25 19:26:37

Zelda123
Scratcher
Registered: 2007-11-21
Posts: 1000+

Re: A* Pathfinder - The Best on Scratch

shadow_7283 wrote:

Zelda123 wrote:

Lucario621 wrote:

Nah  tongue

Lucario's kindheartedness is overwhelming.

Zelda! Your back! Why don't you post projects anymore?!

Well I never really left. I've just been on and off Scratch for the past year or so. I might make more projects in the future.

[/end of hijacking thread]

Last edited by Zelda123 (2009-11-25 19:26:50)

Offline

 

Board footer