Class: Linotype::Simulator
- Inherits:
-
Object
- Object
- Linotype::Simulator
- Defined in:
- lib/linotype/simulator.rb
Instance Attribute Summary collapse
-
#game ⇒ Object
Returns the value of attribute game.
-
#player_one ⇒ Object
Returns the value of attribute player_one.
-
#player_two ⇒ Object
Returns the value of attribute player_two.
Instance Method Summary collapse
-
#initialize(strategy_one, strategy_two) ⇒ Simulator
constructor
A new instance of Simulator.
- #simulate! ⇒ Object
Constructor Details
Instance Attribute Details
#game ⇒ Object
Returns the value of attribute game.
4 5 6 |
# File 'lib/linotype/simulator.rb', line 4 def game @game end |
#player_one ⇒ Object
Returns the value of attribute player_one.
4 5 6 |
# File 'lib/linotype/simulator.rb', line 4 def player_one @player_one end |
#player_two ⇒ Object
Returns the value of attribute player_two.
4 5 6 |
# File 'lib/linotype/simulator.rb', line 4 def player_two @player_two end |
Instance Method Details
#simulate! ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/linotype/simulator.rb', line 11 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 puts "---------------" end puts "Game Over!" end |