Guest User

Untitled

a guest
Feb 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. require File.join(File.dirname(__FILE__), 'astar_digger')
  2.  
  3. module FJC
  4. module Diggers
  5.  
  6. class FAstarDigger < AstarDigger
  7. def initialize name = nil
  8. @path = []
  9. super
  10. end
  11.  
  12. def pick_move
  13. 2.times do
  14. @path = find_path unless @path.size >= 2
  15. first = @path.pop; second = @path[-1]
  16.  
  17. raise "No StarMap!" unless first and second
  18.  
  19. d = :up if first[1] < second[1]
  20. d = :down if first[1] > second[1]
  21. d = :left if first[0] > second[0]
  22. d = :right if first[0] < second[0]
  23. return d if %w{ R O F }.include?(@board.look(d))
  24.  
  25. @path = []
  26. end
  27.  
  28. raise "FOO"
  29. end
  30. end
  31.  
  32. end
  33. end
Add Comment
Please, Sign In to add comment