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.



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

#markerObject

Returns the value of attribute marker.



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

def marker
  @marker
end

#opponentObject

Returns the value of attribute opponent.



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

def opponent
  @opponent
end

#player_typeObject

Returns the value of attribute player_type.



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

def player_type
  @player_type
end

#turnObject

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

Returns:

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



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

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