[ANN] RRobots - ducks, armed and dangerous

Gyoung-Yoon Noh wrote:

···

On 11/24/05, Simon Kröger <SimonKroeger@gmx.de> wrote:

v0.1.1 is ready for download.
(and hopefully realy platform independent)

My screenshot:
http://static.flickr.com/26/66471832_4ceaf3b81b_o.png

--
http://nohmad.sub-port.net

Hehe, nice!

and thanks for the feedback.

Simon

(Sorry for the blank post)

Simon Kröger wrote:

Robots are distributed as source code (i don't see another way anyway)
so nobody would want to compete against such a bot.
(You can search ObjectSpace and find the other robot, setting his energy
to -1, easy victory but without honour)
Maybe there is a way to protect against such strategies i didn't thought
of, any ideas?

$SAFE can stop this kind of thing. Run a thread for each robot, taint stuff
you don't want it to be able to mess with (e.g. the thread), untaint the
robot's code, and eval and run it under $SAFE=4.

Cheers,
Dave

JEGII:

Sure, move the communication to a client server architecture so you can
control this better. You've got to stop them running in the same
process, to make it easier on yourself.

Yes, that's the better way - easier than $SAFE.

Cheers,
Dave

Just wanted to add, well done, and I'm looking forward to creating some robots!

···

On 11/24/05, Simon Kröger <SimonKroeger@gmx.de> wrote:

v0.1.1 is ready for download.

--
Terje

Terje Tjervaag wrote:

···

On 11/24/05, Simon Kröger <SimonKroeger@gmx.de> wrote:

v0.1.1 is ready for download.

Hi,

I added a little status display in the canvas so each robot's health
is shown - easier to have it all in one window rather than having the
health in the terminal window.

Diff attached, against 0.1.1

--
Terje

Thanks,

patch accepted (with minor tweak)

cheers

Simon

I think this has grown enough that there needs to be a separate website &
mailing list for RRobots...

j.

···

On 11/25/05, Simon Kröger <SimonKroeger@gmx.de> wrote:

I wasted my time creating my first real bot (should have fixed
more bugs instead) and named it quite arrogant 'Killer':
(found one very anoying bug with the scanner pointing east, fixed
it, new version v0.1.3)

-------------------------------------------------------------------
require 'robot'

class Killer
   include Robot

   def min_max value, m
     value-= 360 if value > 180
     value+= 360 if value < -180
     value = -m if value < -m
     value = m if value > m
     return value
   end

   def tick events
     @dist = 1000 if @dist.nil?
     @target_heading = 0 if @target_heading.nil?
     @radar_range = 60 if @radar_range.nil?
     @approach = false if @approach.nil?

     if !events['robot_scanned'].empty?
       @dist = events['robot_scanned'].first.first
       @target_heading = (radar_heading - @radar_range * 0.5 + 360.0) %
360 if @radar_range.abs < 10
       @radar_range = (@radar_range.abs > 0.5) ? -@radar_range * 0.5 :
-@radar_range
     else
       @radar_range *= -2 if (@radar_range.abs < 60)
     end

     fire 3 if @radar_range.abs < 10

     @approach = true if (@dist < 200 || @dist > 500)
     @approach = false if (@dist > 250 && @dist < 300)

     if @approach
       turn_body = min_max(@target_heading - heading, 10)
       accelerate(@dist > 275 ? 1 : -1)
     else
       turn_body = min_max(@target_heading - heading + 90, 10)
       accelerate((time / 100) % 2 * 2 - 1)
     end

     gun = min_max(@target_heading - gun_heading - turn_body, 30)
     radar = min_max(@radar_range - gun - turn_body, 60)

     turn(turn_body)
     turn_gun(gun)
     turn_radar(radar)
   end
end
-------------------------------------------------------------------

cheers

Simon

--
"Remember. Understand. Believe. Yield! -> http://ruby-lang.org"

Jeff Wood

You get a gold star on the chart for the day!

Today we can all be thankful for rrobots.rb.

Here's the listing of my first bot, affectionately titled BotOne. He
lays a savage beat down on the aptly named NervousBot, but he is by no
means invincible.

#Begin listing

require 'robot'

class BotOne
  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

#End listing

This bot prefers long matches, as he fires low power shots. This, on
my machine at least exposes some performance problems associated with
shooting a lot. Matching a couple of rapid firing bots brings the app
to it's knees after only a few thousand ticks. My first idea where
maybe that the bullets were not being cleaned up properly, but looking
at the source it looks like they are being remove from the hash and
canvas, so I don't know.

Barring that though, this is brilliant!

One thousand thanks,
-Harold

···

On 11/24/05, Simon Kröger <SimonKroeger@gmx.de> wrote:

Gyoung-Yoon Noh wrote:

> On 11/24/05, Simon Kröger <SimonKroeger@gmx.de> wrote:
>
>>v0.1.1 is ready for download.
>>(and hopefully realy platform independent)
>>
>
>
> My screenshot:
> http://static.flickr.com/26/66471832_4ceaf3b81b_o.png
>
> --
> http://nohmad.sub-port.net

Hehe, nice!

and thanks for the feedback.

Simon

Jeff Wood wrote:

I think this has grown enough that there needs to be a separate website &
mailing list for RRobots...

j.

true,

and there is a first version online:

http://rrobots.rubyforge.org/index.html

I would like to see new robots in the forum and move most of the discussion there. (i read your post as a polite way of saying: please reduce the noise to ruby-talk, or am i completely wrong?)

cheers

Simon

Harold Hausman wrote:

You get a gold star on the chart for the day!

Today we can all be thankful for rrobots.rb.

Here's the listing of my first bot, affectionately titled BotOne. He
lays a savage beat down on the aptly named NervousBot, but he is by no
means invincible.

to cool.

#Begin listing
[...]
#End listing

This bot prefers long matches, as he fires low power shots. This, on
my machine at least exposes some performance problems associated with
shooting a lot. Matching a couple of rapid firing bots brings the app
to it's knees after only a few thousand ticks. My first idea where
maybe that the bullets were not being cleaned up properly, but looking
at the source it looks like they are being remove from the hash and
canvas, so I don't know.

I will dive into that (i was able to finish the match, but it slows
down considerably) maybe i have to 'reuse' old bullets.

Barring that though, this is brilliant!

One thousand thanks,
-Harold

I'm realy glad to see someone enjoys this little game.

cheers

Simon

hhausman wrote:

You get a gold star on the chart for the day!

Today we can all be thankful for rrobots.rb.

Here's the listing of my first bot, affectionately titled BotOne. He
lays a savage beat down on the aptly named NervousBot, but he is by no
means invincible.

After quite a bit of tweaking I'm also ready to release my aptly named
HuntingDuck. It will try to move closer to it's prey (while shooting it
ofcourse).

It seems to be about even with BotOne, but I as its creator might be
overproud :slight_smile:

class HuntingDuck
   include Robot
  def initialize bf
    super(bf)
    @time_since=10
    @direction=1
  end
  def rel_direction(from,to)
    rel = to -from
    if rel > 180
      rel = -360 + rel
    end
    if rel < -180
      rel = 360+rel
    end
    return rel
  end
  def rel_gun_heading
    rel_direction(heading, gun_heading)
  end
  def tick events
    accelerate 1
    @direction = -@direction if Kernel.rand < 0.02
    if !events['got_hit'].empty?
      fire 2
      turn -10*@direction
    end
    if !events['robot_scanned'].empty?
      fire 3
      @time_since=0
    else
      if @time_since < 15
        if Kernel.rand < 0.5 && rel_gun_heading < 30
          turn_gun 6
        elsif rel_gun_heading > -30
          turn_gun -6
        else
          turn_gun 6
        end
        fire 0.5
      elsif @time_since < 100
        turn 10*@direction
      else
        turn 5
      end
    end
    @time_since += 1
  end
end

···

--
Posted via http://www.ruby-forum.com/\.

[...]

> Matching a couple of rapid firing bots brings the app

to it's knees after only a few thousand ticks. My first idea where
maybe that the bullets were not being cleaned up properly, but looking
at the source it looks like they are being remove from the hash and
canvas, so I don't know.

I hope i got it. Would you download v0.1.2 and try it?

cheers

Simon

I"m saying there's been a lot of traffic on the topic over the past
few days which shows a group with a focused interest, maybe you don't
want the noise from the rest of the list ... Enjoy your ducks in peace
so to say.

j.

···

On 11/26/05, Simon Kröger <SimonKroeger@gmx.de> wrote:

Jeff Wood wrote:

> I think this has grown enough that there needs to be a separate website &
> mailing list for RRobots...
>
> j.

true,

and there is a first version online:

http://rrobots.rubyforge.org/index.html

I would like to see new robots in the forum and move most of the
discussion there. (i read your post as a polite way of saying: please
reduce the noise to ruby-talk, or am i completely wrong?)

cheers

Simon

--
"Remember. Understand. Believe. Yield! -> http://ruby-lang.org"

Jeff Wood

After quite a bit of tweaking I'm also ready to release my aptly named
HuntingDuck. It will try to move closer to it's prey (while shooting it
ofcourse).

It seems to be about even with BotOne, but I as its creator might be
overproud :slight_smile:

Against SittingDuck, it performed very badly :slight_smile:

Harold Hausman wrote:
> You get a gold star on the chart for the day!
>
> Today we can all be thankful for rrobots.rb.

> Here's the listing of my first bot, affectionately titled BotOne. He
> lays a savage beat down on the aptly named NervousBot, but he is by no
> means invincible.

to cool.

no, you're too cool. :wink:

> #Begin listing
> [...]
> #End listing
>
> This bot prefers long matches, as he fires low power shots. This, on
> my machine at least exposes some performance problems associated with
> shooting a lot. Matching a couple of rapid firing bots brings the app
> to it's knees after only a few thousand ticks. My first idea where
> maybe that the bullets were not being cleaned up properly, but looking
> at the source it looks like they are being remove from the hash and
> canvas, so I don't know.

I will dive into that (i was able to finish the match, but it slows
down considerably) maybe i have to 'reuse' old bullets.

I've seen some code for circular lists (Gavin K?) that might be a more
efficient way to manage @battlefield.bullets than a hash, but as far
as optimizing the TK stuff, I haven't the foggiest. I'm super
interested in this game improving though, thanks again for taking the
lead on this, that thread went on too long for *someone* not to put
the rubber to the road.

Keep up the good work,
-Harold

···

On 11/24/05, Simon Kröger <SimonKroeger@gmx.de> wrote:

Just downloaded it. It's killer... Absolutely rockin'

No excuses now, lets see some bots (:

here's a quasi interesting bot, doesn't display the modicum of
intelligence that the BotOne does, but still wins a fair ammount.
Behold, CheeseBot:

#Begin Listing

require 'robot'

class CheeseBot
  include Robot
  def tick events
    @stage = 1 if @stage.nil?
    @direction = -1 if @direction.nil?
    fire 1
    case @stage
      when 1
        accelerate @direction
        if( heading < 90 )
          turn 90 - heading
        elsif( heading > 90 )
          turn heading - 90
        else
          @stage = 2
        end
      when 2
        accelerate @direction
        if y > @battlefield.height - (size*2)
          @stage = 3
          @temp_time = time
        end
      when 3
        accelerate @direction
        if( (@temp_time + 9) >= time )
          turn 10
          turn_gun -10
        else
          @stage = 4
        end
      when 4
        accelerate @direction
        if( (time > @temp_time+30) && (x > (@battlefield.width - (size*2))

x < (size*2)) )

          @direction *= -1
          @temp_time = time
        end
    end
  end
end

#End Listing
#Beware the word wrap. heh

Thanks again and long live rrobots.rb,
-Harold

···

On 11/25/05, Simon Kröger <SimonKroeger@gmx.de> wrote:

> [...]
> Matching a couple of rapid firing bots brings the app
> to it's knees after only a few thousand ticks. My first idea where
> maybe that the bullets were not being cleaned up properly, but looking
> at the source it looks like they are being remove from the hash and
> canvas, so I don't know.

I hope i got it. Would you download v0.1.2 and try it?

cheers

Simon

I"m saying there's been a lot of traffic on the topic over the past
few days which shows a group with a focused interest, maybe you don't
want the noise from the rest of the list ... Enjoy your ducks in peace
so to say.

And you'll have to continue making noisy, shooting ducks on this list.
Otherwise you're unlikely to entice me to make one, too (in between
the other stuff I do).

Bye,
Kero.

micktaiwan wrote:

After quite a bit of tweaking I'm also ready to release my aptly named
HuntingDuck. It will try to move closer to it's prey (while shooting it
ofcourse).

It seems to be about even with BotOne, but I as its creator might be
overproud :slight_smile:

Against SittingDuck, it performed very badly :slight_smile:

Yeah SittingDuck is a though one, it seems only NervousDuck is really
good against sittingDuck.

Another nice feature to add would be a benchmark method. You let two
bots fight 50 times without any screen output, and publish the results.
Nicest would even be to have the output of one of the ongoing fights on
screen (to keep you from getting bored) while in the background it's
running the other matches.

···

--
Posted via http://www.ruby-forum.com/\.

Kero wrote:

I"m saying there's been a lot of traffic on the topic over the past
few days which shows a group with a focused interest, maybe you don't
want the noise from the rest of the list ... Enjoy your ducks in peace
so to say.

And you'll have to continue making noisy, shooting ducks on this list.
Otherwise you're unlikely to entice me to make one, too (in between
the other stuff I do).

Bye,
Kero.

Maybe this can entice you: :slight_smile:

After a lot of Bugfixes and implementing slugfests of up to 8 robots, this is RRobots v0.2.
The robot interface didn't change so all your creations should still work. If you need some challenge look in the forums, good bots are starting to apear there.

http://rrobots.rubyforge.org/screenshots.html

and if you want to download:

http://rubyforge.org/frs/?group_id=1109

cheers

Simon