[ANN] RRobots - ducks, armed and dangerous

H

Harold Hausman


no, you're too 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.

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
 
T

Terje Tjervaag

------=_Part_19401_9617396.1132912301478
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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

------=_Part_19401_9617396.1132912301478
Content-Type: application/octet-stream; name=robot.diff
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="robot.diff"

--- ../robots3/rrobots.rb 2005-11-24 14:59:06.000000000 +0100
+++ rrobots.rb 2005-11-25 10:40:10.052577500 +0100
@@ -107,7 +107,7 @@

$stdout.sync = true

-TkRobot = Struct.new:)body, :gun, :radar)
+TkRobot = Struct.new:)body, :gun, :radar, :status)

usage if ARGV.size != 2

@@ -161,10 +161,16 @@

battlefield.tick
battlefield.robots.each_with_index do |ai, i|
- robots[ai] ||= TkRobot.new(TkcImage.new(canvas, 0, 0), TkcImage.new(canvas, 0, 0), TkcImage.new(canvas, 0, 0))
+ robots[ai] ||= TkRobot.new(TkcImage.new(canvas, 0, 0), TkcImage.new(canvas, 0, 0), TkcImage.new(canvas, 0, 0),
+ TkcText.new(canvas,
+ :fill => %w{red green},
+ :anchor => 'nw',
+ :coords => [10, 15 * i + 10],
+ :font => TkFont.new("courier 10")))
robots[ai].body.configure:)image => colors.body[(ai.heading+5) / 10], :coords => [ai.x / 2, ai.y / 2])
robots[ai].gun.configure:)image => colors.gun[(ai.gun_heading+5) / 10], :coords => [ai.x / 2, ai.y / 2])
robots[ai].radar.configure:)image => colors.radar[(ai.radar_heading+5) / 10], :coords => [ai.x / 2, ai.y / 2])
+ robots[ai].status.configure:)text => "#{ai.class.name.ljust(20)} #{ai.energy}")
end
battlefield.bullets.each do |bullet|
bullets[bullet] ||= TkcOval.new(canvas, [-2, -2], [3, 3], :fill=>'gray80')
@@ -177,4 +183,4 @@
end
}).start

-Tk.mainloop
\ No newline at end of file
+Tk.mainloop

------=_Part_19401_9617396.1132912301478--
 
E

Edwin van Leeuwen

micktaiwan said:
Against SittingDuck, it performed very badly :)

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.
 
S

Simon Kröger

Terje said:
=20
=20
Hi,
=20
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.
=20
Diff attached, against 0.1.1
=20

Thanks,

patch accepted (with minor tweak)

cheers

Simon
 
P

Phrogz

Feature request: support an arbitrary number of bots on the field,
instead of 2. Most of the time bots will probably be designed for 1-1
battles, but it would be cool to see how tactics differ as you add more
enemies to the field.

Ooh, and then perhaps the concept of same-team bots (radar would show
the bot as 'friendly') so you could have multiple instances of two bots
on the field.
 
S

Simon Kröger

[...]
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
 
H

Harold Hausman

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

#End Listing
#Beware the word wrap. heh

Thanks again and long live rrobots.rb,
-Harold

[...]
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
 
C

Clayton Smith

Another robot to play with...

require 'robot'
class Testing
include Robot
def initialize bf
super(bf)
@saw_robot = false
end
def tick events
accelerate 1
if @saw_robot
direction = time%2==0 ? -1 : 1
turn_gun 20*direction
turn 1*direction
@saw_robot = false
else
turn_gun 10
turn 2
end
if !events['robot_scanned'].empty?
fire 1
@saw_robot=true
end
end
end
 
S

Simon Kröger

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
 
J

Jeff Wood

------=_Part_6760_19258845.1132964121494
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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

j.

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-=3D 360 if value > 180
value+=3D 360 if value < -180
value =3D -m if value < -m
value =3D m if value > m
return value
end

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

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

fire 3 if @radar_range.abs < 10

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

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

gun =3D min_max(@target_heading - gun_heading - turn_body, 30)
radar =3D 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

------=_Part_6760_19258845.1132964121494--
 
S

Simon Kröger

Jeff said:
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
 
J

Jeff Wood

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.
 
K

Kero

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.
 
S

Simon Kröger

Kero said:
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: :)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,163
Latest member
Sasha15427
Top