class Checkers::Game::Engine
Public Class Methods
new(state, ai_engine)
click to toggle source
# File lib/checkers/game/engine.rb, line 6 def initialize(state, ai_engine) @state = state @ai = ai_engine end
Public Instance Methods
play()
click to toggle source
# File lib/checkers/game/engine.rb, line 11 def play return if @state.winner || @state.tie if @state.turn == :ai new_board = @ai.next_board(@state.board) turn = if new_board.jumped new_board.any_jump_moves?(player: :ai) ? :ai : :human else :human end @state.set_state(board: new_board, turn: turn) end end