Last active
February 9, 2016 03:32
-
-
Save mmmries/1fe77806a5935eb1261d to your computer and use it in GitHub Desktop.
RRobotsEntry
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 MichaelRobotEntry | |
include Robot | |
INTERVAL = (3.14 * 2 * 100).to_i | |
def tick(events) | |
unless x < size && y < size | |
turn (135 - heading) | |
accelerate 1 | |
end | |
turn_gun (desired_gun_heading - gun_heading) | |
fire(0.5) | |
end | |
private | |
def closest | |
scanned.map(&:first).sort.pop || 1000 | |
end | |
def desired_gun_heading | |
315 + ((rand() * variance) - (variance / 2)) | |
end | |
def scanned | |
@events['robot_scanned'] | |
end | |
def variance | |
90 | |
end | |
end |
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
class NervousDuck | |
include Robot | |
def tick events | |
say ["whoah!", "watch out!", "yikes!"].sample | |
turn_radar 1 if time == 0 | |
turn_gun 30 if time < 3 | |
accelerate 1 | |
turn 2 | |
fire 3 unless events['robot_scanned'].empty? | |
end | |
end |
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
class SlowlyTurning | |
include Robot | |
def tick(events) | |
turn 2 | |
fire 3 unless events['robot_scanned'].empty? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment