rtanque 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +30 -0
- data/bin/rtanque +2 -1
- data/lib/rtanque/configuration.rb +2 -1
- data/lib/rtanque/gui/window.rb +1 -0
- data/lib/rtanque/heading.rb +2 -2
- data/lib/rtanque/match/tick_group.rb +2 -2
- data/lib/rtanque/match.rb +6 -4
- data/lib/rtanque/shell.rb +6 -2
- data/lib/rtanque/version.rb +1 -1
- data/sample_bots/seek_and_destroy.rb +3 -1
- data/spec/rtanque/match_spec.rb +10 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5f4b4408532ba416d2572aac6a6173f412fd99a
|
4
|
+
data.tar.gz: 1d4995cb500186090ceb317fac267fb65ea21a3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1461a7bc912bc9eb9546042d6972695d27a1339639c5a6859c05b2799cf229f00fd4987042d750d4d7ba68bf067cd5ab5a551795a1b65c70058e89b0a8cf5689
|
7
|
+
data.tar.gz: 4787e52d89f835655e7ef722d628554bc9bf9371dd4a75e7235cd219d60f72c4b5dd3dc45f871c0372e72a65e57146499684511dac70f39cbbe8944c7c6b2c73
|
data/README.md
CHANGED
@@ -50,6 +50,36 @@ Make a project directory, init bundler, add the RTanque gem, and create a bot:
|
|
50
50
|
* [RTanque::Heading](http://rubydoc.info/github/awilliams/RTanque/master/frames/RTanque/Heading)
|
51
51
|
* [RTanque::Point](http://rubydoc.info/github/awilliams/RTanque/master/frames/RTanque/Point)
|
52
52
|
|
53
|
+
## Advanced Options
|
54
|
+
|
55
|
+
Set arena dimensions
|
56
|
+
|
57
|
+
$ bundle exec rtanque start --width=400 --height=400 sample_bots/camper:x4
|
58
|
+
|
59
|
+
Adjust max ticks allowed
|
60
|
+
|
61
|
+
$ bundle exec rtanque start --max_ticks=500 sample_bots/camper:x4
|
62
|
+
|
63
|
+
Run headless match (no gui)
|
64
|
+
|
65
|
+
$ bundle exec rtanque start --gui=false sample_bots/camper:x4
|
66
|
+
|
67
|
+
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
|
68
|
+
|
69
|
+
$ bundle exec rtanque start --teams sample_bots/camper:x4 sample_bots/seek_and_destroy.rb:4
|
70
|
+
|
71
|
+
Quiet mode (less console chatter).
|
72
|
+
|
73
|
+
$ bundle exec rtanque start --quiet sample_bots/camper:x4
|
74
|
+
|
75
|
+
Set random number seed, allowing same battle to be repeated. https://github.com/awilliams/RTanque/pull/7
|
76
|
+
|
77
|
+
$ bundle exec rtanque start --seed 1234 sample_bots/camper:x4
|
78
|
+
|
79
|
+
**Experimental** Disable garbage collection during match
|
80
|
+
|
81
|
+
$ bundle exec rtanque start --gc=false sample_bots/camper:x4
|
82
|
+
|
53
83
|
## Sharing
|
54
84
|
At some point you'll want to compete against other bots, or maybe you'll even organize a small tournament. Sharing bots is easy.
|
55
85
|
|
data/bin/rtanque
CHANGED
@@ -23,13 +23,14 @@ LONGDESC
|
|
23
23
|
method_option :width, :aliases => '-w', :default => 1200, :type => :numeric, :banner => 'width of window'
|
24
24
|
method_option :height, :aliases => '-h', :default => 700, :type => :numeric, :banner => 'height of window'
|
25
25
|
method_option :max_ticks, :aliases => '-m', :default => Float::INFINITY, :type => :numeric, :banner => 'max ticks allowed per match'
|
26
|
+
method_option :teams, :default => false, :type => :boolean, :banner => 'true to do a team based match based on tank names'
|
26
27
|
method_option :gui, :default => true, :type => :boolean, :banner => 'false to run headless'
|
27
28
|
method_option :gc, :default => true, :type => :boolean, :banner => 'disable GC (EXPERIMENTAL)'
|
28
29
|
method_option :quiet, :aliases => '-q', :default => false, :type => :boolean, :banner => 'disable chatter'
|
29
30
|
method_option :seed, :default => Kernel.srand, :type => :numeric, :banner => 'random number seed value'
|
30
31
|
def start(*brain_paths)
|
31
32
|
Kernel.srand(options[:seed])
|
32
|
-
runner = RTanque::Runner.new(options[:width], options[:height], options[:max_ticks])
|
33
|
+
runner = RTanque::Runner.new(options[:width], options[:height], options[:max_ticks], options[:teams])
|
33
34
|
brain_paths.each { |brain_path|
|
34
35
|
begin
|
35
36
|
runner.add_brain_path(brain_path)
|
@@ -6,6 +6,7 @@ module RTanque
|
|
6
6
|
# @!visibility private
|
7
7
|
Configuration = ::Configuration.for('default') do
|
8
8
|
raise_brain_tick_errors true
|
9
|
+
quit_when_finished true
|
9
10
|
|
10
11
|
bot do
|
11
12
|
radius 19
|
@@ -43,4 +44,4 @@ module RTanque
|
|
43
44
|
def Configuration.config(&block)
|
44
45
|
::Configuration::DSL.evaluate(self, &block)
|
45
46
|
end
|
46
|
-
end
|
47
|
+
end
|
data/lib/rtanque/gui/window.rb
CHANGED
data/lib/rtanque/heading.rb
CHANGED
@@ -78,7 +78,7 @@ module RTanque
|
|
78
78
|
def delta(to)
|
79
79
|
diff = (to.to_f - self.to_f).abs % FULL_ANGLE
|
80
80
|
diff = -(FULL_ANGLE - diff) if diff > Math::PI
|
81
|
-
to < self ? -diff : diff
|
81
|
+
to.to_f < self.to_f ? -diff : diff
|
82
82
|
end
|
83
83
|
|
84
84
|
# @return [RTanque::Heading]
|
@@ -159,4 +159,4 @@ module RTanque
|
|
159
159
|
@memoized[:to_degrees] ||= (self.radians * 180.0) / Math::PI
|
160
160
|
end
|
161
161
|
end
|
162
|
-
end
|
162
|
+
end
|
data/lib/rtanque/match.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module RTanque
|
2
2
|
class Match
|
3
|
-
attr_reader :arena, :bots, :shells, :explosions, :ticks, :max_ticks
|
3
|
+
attr_reader :arena, :bots, :shells, :explosions, :ticks, :max_ticks, :teams
|
4
4
|
|
5
|
-
def initialize(arena, max_ticks = nil)
|
5
|
+
def initialize(arena, max_ticks = nil, teams = false)
|
6
6
|
@arena = arena
|
7
7
|
@max_ticks = max_ticks
|
8
|
+
@teams = teams
|
8
9
|
@ticks = 0
|
9
10
|
@shells = TickGroup.new
|
10
11
|
@bots = TickGroup.new
|
@@ -20,7 +21,8 @@ module RTanque
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def finished?
|
23
|
-
@stopped || self.max_ticks_reached? || self.bots.count <= 1
|
24
|
+
@stopped || self.max_ticks_reached? || self.bots.count <= 1 ||
|
25
|
+
(self.teams && self.bots.map(&:name).uniq.size == 1)
|
24
26
|
end
|
25
27
|
|
26
28
|
def add_bots(*bots)
|
@@ -64,4 +66,4 @@ module RTanque
|
|
64
66
|
@ticks += 1
|
65
67
|
end
|
66
68
|
end
|
67
|
-
end
|
69
|
+
end
|
data/lib/rtanque/shell.rb
CHANGED
@@ -5,13 +5,17 @@ module RTanque
|
|
5
5
|
SHELL_SPEED_FACTOR = Configuration.shell.speed_factor
|
6
6
|
attr_reader :bot, :arena, :fire_power
|
7
7
|
|
8
|
+
def self.speed fire_power
|
9
|
+
fire_power * SHELL_SPEED_FACTOR
|
10
|
+
end
|
11
|
+
|
8
12
|
def initialize(bot, position, heading, fire_power)
|
9
13
|
@bot = bot
|
10
14
|
@arena = bot.arena
|
11
15
|
@fire_power = fire_power
|
12
16
|
self.position = position
|
13
17
|
self.heading = heading
|
14
|
-
self.speed = (fire_power
|
18
|
+
self.speed = self.class.speed(fire_power) # TODO: add bot's relative speed in this heading
|
15
19
|
@dead = false
|
16
20
|
end
|
17
21
|
|
@@ -37,4 +41,4 @@ module RTanque
|
|
37
41
|
end
|
38
42
|
end
|
39
43
|
end
|
40
|
-
end
|
44
|
+
end
|
data/lib/rtanque/version.rb
CHANGED
@@ -8,6 +8,8 @@ class SeekAndDestroy < RTanque::Bot::Brain
|
|
8
8
|
TURRET_FIRE_RANGE = RTanque::Heading::ONE_DEGREE * 5.0
|
9
9
|
|
10
10
|
def tick!
|
11
|
+
@desired_heading ||= nil
|
12
|
+
|
11
13
|
if (lock = self.get_radar_lock)
|
12
14
|
self.destroy_lock(lock)
|
13
15
|
@desired_heading = nil
|
@@ -48,4 +50,4 @@ class SeekAndDestroy < RTanque::Bot::Brain
|
|
48
50
|
@locked_on = lock.name if lock
|
49
51
|
lock
|
50
52
|
end
|
51
|
-
end
|
53
|
+
end
|
data/spec/rtanque/match_spec.rb
CHANGED
@@ -21,9 +21,18 @@ describe RTanque::Match do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'should be false if two or more bots left' do
|
24
|
-
|
24
|
+
bot1 = double('bot', :name => "bot1")
|
25
|
+
bot2 = double('bot', :name => "bot2")
|
26
|
+
@instance.add_bots(bot1, bot2)
|
25
27
|
expect(@instance.finished?).to be_false
|
26
28
|
end
|
29
|
+
|
30
|
+
it 'should be true if two or more bots left w/ same name' do
|
31
|
+
bot1 = double('bot', :name => "bot1")
|
32
|
+
bot2 = double('bot', :name => "bot1")
|
33
|
+
@instance.add_bots(bot1, bot2)
|
34
|
+
expect(@instance.finished?).to be_true
|
35
|
+
end
|
27
36
|
end
|
28
37
|
|
29
38
|
describe '#tick' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rtanque
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|
@@ -285,7 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
285
285
|
version: '0'
|
286
286
|
requirements: []
|
287
287
|
rubyforge_project:
|
288
|
-
rubygems_version: 2.0.
|
288
|
+
rubygems_version: 2.0.0
|
289
289
|
signing_key:
|
290
290
|
specification_version: 4
|
291
291
|
summary: RTanque is a game for programmers. Players program the brain of a tank and
|
@@ -300,3 +300,4 @@ test_files:
|
|
300
300
|
- spec/rtanque/shell_spec.rb
|
301
301
|
- spec/rtanque_spec.rb
|
302
302
|
- spec/spec_helper.rb
|
303
|
+
has_rdoc:
|