Class: NeuroGammon::RandomPlayer

Inherits:
BasePlayer show all
Defined in:
lib/neuro_gammon/random_player.rb

Instance Attribute Summary

Attributes inherited from BasePlayer

#id, #name

Instance Method Summary collapse

Constructor Details

#initializeRandomPlayer

Returns a new instance of RandomPlayer.



23
24
25
26
# File 'lib/neuro_gammon/random_player.rb', line 23

def initialize
  super
  
end

Instance Method Details

#suggest_move(board, dice, colour) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/neuro_gammon/random_player.rb', line 28

def suggest_move board,dice,colour
  valid=board.valid_moves(colour, dice)
  if (valid.size>0)
    move=valid[rand(valid.size)]
    return move
  else
    return nil
  end
end