_transition_for_position: () ->
switch @['_algorithm']
when 'standard' then (n) =>
([i,e], vector, offset) =>
h = i - offset; w = vector.length
if e < n
if h <= w - 2
a = n - e + 1; b = w - h
k = if a < b then a else b
j = @_index_of(vector, k, h)
if j == 0
[
[(i + 1), e]
]
else if j > 0
[
[i, (e + 1)]
[(i + 1), (e + 1)]
[(i + j + 1), (e + j)]
]
else
[
[i, (e + 1)]
[(i + 1), (e + 1)]
]
else if h == w - 1
if vector[h]
[
[(i + 1), e]
]
else
[
[i, (e + 1)]
[(i + 1), (e + 1)]
]
else
[
[i, (e + 1)]
]
else if e == n
if h <= w - 1
if vector[h]
[
[(i + 1), n]
]
else
null
else
null
else
null
when 'transposition' then (n) =>
([i,e,t], vector, offset) =>
h = i - offset; w = vector.length
if e == 0 < n
if h <= w - 2
a = n - e + 1; b = w - h
k = if a < b then a else b
j = @_index_of(vector, k, h)
if j == 0
[
[(i + 1), 0, 0]
]
else if j == 1
[
[i, 1, 0]
[i, 1, 1]
[(i + 1), 1, 0]
[(i + 2), 1, 0]
]
else if j > 1
[
[i, 1, 0]
[(i + 1), 1, 0]
[(i + j + 1), j, 0]
]
else
[
[i, 1, 0]
[(i + 1), 1, 0]
]
else if h == w - 1
if vector[h]
[
[(i + 1), 0, 0]
]
else
[
[i, 1, 0]
[(i + 1), 1, 0]
]
else
[
[i, 1, 0]
]
else if 1 <= e < n
if h <= w - 2
if t is 0
a = n - e + 1; b = w - h
k = if a < b then a else b
j = @_index_of(vector, k, h)
if j == 0
[
[(i + 1), e, 0]
]
else if j == 1
[
[i, (e + 1), 0]
[i, (e + 1), 1]
[(i + 1), (e + 1), 0]
[(i + 2), (e + 1), 0]
]
else if j > 1
[
[i, (e + 1), 0]
[(i + 1), (e + 1), 0]
[(i + j + 1), (e + j), 0]
]
else
[
[i, (e + 1), 0]
[(i + 1), (e + 1), 0]
]
else
if vector[h]
[
[(i + 2), e, 0]
]
else
null
else if h == w - 1
if vector[h]
[
[(i + 1), e, 0]
]
else
[
[i, (e + 1), 0]
[(i + 1), (e + 1), 0]
]
else
[
[i, (e + 1), 0]
]
else
if h <= w - 1 and t is 0
if vector[h]
[
[(i + 1), n, 0]
]
else
null
else if h <= w - 2 and t is 1
if vector[h]
[
[(i + 2), n, 0]
]
else
null
else
null
when 'merge_and_split' then (n) =>
([i,e,s], vector, offset) =>
h = i - offset; w = vector.length
if e == 0 < n
if h <= w - 2
if vector[h]
[
[(i + 1), e, 0]
]
else
[
[i, (e + 1), 0]
[i, (e + 1), 1]
[(i + 1), (e + 1), 0]
[(i + 2), (e + 1), 0]
]
else if h == w - 1
if vector[h]
[
[(i + 1), e, 0]
]
else
[
[i, (e + 1), 0]
[i, (e + 1), 1]
[(i + 1), (e + 1), 0]
]
else
[
[i, (e + 1), 0]
]
else if e < n
if h <= w - 2
if s is 0
if vector[h]
[
[(i + 1), e, 0]
]
else
[
[i, (e + 1), 0]
[i, (e + 1), 1]
[(i + 1), (e + 1), 0]
[(i + 2), (e + 1), 0]
]
else
[
[(i + 1), e, 0]
]
else if h == w - 1
if s is 0
if vector[h]
[
[(i + 1), e, 0]
]
else
[
[i, (e + 1), 0]
[i, (e + 1), 1]
[(i + 1), (e + 1), 0]
]
else
[
[(i + 1), e, 0]
]
else
[
[i, (e + 1), 0]
]
else
if h <= w - 1
if s is 0
if vector[h]
[
[(i + 1), n, 0]
]
else
null
else
[
[(i + 1), e, 0]
]
else
null