Astar algorithm, problem

General Robotics Forum - All aspects of robots and their applications. 

Page 2 of 2       << first < 1 2 Bookmark this page:  YahooMyWeb Yahoo!  Google Google  Windows Live Favorites Windows Live  del.icio.us del.icio.us  digg digg  Add to Netscape Netscape
Subject Author Date
Astar algorithm, problem Robbo 12-05-2009
If you were  Registered and logged in, you could reply and use other advanced thread options
Posted by Robbo on December 6, 2009, 11:05 am


In this example, robot (^) wants to go to
place marked by "@".
(please copy maze shown below to notepad to
have equal wide fonts)
. - is cell
, - is opening between cells
# - wall
x - destination position
^ - actual position of robot

# # # # # # # # #
.
# ###,# # # # # #
#^,.#
# #,##### # # # #
#.,.,.#x
# #,###,#,# # # #
.,.#.,.,.#
###,#,##### # # #
.,.#.,.,.#
# ###,###,### # #
,.#.#.#.#.#
#####,#,#,#,### #
#.,.,.#.,.,.,.#
#,#,#######,### #
.#.#.,.,.,.#.#
###,#,###,#,#,# #
#.,.#.#.,.#.,.#
############### #

# # # # # # # # #


for this maze, my implementation of A*
generates such digits:

# # # # # # # # # #
2
# # ### # # # # # #
#^ 1#
# # # ##### # # # #
#1 #
# # # ### # # # # #
# #
# ### # ##### # # #
# #
# # ### ### ### # #
# # # # #
# ##### # # # ### #
# # #
# # # ####### ### #
# # # #
# ### # ### # # # #
# # # # #
# ############### #

# # # # # # # # # #

As you can see, it try to go up and
generates only two 1 and one 2.
Digits even do not connect to destination.




Posted by Robbo on December 7, 2009, 9:36 am


I think, I found the problem:

do {
for (int i = 0; i < nodeNumber; i++)
if (lengths[i] < lengths[shortestPath])
shortestPath = i;

should be:

do {
shortestPath = 0;
for (int i = 0; i < nodeNumber; i++)
if (lengths[i] < lengths[shortestPath])
shortestPath = i;



Page 2 of 2       << first < 1 2

The site map in XML format XML site map
other useful resources:
Official Robosapien Website
Lego Mindstorms Website

Contact Us | Privacy Policy