Talk:A* search algorithm: Difference between revisions

Content deleted Content added
Mikademus (talk | contribs)
Line 183:
'''return''' FAILURE
:[[User:Qwertyus|Qwertyus]] 13:00, 11 August 2006 (UTC)
 
I agree with the points you provided above. I based the style of the pseudocode on that in the "AI for Game Developers" book by Bourgh & Seamann, in which their conceptual outline does not complicate the code with creating a path, only showing how to find the goal node. However, it may be even more confusing to omit the creation of the path itself, so my follow-up suggestion, with some improvements(?)
* Conceptually easier to follow path generation
* Providing a goal node for pedagogical reasons
* The bizarre pleasure of beholding an unholy pseudo-language which is consistent and looks like a mixture of Pascal, Python and Visual Basic
 
'''function''' AStar( Node ''start_node'', Node ''end_node'') '''returns''' List '''of''' Node
'''type''' Visited_Node := '''record of'''
''node'' := Node
''parent'' := Node
'''end record'''
'''var''' ''open_list'' := '''empty''' Queue '''of''' Visited_Node
'''var''' ''closed_list'' := '''empty''' Set '''of''' Visited_Node
'''var''' node_info := Visited_Node( start_node, '''empty''' );
push( what:''node_info'', on:''open_list'' )
'''while''' ''open_list'' '''is not empty'''
'''var''' node_info := remove_first( from:''open_list'' )
push( what:''node_info''. on:''closed_list'' )
// The goal node was reached. Trace the path using
// the saved parent information and return path
'''if''' ''node_info''.''node'' '''equals''' ''end_node''
'''then return''' trace_path( from:''node_info'', in:''closed_list'' )
'''else'''
'''foreach''' ''neighbor'' '''of''' ''node_info''.''node''
'''if''' ''neighbor'' is not in ''open_list''
'''and if''' ''neighbor'' is not in ''closed_list''
'''then'''
'''let''' ''node_cost'' := EstimateCostFor( ''neighbor'' )
'''var''' ''new_node'' := Visited_Node( ''neighbor'', ''node_info''.''node'' )
'''push'''( what:''new_node'', cost:''node_cost'', on:''open_list'' )
// Pathfinding failed. Return an empty
// list to indicate this.
'''return empty'''
[[User:Mikademus|Mikademus]] 15:41, 11 August 2006 (UTC)