Sha256: 77e19a8255e752278533eba64ee0a160a05950c32bc7178a36c7845d47ac6772

Contents?: true

Size: 757 Bytes

Versions: 1

Compression:

Stored size: 757 Bytes

Contents

require File.join('games', 'shared', 'player')

module MM
  class ComputerPlayerExpert < Shared::Player
    attr_reader :game

    def make_move(game)
      @game = game
      computer_choosing_graphic
      smart_move
    end

    def smart_move
      secret_code = current_result_partial_match_values.concat(current_result_exact_match_values)
      (4-(secret_code.size)).times do
        secret_code.push((1..6).to_a.sample)
      end
      secret_code.shuffle
    end

    def computer_choosing_graphic
      game.computer_choosing_graphic
    end

    def current_result_partial_match_values
      game.current_result_partial_match_values
    end

    def current_result_exact_match_values
      game.current_result_exact_match_values
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
games_bfox-0.6.0 lib/games/mastermind/computer_player_expert.rb