# Basic OO ideas

**URL:** <https://www.ruby-forum.com/t/basic-oo-ideas/94111>\
**Category:** Ruby\
**Created:** [April 21, 2006, 4:45am UTC](https://www.ruby-forum.com/t/basic-oo-ideas/94111 "2006-04-21T04:45:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![snow-templar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/977dab/32.png) [@snow-templar](https://www.ruby-forum.com/u/snow-templar)\
**Post date:** [April 21, 2006, 4:45am UTC](https://www.ruby-forum.com/t/basic-oo-ideas/94111/1 "2006-04-21T04:45:45Z")

</div>

HI all,

Still struggling with writing a basic bot for rrobots. Thought I  
would ask for some advice - given the following information, how (and  
why) would you structure your classes and methods (general info fine,  
not asking anyone to write code for me):

#state: Things I can check/read from

# team

# battlefield\_height

# battlefield\_width

# energy

# gun\_heading

# gun\_heat

# heading

# size

# radar\_heading

# time

# game\_over

# speed

# x

# y

#actions: Things I can change/set

# accelerate

# stop

# fire

# turn

# turn\_gun

# turn\_radar

# broadcast

# say

#events: More things I can check/read from

# got\_hit

# robot\_scanned

# broadcasts

Here’s a basic outline I wrote - am I on the right track?

require ‘robot’

class GoofeyDuck4  
include Robot

def initialize  
@status = [  
‘got\_hit’ =\> 0,  
‘found’ =\> 0,  
]  
end

def tick events

```
bot = Bot.new

got_hit = 1 if (!events['events'].empty?)
found = 1 if (!events['robot_scanned'].empty?)

turn_radar(bot.radar.dir)
turn_gun(bot.gun.dir)
turn(bot.tank.dir)
accelerate(bot.tank.speed)
fire(bot.gun.fire)

```

end

end

class Bot

def radar

end

def gun

end

def tank

end

end

Thanks!

Greg
