Module: OthelloRuby::Game::BordWork
Instance Method Summary collapse
- #get_reverse_pattern(active, passive, bit_string) ⇒ Object
- #left_direction(bit_string) ⇒ Object
- #left_under_direction(bit_string) ⇒ Object
- #left_upward_direction(bit_string) ⇒ Object
- #right_direction(bit_string) ⇒ Object
- #right_under_direction(bit_string) ⇒ Object
- #right_upward_direction(bit_string) ⇒ Object
- #under_direction(bit_string) ⇒ Object
- #upward_direction(bit_string) ⇒ Object
Instance Method Details
#get_reverse_pattern(active, passive, bit_string) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/othello_ruby.rb', line 10 def get_reverse_pattern(active, passive, bit_string) patterns = [] EIGHT_DIRECTION.each do |name| patterns << send("get_#{name}_pat", active, passive, bit_string) end patterns.delete(0) patterns.compact end |
#left_direction(bit_string) ⇒ Object
36 37 38 |
# File 'lib/othello_ruby.rb', line 36 def left_direction(bit_string) (bit_string >> 1) & 0x7F7F7F7F7F7F7F7F end |
#left_under_direction(bit_string) ⇒ Object
56 57 58 |
# File 'lib/othello_ruby.rb', line 56 def left_under_direction(bit_string) (bit_string << 7) & 0xFFFFFFFFFFFFFFFF end |
#left_upward_direction(bit_string) ⇒ Object
52 53 54 |
# File 'lib/othello_ruby.rb', line 52 def left_upward_direction(bit_string) bit_string >> 9 end |
#right_direction(bit_string) ⇒ Object
40 41 42 |
# File 'lib/othello_ruby.rb', line 40 def right_direction(bit_string) (bit_string << 1) & 0xFEFEFEFEFEFEFEFE end |
#right_under_direction(bit_string) ⇒ Object
64 65 66 |
# File 'lib/othello_ruby.rb', line 64 def right_under_direction(bit_string) (bit_string << 9) & 0xFFFFFFFFFFFFFFFF end |
#right_upward_direction(bit_string) ⇒ Object
60 61 62 |
# File 'lib/othello_ruby.rb', line 60 def right_upward_direction(bit_string) bit_string >> 7 end |
#under_direction(bit_string) ⇒ Object
48 49 50 |
# File 'lib/othello_ruby.rb', line 48 def under_direction(bit_string) (bit_string << 8) & 0xFFFFFFFFFFFFFFFF end |
#upward_direction(bit_string) ⇒ Object
44 45 46 |
# File 'lib/othello_ruby.rb', line 44 def upward_direction(bit_string) bit_string >> 8 end |