Skip to content

Commit

Permalink
disables team/co-op mode by default
Browse files Browse the repository at this point in the history
  • Loading branch information
awilliams committed May 26, 2013
1 parent 9099bea commit 967b6b6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,36 @@ Make a project directory, init bundler, add the RTanque gem, and create a bot:
* [RTanque::Heading](https://rubydoc.info/github/awilliams/RTanque/master/frames/RTanque/Heading)
* [RTanque::Point](https://rubydoc.info/github/awilliams/RTanque/master/frames/RTanque/Point)

## Advanced Options

Set arena dimensions

$ bundle exec rtanque start --width=400 --height=400 sample_bots/camper:x4

Adjust max ticks allowed

$ bundle exec rtanque start --max_ticks=500 sample_bots/camper:x4

Run headless match (no gui)

$ bundle exec rtanque start --gui=false sample_bots/camper:x4

Run 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

$ bundle exec rtanque start --teams sample_bots/camper:x4 sample_bots/seek_and_destroy.rb:4

Quiet mode (less console chatter).

$ bundle exec rtanque start --quiet sample_bots/camper:x4

Set random number seed, allowing same battle to be repeated. https://github.com/awilliams/RTanque/pull/7

$ bundle exec rtanque start --seed 1234 sample_bots/camper:x4

**Experimental** Disable garbage collection during match

$ bundle exec rtanque start --gc=false sample_bots/camper:x4

## Sharing
At some point you'll want to compete against other bots, or maybe you'll even organize a small tournament. Sharing bots is easy.

Expand Down
3 changes: 2 additions & 1 deletion bin/rtanque
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ LONGDESC
method_option :width, :aliases => '-w', :default => 1200, :type => :numeric, :banner => 'width of window'
method_option :height, :aliases => '-h', :default => 700, :type => :numeric, :banner => 'height of window'
method_option :max_ticks, :aliases => '-m', :default => Float::INFINITY, :type => :numeric, :banner => 'max ticks allowed per match'
method_option :teams, :default => false, :type => :boolean, :banner => 'true to do a team based match based on tank names'
method_option :gui, :default => true, :type => :boolean, :banner => 'false to run headless'
method_option :gc, :default => true, :type => :boolean, :banner => 'disable GC (EXPERIMENTAL)'
method_option :quiet, :aliases => '-q', :default => false, :type => :boolean, :banner => 'disable chatter'
method_option :seed, :default => Kernel.srand, :type => :numeric, :banner => 'random number seed value'
def start(*brain_paths)
Kernel.srand(options[:seed])
runner = RTanque::Runner.new(options[:width], options[:height], options[:max_ticks])
runner = RTanque::Runner.new(options[:width], options[:height], options[:max_ticks], options[:teams])
brain_paths.each { |brain_path|
begin
runner.add_brain_path(brain_path)
Expand Down
7 changes: 4 additions & 3 deletions lib/rtanque/match.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
module RTanque
class Match
attr_reader :arena, :bots, :shells, :explosions, :ticks, :max_ticks
attr_reader :arena, :bots, :shells, :explosions, :ticks, :max_ticks, :teams

def initialize(arena, max_ticks = nil)
def initialize(arena, max_ticks = nil, teams = false)
@arena = arena
@max_ticks = max_ticks
@teams = teams
@ticks = 0
@shells = TickGroup.new
@bots = TickGroup.new
Expand All @@ -21,7 +22,7 @@ def max_ticks_reached?

def finished?
@stopped || self.max_ticks_reached? || self.bots.count <= 1 ||
self.bots.map(&:name).uniq.size == 1
(self.teams && self.bots.map(&:name).uniq.size == 1)
end

def add_bots(*bots)
Expand Down

0 comments on commit 967b6b6

Please sign in to comment.