{"id":17647109,"url":"https://github.com/awilliams/rtanque","last_synced_at":"2025-04-13T04:59:32.760Z","repository":{"id":7145258,"uuid":"8442885","full_name":"awilliams/RTanque","owner":"awilliams","description":"RTanque is a game for (Ruby) programmers. Players program the brain of a tank and then send their tank+brain into battle against other tanks.","archived":false,"fork":false,"pushed_at":"2021-04-22T17:56:53.000Z","size":1917,"stargazers_count":302,"open_issues_count":7,"forks_count":78,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-13T04:59:21.933Z","etag":null,"topics":["rtanque","ruby"],"latest_commit_sha":null,"homepage":"http://awilliams.github.com/RTanque/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/awilliams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-26T21:52:17.000Z","updated_at":"2024-12-03T02:40:11.000Z","dependencies_parsed_at":"2022-08-21T01:20:29.687Z","dependency_job_id":null,"html_url":"https://github.com/awilliams/RTanque","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awilliams%2FRTanque","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awilliams%2FRTanque/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awilliams%2FRTanque/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awilliams%2FRTanque/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awilliams","download_url":"https://codeload.github.com/awilliams/RTanque/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665756,"owners_count":21142123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rtanque","ruby"],"created_at":"2024-10-23T11:10:28.361Z","updated_at":"2025-04-13T04:59:32.735Z","avatar_url":"https://github.com/awilliams.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RTanque [![Build Status](https://travis-ci.org/awilliams/RTanque.png?branch=dev)](https://travis-ci.org/awilliams/RTanque) [![CodeClimate](https://codeclimate.com/github/awilliams/RTanque.png)](https://codeclimate.com/github/awilliams/RTanque)\n\n**What is this?**\nRTanque is a game for ( *Ruby* ) programmers. Players program the brain of a tank and then send their tank+brain into battle with other tanks. All tanks are otherwise equal.\n\n[Getting started guide](https://awilliams.github.io/posts/rtanque-getting-started/)\n\nRules of the game are simple: Last bot standing wins. Gameplay is also pretty simple. Each tank has a **base**, **turret** and **radar**, each of which rotate independently. The base moves the tank, the turret has a gun mounted to it which can fire at other tanks, and the radar detects other tanks in its field of vision.\n\nHave fun competing against friends' tanks or the sample ones included. Maybe you'll start a small league at your local Ruby meetup. CLI provides easy way to download bots from gists.\n\nSound difficult or time consuming? It's not! Check out the included sample tank [Seek\u0026Destroy](https://github.com/awilliams/RTanque/blob/master/sample_bots/seek_and_destroy.rb) (which is actually fairly difficult to beat with the keyboard controlled bot). Note that it clocks in at under 50 LOC.\n\nThis is not an original idea, see [influences](https://github.com/awilliams/RTanque#influences). There's a lot of resources out there around tank design and tactics that could be applied to RTanque.\n\nHow does it look? Here's a video of a battle:\n\n\u003ca href=\"http://www.youtube.com/watch?feature=player_embedded\u0026v=UPBqwOgGlVY\n\" target=\"_blank\"\u003e\u003cimg src=\"http://img.youtube.com/vi/UPBqwOgGlVY/0.jpg\" \nalt=\"RTanque Demo\" width=\"640\" height=\"480\" border=\"10\" /\u003e\u003c/a\u003e\n\n#### Influences\nRTanque is based on the Java project [Robocode](http://robocode.sourceforge.net/) and inspired by other Ruby ports. Thanks and credit go to them both.\n\n* [RobotWar](http://corewar.co.uk/robotwar/) - Perhaps the canonical version. Created in 1970's and set in the distant 2002. Apple II\n* [Robocode](http://robocode.sourceforge.net/) - Java game, originally from IBM. Tank \u0026 explosion images taken from here.\n* [RRobots](http://rrobots.rubyforge.org/) - Ruby port of Robocode. 2005\n* [RRobots fork](https://github.com/ralreegorganon/rrobots)\n* [FightCode](http://fightcodegame.com/) - Online javascript tank game\n* [Scalatron](http://scalatron.github.com/) - Scala bot game\n* [Many more...](https://www.google.com/?q=robocode%20clone)\n\n## Requirements\n\n * The [Gosu](https://github.com/jlnr/gosu) library used for rendering has some dependencies. Use the [Gosu getting started](https://github.com/jlnr/gosu/wiki/Getting-Started-on-Linux) to resolve any for your system.\n * Ruby 2.2 or later (also tested on earlier versions)\n\n## Quick Start\n\nMake a project directory, init bundler, add the RTanque gem, and create a bot:\n\n    $ mkdir RTanque; cd RTanque\n    $ bundle init\n    $ echo \"gem 'rtanque'\" \u003e\u003e Gemfile\n    $ bundle\n    $ bundle exec rtanque new_bot my_deadly_bot\n    $ bundle exec rtanque start bots/my_deadly_bot sample_bots/keyboard sample_bots/camper:x2\n\n*Drive the Keyboard bot with asdf. Aim/fire with the arrow keys*\n\n## [RTanque Documentation](http://rubydoc.info/github/awilliams/RTanque/master/frames/file/README.md)\n\n  * [RTanque](http://rubydoc.info/github/awilliams/RTanque/master/frames/RTanque)\n  * [RTanque::Bot::Brain](http://rubydoc.info/github/awilliams/RTanque/master/frames/RTanque/Bot/Brain)\n  * [RTanque::Heading](http://rubydoc.info/github/awilliams/RTanque/master/frames/RTanque/Heading)\n  * [RTanque::Point](http://rubydoc.info/github/awilliams/RTanque/master/frames/RTanque/Point)\n\n## Advanced Options\n\nSet arena dimensions\n\n    $ bundle exec rtanque start --width=400 --height=400 sample_bots/camper:x4\n\nAdjust max ticks allowed\n\n    $ bundle exec rtanque start --max_ticks=500 sample_bots/camper:x4\n\nRun headless match (no gui)\n\n    $ bundle exec rtanque start --gui=false sample_bots/camper:x4\n\nRun team match (teams are currently determined by bot name. Bots with same name are on the same team. The match finished if alive bots have the same name.) https://github.com/awilliams/RTanque/pull/10\n\n    $ bundle exec rtanque start --teams sample_bots/camper:x4 sample_bots/seek_and_destroy.rb:4\n\nQuiet mode (less console chatter).\n\n    $ bundle exec rtanque start --quiet sample_bots/camper:x4\n\nSet random number seed, allowing same battle to be repeated. https://github.com/awilliams/RTanque/pull/7\n\n    $ bundle exec rtanque start --seed 1234 sample_bots/camper:x4\n\n**Experimental** Disable garbage collection during match\n\n    $ bundle exec rtanque start --gc=false sample_bots/camper:x4\n\n## Sharing\nAt some point you'll want to compete against other bots, or maybe you'll even organize a small tournament. Sharing bots is easy.\n\nAsk your friends to upload their bot(s) in a [gist](https://gist.github.com/), which you can then download with the following command:\n\n    bundle exec rtanque get_gist \u003cgist_id\u003e ...\n\nFor example, to download [Marksman](https://gist.github.com/SteveRidout/5909793)\n    \n    bundle exec rtanque get_gist 5909793\n    \nIf you'd like to publicly share your bot, post its gist id on the wiki https://github.com/awilliams/RTanque/wiki/bot-gists\n\n## Bot API\n\nThe tank api consists of reading input from Brain#sensors and giving output to Brain#command\n\n**[Brain#sensors](http://rubydoc.info/github/awilliams/RTanque/master/frames/RTanque/Bot/Sensors)**\n\n```ruby\nclass Bot \u003c RTanque::Bot::Brain\n  # RTanque::Bot::Sensors =\n  #  Struct.new(:ticks, :health, :speed, :position, :heading, :radar, :turret)\n  def tick!\n    sensors.ticks # Integer\n    sensors.health # Float\n    sensors.position # RTanque::Point\n    sensors.heading # RTanque::Heading\n    sensors.speed # Float\n    sensors.radar_heading # RTanque::Heading\n    sensors.turret_heading # RTanque::Heading\n    sensors.radar.each do |scanned_bot|\n      # scanned_bot: RTanque::Bot::Radar::Reflection\n      # Reflection(:heading, :distance, :name)\n    end\n  end\nend\n```\n**[Brain#command](http://rubydoc.info/github/awilliams/RTanque/master/frames/RTanque/Bot/Command)**\n\n```ruby\nclass Bot \u003c RTanque::Bot::Brain\n  # RTanque::Bot::Command =\n  #  Struct.new(:speed, :heading, :radar_heading, :turret_heading, :fire_power)\n  def tick!\n    command.speed = 1\n    command.heading = Math::PI / 2.0\n    command.radar_heading = Math::PI\n    command.turret_heading = Math::PI\n    command.fire(3)\n  end\nend\n```\n\n**RTanque::Heading**\nThis class handles angles. It is a wrapper around Float bound to `(0..Math::PI*2)`\n\n```ruby\nRTanque::Heading.new(Math::PI)\n=\u003e \u003cRTanque::Heading: 3.141592653589793rad 180.0deg\u003e\n\nRTanque::Heading.new_from_degrees(180)\n=\u003e \u003cRTanque::Heading: 3.141592653589793rad 180.0deg\u003e\n\nRTanque::Heading.new_from_degrees(180) + RTanque::Heading.new(Math::PI)\n=\u003e \u003cRTanque::Heading: 0.0rad 0.0deg\u003e\n\nRTanque::Heading.new(Math::PI) + (Math::PI / 2.0)\n=\u003e \u003cRTanque::Heading: 4.71238898038469rad 270.0deg\u003e\n\nRTanque::Heading.new == 0\n=\u003e true\n```\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawilliams%2Frtanque","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawilliams%2Frtanque","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawilliams%2Frtanque/lists"}