lib/engine/game/g_1862/game.rb
# given a freight route set, find number of intervening hexes
# between ends. If an end is an offboard, calculate distance as if end
# is last hex before offboard and add 1
given a freight route set, find number of intervening hexes
between ends. If an end is an offboard, calculate distance as if end
is last hex before offboard and add 1
given a freight route set find number of intervening hexes between ends . If an end is an offboard calculate distance as if end is last hex before offboard and add 1
def hex_crow_distance(set, setend_a, setend_b)
          end_a = adjust_end(set, setend_a)
          end_b = adjust_end(set, setend_b)
          x_a, y_a = doubleheight_coordinates(end_a.hex)
          x_b, y_b = doubleheight_coordinates(end_b.hex)
          dx = (x_a - x_b).abs
          dy = (y_a - y_b).abs
          distance = [0, dx + [0, (dy - dx) / 2].max - 1].max
          distance += 1 if end_a != setend_a
          distance += 1 if end_b != setend_b
          distance
        end
def hex_crow_distance ( set , setend_a , setend_b ) end_a = adjust_end ( set , setend_a ) end_b = adjust_end ( set , setend_b ) x_a , y_a = doubleheight_coordinates ( end_a . hex ) x_b , y_b = doubleheight_coordinates ( end_b . hex ) dx = ( x_a - x_b ) . abs dy = ( y_a - y_b ) . abs distance = [ 0 , dx + [ 0 , ( dy - dx ) / 2 ] . max - 1 ] . max distance += 1 if end_a != setend_a distance += 1 if end_b != setend_b distance end
given a freight route set, find number of intervening hexes
between ends.
given a freight route set find number of intervening hexes between ends .
# from https://www.redblobgames.com/grids/hexagons#distances # this game essentially uses double-height coordinates # adjust for offboards
set
<not_specific>
setend_a
<not_specific>
setend_b
<not_specific>