Class: AIGames::FourInARow::Bot
- Inherits:
-
Object
- Object
- AIGames::FourInARow::Bot
- Defined in:
- lib/ai_games/four_in_a_row/bot.rb
Instance Attribute Summary collapse
-
#current_time_bank ⇒ Object
Time in milliseconds that the bot has in its time bank.
-
#match ⇒ Object
readonly
The match instance.
-
#maximum_time_bank ⇒ Object
Maximum time in milliseconds that the bot can have in its time bank.
-
#time_per_move ⇒ Object
Time in milliseconds that is added to the bot’s time bank each move.
Instance Method Summary collapse
-
#initialize(match = nil) ⇒ Bot
constructor
Initializes a new bot.
-
#place_disc ⇒ Object
Places a disk.
-
#run ⇒ Object
Starts this bot.
-
#update(row, column, new_owner) ⇒ Object
Handles changes on the playing field.
Constructor Details
Instance Attribute Details
#current_time_bank ⇒ Object
Time in milliseconds that the bot has in its time bank
26 27 28 |
# File 'lib/ai_games/four_in_a_row/bot.rb', line 26 def current_time_bank @current_time_bank end |
#match ⇒ Object (readonly)
The match instance
35 36 37 |
# File 'lib/ai_games/four_in_a_row/bot.rb', line 35 def match @match end |
#maximum_time_bank ⇒ Object
Maximum time in milliseconds that the bot can have in its time bank
29 30 31 |
# File 'lib/ai_games/four_in_a_row/bot.rb', line 29 def maximum_time_bank @maximum_time_bank end |
#time_per_move ⇒ Object
Time in milliseconds that is added to the bot’s time bank each move
32 33 34 |
# File 'lib/ai_games/four_in_a_row/bot.rb', line 32 def time_per_move @time_per_move end |
Instance Method Details
#place_disc ⇒ Object
Places a disk. This method MUST return a single integer value, denoting the column you want to drop a pin in. To customize your bot, overwrite this method with your own implementation.
45 46 47 |
# File 'lib/ai_games/four_in_a_row/bot.rb', line 45 def place_disc rand(0...match..columns) end |
#run ⇒ Object
Starts this bot.
56 57 58 |
# File 'lib/ai_games/four_in_a_row/bot.rb', line 56 def run @match.parser.run end |
#update(row, column, new_owner) ⇒ Object
Handles changes on the playing field. Whenever the “owner” of a cell changes, the bot gets notified about it via this method. Overwrite this method to add your own logic.
52 53 |
# File 'lib/ai_games/four_in_a_row/bot.rb', line 52 def update(row, column, new_owner) end |