Sha256: 9b377f2895837c2dbbc3ccf217855655253b7a28ea3b6189a46b9dde4f83fc8a

Contents?: true

Size: 735 Bytes

Versions: 2

Compression:

Stored size: 735 Bytes

Contents

require_relative 'ai'
require_relative 'algebraic_conversion'
require_relative 'movement_rules/castling_rights'

class Player
  include CastlingRights

  attr_accessor :last_move
  attr_reader :color, :board, :history

  def initialize(color, board)
    @color = color
    @board = board
    @history = []
  end

  private

  def maximizing_player?
    color == :white
  end
end

class Computer < Player
  include AI

  # depth: Levels of AI#minimax recursion.
  # Deeper means harder (computer can think `depth` turns ahead)
  # See Engine#set_difficulty
  attr_accessor :depth

  def select_move
    computer_chooses_move
  end
end

class Human < Player
  include AlgebraicConversion

  def select_move
    algebraic_input
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sapphire-chess-1.0.1 lib/sapphire-chess/player.rb
sapphire-chess-1.0.0 lib/sapphire-chess/player.rb