Class: NeuroGammon::BaseNeuralPlayer
- Inherits:
-
BasePlayer
- Object
- BasePlayer
- NeuroGammon::BaseNeuralPlayer
- Defined in:
- lib/neuro_gammon/base_neural_player.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#hidden_layers ⇒ Object
readonly
Returns the value of attribute hidden_layers.
-
#learning_rate ⇒ Object
readonly
Returns the value of attribute learning_rate.
-
#n_inputs ⇒ Object
readonly
Returns the value of attribute n_inputs.
-
#n_outputs ⇒ Object
readonly
Returns the value of attribute n_outputs.
Attributes inherited from BasePlayer
Instance Method Summary collapse
-
#initialize ⇒ BaseNeuralPlayer
constructor
A new instance of BaseNeuralPlayer.
- #suggest_move(board, dice, colour) ⇒ Object
Constructor Details
#initialize ⇒ BaseNeuralPlayer
Returns a new instance of BaseNeuralPlayer.
14 15 16 17 |
# File 'lib/neuro_gammon/base_neural_player.rb', line 14 def initialize super init_net end |
Instance Attribute Details
#hidden_layers ⇒ Object (readonly)
Returns the value of attribute hidden_layers.
12 13 14 |
# File 'lib/neuro_gammon/base_neural_player.rb', line 12 def hidden_layers @hidden_layers end |
#learning_rate ⇒ Object (readonly)
Returns the value of attribute learning_rate.
11 12 13 |
# File 'lib/neuro_gammon/base_neural_player.rb', line 11 def learning_rate @learning_rate end |
#n_inputs ⇒ Object (readonly)
Returns the value of attribute n_inputs.
9 10 11 |
# File 'lib/neuro_gammon/base_neural_player.rb', line 9 def n_inputs @n_inputs end |
#n_outputs ⇒ Object (readonly)
Returns the value of attribute n_outputs.
10 11 12 |
# File 'lib/neuro_gammon/base_neural_player.rb', line 10 def n_outputs @n_outputs end |
Instance Method Details
#suggest_move(board, dice, colour) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/neuro_gammon/base_neural_player.rb', line 19 def suggest_move board,dice,colour moves=board.valid_moves(colour, dice) best_move=nil best_score=-99 moves.each do |move| new_board_state=board.move(move,colour) inp=generate_input_pattern(new_board_state) out=run_net(inp) score=evaluate_output(out,board,dice,colour) if score>best_score best_move=move best_score=score end end return best_move end |