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.
4 5 6 7 8 9 |
# File 'lib/player.rb', line 4 def initialize(marker) @marker = marker @player_type = 'human' @turn = 0 @opponent = nil end |
Instance Attribute Details
#marker ⇒ Object
Returns the value of attribute marker.
3 4 5 |
# File 'lib/player.rb', line 3 def marker @marker end |
#opponent ⇒ Object
Returns the value of attribute opponent.
3 4 5 |
# File 'lib/player.rb', line 3 def opponent @opponent end |
#player_type ⇒ Object
Returns the value of attribute player_type.
3 4 5 |
# File 'lib/player.rb', line 3 def player_type @player_type end |
#turn ⇒ Object
Returns the value of attribute turn.
3 4 5 |
# File 'lib/player.rb', line 3 def turn @turn end |
Instance Method Details
#current_player? ⇒ Boolean
16 17 18 |
# File 'lib/player.rb', line 16 def current_player? self.turn == 1 end |
#get_alpha(alpha, score) ⇒ Object
20 21 22 |
# File 'lib/player.rb', line 20 def get_alpha(alpha, score) alpha end |
#get_beta(beta, score) ⇒ Object
24 25 26 |
# File 'lib/player.rb', line 24 def get_beta(beta, score) beta end |
#next_player_turn ⇒ Object
11 12 13 14 |
# File 'lib/player.rb', line 11 def next_player_turn self.turn = 0 self.opponent.turn = 1 end |