Class: Player
- Inherits:
-
Object
- Object
- Player
- Defined in:
- lib/player.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#marker ⇒ Object
Returns the value of attribute marker.
-
#opponent ⇒ Object
Returns the value of attribute opponent.
-
#player_type ⇒ Object
Returns the value of attribute player_type.
-
#turn ⇒ Object
Returns the value of attribute turn.
Instance Method Summary collapse
- #current_player? ⇒ Boolean
- #get_alpha(alpha, score) ⇒ Object
- #get_beta(beta, score) ⇒ Object
-
#initialize(marker) ⇒ Player
constructor
A new instance of Player.
- #next_player_turn ⇒ Object
Constructor Details
#initialize(marker) ⇒ Player
Returns a new instance of Player.
3 4 5 6 7 8 |
# File 'lib/player.rb', line 3 def initialize(marker) @marker = marker @player_type = 'human' @turn = 0 @opponent = nil end |
Instance Attribute Details
#marker ⇒ Object
Returns the value of attribute marker.
2 3 4 |
# File 'lib/player.rb', line 2 def marker @marker end |
#opponent ⇒ Object
Returns the value of attribute opponent.
2 3 4 |
# File 'lib/player.rb', line 2 def opponent @opponent end |
#player_type ⇒ Object
Returns the value of attribute player_type.
2 3 4 |
# File 'lib/player.rb', line 2 def player_type @player_type end |
#turn ⇒ Object
Returns the value of attribute turn.
2 3 4 |
# File 'lib/player.rb', line 2 def turn @turn end |
Instance Method Details
#current_player? ⇒ Boolean
15 16 17 |
# File 'lib/player.rb', line 15 def current_player? self.turn == 1 end |
#get_alpha(alpha, score) ⇒ Object
19 20 21 |
# File 'lib/player.rb', line 19 def get_alpha(alpha, score) alpha end |
#get_beta(beta, score) ⇒ Object
23 24 25 |
# File 'lib/player.rb', line 23 def get_beta(beta, score) beta end |
#next_player_turn ⇒ Object
10 11 12 13 |
# File 'lib/player.rb', line 10 def next_player_turn self.turn = 0 self.opponent.turn = 1 end |