is this gonna work? is this A*? :)
Ok, i read a bunch of stuff on A* and im trying to implement it now, please tell me if im on the right track.
my game map is in a 2d array, the function looks at the cells on all 4 sides of the unit and if not blocked, adds a node to a tree structure with the direction and the cost (+1). then it does the same for each of these nodes, then for their nodes etc. until it reaches the target coordinates. as soon as it does, it searches back to the node in the second level and gets the direction of the next move.
actually, now that i think about it, i dont even need the cost anymore, since the first node to be the right coordinate would be the quickest way there anyway.
does this sound like it''s going to work? im working on it right now and it doesnt seem to have anything to do with A*, there is no heuristic and...i guess no cost...
please reply something about this.
yeah, that, and getting toasted...niicely toasted.
yeah, that, and getting toasted...niicely toasted.
Hello,
I am not sure if i understand you correctly. But it sounds more to me that you''re using the Breadth-first search instead of A* search.
Breadth-First search first explores all the nodes 1 cell away from it, then 2 cells away, 3 cells away ... until reaching the goal. Some mechanism is needed to mark the direction of the search going from one node to the other. From the above, it ''s clear that when we reach the goal node, the path we found is shortest.
A* uses the heuristic to guide its search while trying to maintain the shortest solution. Each node is computed by function f which is as follow.
f = g+h
g = the cost of going from the start node to this node
h = the heuristic estimate of the cost of going from this node to the goal node
The node which has the lowest f value is choosed in each iteration to continue exploring. The a* search will try to go in the direction the heuristic guide (instead of considering all direction equaly as in Breadth-first search) while trying to maintain the shortest path through the g component of f. You can think of Breadth-first search as a* which has h component of 0.
I hope this helps some, you should consult more of the a* documents to grab its full essence.
Mark.
I am not sure if i understand you correctly. But it sounds more to me that you''re using the Breadth-first search instead of A* search.
Breadth-First search first explores all the nodes 1 cell away from it, then 2 cells away, 3 cells away ... until reaching the goal. Some mechanism is needed to mark the direction of the search going from one node to the other. From the above, it ''s clear that when we reach the goal node, the path we found is shortest.
A* uses the heuristic to guide its search while trying to maintain the shortest solution. Each node is computed by function f which is as follow.
f = g+h
g = the cost of going from the start node to this node
h = the heuristic estimate of the cost of going from this node to the goal node
The node which has the lowest f value is choosed in each iteration to continue exploring. The a* search will try to go in the direction the heuristic guide (instead of considering all direction equaly as in Breadth-first search) while trying to maintain the shortest path through the g component of f. You can think of Breadth-first search as a* which has h component of 0.
I hope this helps some, you should consult more of the a* documents to grab its full essence.
Mark.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement