Ruby Arena is a game for programmers and people who wants to learn how to program in Ruby.
Instead of controling your robot with keys you have to program its AI (artifical intelligence) and see if it can beat other robots!
This project has been inspired by [robocode][robocode] (Java, .NET) and [rrobots][rrobots] (Ruby).
- create arena from scratch
- learn
- have fun!
gem install ruby_arena
ruby_arena path_to/robot.rb path_to/another_robot.rb
You can run game with some predefined robots (levels).
ruby_arena -l 0 path_to/your_ai.rb
You can use source code of level robots as reference.
If you have your own robots (well AIs), then feel free to publish them as gists and add them here.
Just extend RubyArena::Ai
class and implement your own #tick
method.
class TestAi < RubyArena::Ai
def tick(events)
fire # do nothing but fire when possible
end
end
AI api is very similar to robot api from [rrobots][rrobots].
# change speed by 1, max to 8
accelerate
# change speed by -1, min to -8
decelerate
# turn robot, gun and radar
turn(angle)
# turn gun and radar
turn_gun(angle)
# turn radar
turn_radar(angle)
# fire a bullet
fire
# change radar view angle
set_radar_view_angle(angle)
You can do each action just once in each tick, so:
turn(2)
turn(2)
Will do just turn by 2 degrees. It is the same for other actions.
Project is in very early stage with unstable API. Any contribution (your own robot, reported issue, new pull request, advice regarding code/OO design) is very much appreciated.
However you can already start the game and the battle between robots! Detais were mentioned above.
- Fork the repo
- Create your own branch
- Do your changes
- Create pull request
- Everything needs to be tested! Well not everything. I really do not have an idea how to test Gui. But rest of the code must be tested before merging to master. If you do not now how to test it, than open new issue and we can discuss it.
- If something is hard to implement or change, then please refactor the code first so change is easy and then implement it.
I would like to thank to each of the contributors.
MIT LICENSE [robocode]: http://robocode.sourceforge.net/ [rrobots]: http://rrobots.rubyforge.org/