Sha256: f70752371de5c36b1ec8abf0da9c64cb4d6805b4ad2135a40581164a3e051cad

Contents?: true

Size: 861 Bytes

Versions: 1

Compression:

Stored size: 861 Bytes

Contents

module Linotype
  class Simulator
    
    attr_accessor :player_one, :player_two, :game
    
    def initialize(strategy_one, strategy_two)
      self.player_one = Player.new(strategy: strategy_one)
      self.player_two = Player.new(strategy: strategy_two)
    end
    
    def simulate!
      self.game = Game.new(player_one: player_one, player_two: player_two)
      puts "Let's start the simulator"
      while !game.over?
        if best_next_play = game.best_next_play        
          puts "Player #{game.player_number(game.current_player)} will play: #{best_next_play.word}"
          game.play(*best_next_play.to_hash[:coordinates])
        else
          puts "Player #{game.player_number(game.current_player)} will pass."
          game.play
        end
        game.print_board
        game.print_scores
      end
      game
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
linotype-0.0.4 lib/linotype/simulator.rb