class ConnectNGame::BasicMoves
The Basic bot just picks the move with the highest score.
Public Class Methods
new(name = "Basic")
click to toggle source
Build the player
Calls superclass method
ConnectNGame::Player::new
# File lib/connect_n_game/players/basic.rb, line 9 def initialize(name = "Basic") super(name, "Minimum tactical analysis.", :silicon) end
Public Instance Methods
losers_comments()
click to toggle source
The agony of defeat
# File lib/connect_n_game/players/basic.rb, line 32 def losers_comments "#{name} says 'Hmmm... What did I miss?'" end
make_move(game, piece)
click to toggle source
Make a move. This bot picks the move with the highest score.
Parameters
-
game - the game being played.
-
piece - the piece to be played, 1 or 2.
Returns
-
A move, 1 .. rack.width
# File lib/connect_n_game/players/basic.rb, line 19 def make_move(game, piece) (game.rack.weights.each_with_index.map do |weight, index| channel = index + 1 [weight + game.rack.score_move(channel, piece), channel] end).sort.show_weights("Scan").last[1] end
winners_comments()
click to toggle source
The thrill of victory.
# File lib/connect_n_game/players/basic.rb, line 27 def winners_comments "#{name} says 'A genius in my own mind!'" end