class RTanque::Bot::Brain
Commands the associated {RTanque::Bot}. This class should be inherited from and {NAME} and {#tick!} overridden.
See {RTanque::Bot::BrainHelper} for a useful mixin
Sample bots:
* {file:sample_bots/seek_and_destroy.rb SeekAndDestroy} * {file:sample_bots/camper.rb Camper} * {file:sample_bots/keyboard.rb Keyboard} Special bot controlled by the keyboard
Attributes
arena[R]
@return [RTanque::Arena]
command[RW]
@!attribute [r] sensors
@return [RTanque::Bot::Sensors]
@!attribute [r] command
@return [RTanque::Bot::Command]
sensors[RW]
@!attribute [r] sensors
@return [RTanque::Bot::Sensors]
@!attribute [r] command
@return [RTanque::Bot::Command]
Public Class Methods
new(arena)
click to toggle source
@!visibility private
# File lib/rtanque/bot/brain.rb, line 26 def initialize(arena) @arena = arena end
Public Instance Methods
tick(sensors)
click to toggle source
@!visibility private
# File lib/rtanque/bot/brain.rb, line 31 def tick(sensors) self.sensors = sensors RTanque::Bot::Command.new.tap do |empty_command| self.command = empty_command self.tick! end end
tick!()
click to toggle source
Main logic goes here
Get input from {#sensors}. See {RTanque::Bot::Sensors}
Give output to {#command}. See {RTanque::Bot::Command} @abstract
# File lib/rtanque/bot/brain.rb, line 45 def tick! # Sweet bot logic end