Created
November 20, 2012 23:13
-
-
Save st23am/4121915 to your computer and use it in GitHub Desktop.
BaselineBot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rrobots' | |
class Robot3 | |
include Robot | |
def tick events | |
@rapid_fire = 0 if @rapid_fire.nil? | |
@last_seen = 0 if @last_seen.nil? | |
@turn_speed = 3 if @turn_speed.nil? | |
if time - @last_seen > 200 | |
@turn_speed *= -1 | |
@last_seen = time | |
end | |
turn @turn_speed | |
if( @rapid_fire > 0 ) | |
fire 0.84 | |
turn_gun -(@turn_speed / @turn_speed) *2 | |
@rapid_fire = @rapid_fire - 1 | |
else | |
turn_gun @turn_speed * 1.25 | |
end | |
if( !events['robot_scanned'].empty? ) | |
@turn_speed *= -1 | |
@last_seen = time | |
@rapid_fire = 20 | |
end | |
@last_hit = time unless events['got_hit'].empty? | |
if @last_hit && time - @last_hit < 20 | |
accelerate(-1) | |
else | |
accelerate 1 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment