Netlogo Dijkstra algorithm
问题 to-report find-path [ init final ] ask init [set dist_d 0] let current init let p_dij [] set p_dij insert-item 0 p_dij current show "dij" while [not (current = final)] [ ask [neighbors with [pcolor = yellow and not (dist_d = -1)]] of current [set dist_d min (list dist_d (1 + [dist_d] of current))] ask current [set dist_d -1] let min_d min [dist_d] of neighbors set current one-of neighbors with [dist_d = min_d and pcolor = yellow] set p_dij insert-item (length p_dij - 1) p_dij current ] ask