Skip to content

Instantly share code, notes, and snippets.

@mmmries
Last active February 9, 2016 03:32
Show Gist options
  • Save mmmries/1fe77806a5935eb1261d to your computer and use it in GitHub Desktop.
Save mmmries/1fe77806a5935eb1261d to your computer and use it in GitHub Desktop.
RRobotsEntry
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
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
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