Class: Player

Inherits:
Object
  • Object
show all
Defined in:
lib/player.rb

Direct Known Subclasses

Maximizing, Minimizing

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#markerObject

Returns the value of attribute marker.



3
4
5
# File 'lib/player.rb', line 3

def marker
  @marker
end

#opponentObject

Returns the value of attribute opponent.



3
4
5
# File 'lib/player.rb', line 3

def opponent
  @opponent
end

#player_typeObject

Returns the value of attribute player_type.



3
4
5
# File 'lib/player.rb', line 3

def player_type
  @player_type
end

#turnObject

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

Returns:

  • (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_turnObject



11
12
13
14
# File 'lib/player.rb', line 11

def next_player_turn
  self.turn = 0
  self.opponent.turn = 1
end