エントリーの編集
エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
記事へのコメント0件
- 注目コメント
- 新着コメント
このエントリーにコメントしてみましょう。
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています
- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
a star in ruby
1 class AStar 2 3 def initialize(adjacency_func, cost_func, distance_func) 4 @adjacency = adjacen... 1 class AStar 2 3 def initialize(adjacency_func, cost_func, distance_func) 4 @adjacency = adjacency_func 5 @cost = cost_func 6 @distance = distance_func 7 end 8 9 def find_path(start, goal) 10 been_there = {} 11 pqueue = PriorityQueue.new 12 pqueue << [1, [start, [], 0]] 13 while !pqueue.empty? 14 spot, path_so_far, cost_so_far = pqueue.next 15 next if been_there[spot] 16 newpath = path_so_far + [

