Class: Game
- Inherits:
-
Object
- Object
- Game
- Includes:
- ScoreRound
- Defined in:
- lib/prisoners-dilemma.rb,
lib/prisoners-dilemma/version.rb
Instance Attribute Summary collapse
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Game
constructor
A new instance of Game.
- #play ⇒ Object
Methods included from ScoreRound
#both_cooperate, #green_screws_red, #neither_cooperate, #red_screws_green
Constructor Details
#initialize ⇒ Game
Returns a new instance of Game.
11 12 13 14 15 16 |
# File 'lib/prisoners-dilemma.rb', line 11 def initialize @score = [0, 0] @red = RedPlayer.new @green = GreenPlayer.new end |
Instance Attribute Details
#score ⇒ Object (readonly)
Returns the value of attribute score.
9 10 11 |
# File 'lib/prisoners-dilemma.rb', line 9 def score @score end |
Class Method Details
.version ⇒ Object
2 3 4 |
# File 'lib/prisoners-dilemma/version.rb', line 2 def self.version '0.0.1' end |
Instance Method Details
#play ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/prisoners-dilemma.rb', line 18 def play 1.upto 10_000 do |round_number| announce round_number score_round end score_game end |