Module: BoardEvaluation

Included in:
Board
Defined in:
lib/sapphire-chess/board/board_evaluation.rb

Instance Method Summary collapse

Instance Method Details

#evaluateObject



2
3
4
# File 'lib/sapphire-chess/board/board_evaluation.rb', line 2

def evaluate
  material_evaluation + piece_location_evaluation
end

#evaluate_move(move, color) ⇒ Object



20
21
22
23
24
# File 'lib/sapphire-chess/board/board_evaluation.rb', line 20

def evaluate_move(move, color)
  provisional(move, color) do
    evaluate
  end
end

#material_evaluationObject



6
7
8
9
10
11
# File 'lib/sapphire-chess/board/board_evaluation.rb', line 6

def material_evaluation
  white_evaluation = friendly_pieces(:white).map(&:value).sum
  black_evaluation = -friendly_pieces(:black).map(&:value).sum

  white_evaluation + black_evaluation
end

#piece_location_evaluationObject



13
14
15
16
17
18
# File 'lib/sapphire-chess/board/board_evaluation.rb', line 13

def piece_location_evaluation
  white_evaluation = friendly_pieces(:white).map(&:location_value).sum
  black_evaluation = -friendly_pieces(:black).map(&:location_value).sum

  white_evaluation + black_evaluation
end