search.rb
# Checks whether a king will be in check in a given position, used for determining if
#   a player can castle without moving through check
Checks whether a king will be in check in a given position, used for determining if
a player can castle without moving through check
Checks whether a king will be in check in a given position used for determining if a player can castle without moving through check
def king_can_move?(from, to)
    @squares[to], @colors[to] = K, @mx
    @squares[from], @colors[from] = EMPTY, EMPTY
    @kings[@mx] = to
    c = in_check?
    @squares[from], @colors[from] = K, @mx
    @squares[to], @colors[to] = EMPTY, EMPTY
    @kings[@mx] = from
    !c
  end
def king_can_move? ( from , to ) @squares [ to ] , @colors [ to ] = K , @mx @squares [ from ] , @colors [ from ] = EMPTY , EMPTY @kings [ @mx ] = to c = in_check? @squares [ from ] , @colors [ from ] = K , @mx @squares [ to ] , @colors [ to ] = EMPTY , EMPTY @kings [ @mx ] = from ! c end
Checks whether a king will be in check in a given position, used for determining if
a player can castle without moving through check
Checks whether a king will be in check in a given position used for determining if a player can castle without moving through check
from
<not_specific>
to
<not_specific>