Class: XO::AI::Player

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

Direct Known Subclasses

MaxPlayer, MinPlayer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Player

Returns a new instance of Player.



9
10
11
# File 'lib/xo/ai/player.rb', line 9

def initialize(token)
  @token = token
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



7
8
9
# File 'lib/xo/ai/player.rb', line 7

def token
  @token
end

Instance Method Details

#best_score(next_grids_scores) ⇒ Object

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/xo/ai/player.rb', line 21

def best_score(next_grids_scores)
  raise NotImplementedError
end

#loser_valueObject

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/xo/ai/player.rb', line 29

def loser_value
  raise NotImplementedError
end

#non_terminal_score(next_grids, scores) ⇒ Object



17
18
19
# File 'lib/xo/ai/player.rb', line 17

def non_terminal_score(next_grids, scores)
  best_score(compute_next_grids_scores(next_grids, scores))
end

#squashed_valueObject



33
34
35
# File 'lib/xo/ai/player.rb', line 33

def squashed_value
  0
end

#terminal_score(outcome) ⇒ Object



13
14
15
# File 'lib/xo/ai/player.rb', line 13

def terminal_score(outcome)
  send("#{outcome}_value")
end

#winner_valueObject

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/xo/ai/player.rb', line 25

def winner_value
  raise NotImplementedError
end