Skip to content

Instantly share code, notes, and snippets.

@elorest
Last active August 29, 2015 14:09
Show Gist options
  • Save elorest/7a8f6b7179d2dbd58b7f to your computer and use it in GitHub Desktop.
Save elorest/7a8f6b7179d2dbd58b7f to your computer and use it in GitHub Desktop.
require 'rrobots'
class Elorest
include Robot
def tick events
@time = "hello" if time == 0
say @time
# @planned ||= events['robot_scanned'].inspect
# say @planned
# turn_radar 1
# turn_gun 1
accelerate 1 if speed < 8
if defined?(@dir)
@dir ||= 1
elsif time % 1000 == 0
@dir *= -1
end
if events['robot_scanned'].empty?
turn @dir * 1
fire(0.1)
# ((time % 2) - 1)
else
fire(1)
turn(0.5 * @dir)
end
turn 10 if speed < 2
# case rand(1001)
# when 499..502
# turn -10
# when 507..510
# turn 10
# end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment