Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///a_star_find_path(start_node,end_node);
- node_width = 32;
- start_node = argument0;
- cur_node = argument0;
- end_node = argument1;
- pathed = ds_list_create();
- ds_list_add(pathed,start_node);
- while(cur_node != end_node)
- {
- lowest_node = noone;
- lowest_value = 99999999999;
- for(n = 0; n < ds_list_size(cur_node.neighbors); n ++)
- {
- if (move_score(start_node,end_node,ds_list_find_value(cur_node.neighbors,n)) < ds_list_find_value(cur_node.neighbors,n).movment_score || ds_list_find_value(cur_node.neighbors,n).movement_score == noone)
- {
- if (ds_list_find_value(cur_node.neighbors,n).movement_score < lowest_value && ds_list_find_index(pathed,ds_list_find_value(cur_node.neighbors,n)) == -1)
- {
- lowest_value = ds_list_find_value(cur_node.neighbors,n).movement_score;
- lowest_node = ds_list_find_value(cur_node.neighbors,n);
- }
- }
- }
- if (lowest_node == noone)
- {
- with(obj_pathing_node)
- {
- if (movement_score != noone && movement_score < other.lowest_value && ds_list_find_index(other.pathed,id) == -1)
- {
- other.lowest_node = id;
- other.lowest_value = movement_score;
- }
- }
- if (lowest_node == noone) {return noone;}
- else
- {
- lowest_node.parent = cur_node;
- cur_node = lowest_node;
- }
- }
- else
- {
- lowest_node.parent = cur_node;
- cur_node = lowest_node;
- }
- }
- while (cur_node != start_node)
- {
- cur_node.parent.child = cur_node;
- cur_node = cur_node.parent;
- }
- //stop memory leaks by destroying ds list.
- ds_list_destroy(pathed);
- return cur_node.child;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement