ruby_arena 0.0.2 → 0.0.3
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/.gitignore +1 -0
- data/Gemfile.lock +2 -2
- data/{LICENSE.txt → LICENSE.md} +0 -0
- data/README.md +15 -20
- data/Rakefile +1 -0
- data/lib/ruby_arena.rb +4 -2
- data/lib/ruby_arena/level.rb +15 -3
- data/lib/ruby_arena/{level0.rb → levels/level0_ai.rb} +1 -1
- data/lib/ruby_arena/levels/level1_ai.rb +6 -0
- data/lib/ruby_arena/levels/level2_ai.rb +7 -0
- data/lib/ruby_arena/levels/level3_ai.rb +12 -0
- data/lib/ruby_arena/robot.rb +2 -2
- data/lib/ruby_arena/version.rb +1 -1
- data/spec/level_spec.rb +2 -2
- metadata +7 -5
- data/lib/ruby_arena/level1.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7853e804e75c4a2b050b17d2d1a352f7b67b10f5
|
4
|
+
data.tar.gz: aa1d37e5c373ee9c276fe017f797ae248134786f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90939f040ac27e8b9a7687a9cac5c12f32a04f035a1fd1f4f9c22d2e16e92ffe47c8c9e738b95c9a8f51c4c7347f3bf963573e972b8ee23be982594f3d5ca942
|
7
|
+
data.tar.gz: 12ae3cfab0cb7525401364ae3b844c2c3c296989865b706cdca83440e0dd3f5375d5c02bb9e27658b443ddaabbbdabfaf2bab6d26e8707543bfc6e6d3c587a58
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ruby_arena (0.0.
|
4
|
+
ruby_arena (0.0.3.pre.alpha)
|
5
|
+
gosu
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
@@ -25,7 +26,6 @@ PLATFORMS
|
|
25
26
|
|
26
27
|
DEPENDENCIES
|
27
28
|
bundler (~> 1.5)
|
28
|
-
gosu
|
29
29
|
rake
|
30
30
|
rspec (~> 3.0.0.beta1)
|
31
31
|
ruby_arena!
|
data/{LICENSE.txt → LICENSE.md}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -20,40 +20,28 @@ This project has been inspired by [robocode][robocode] (Java, .NET) and [rrobots
|
|
20
20
|
## How to run arena (and battles)
|
21
21
|
|
22
22
|
```
|
23
|
-
|
24
|
-
|
25
|
-
bundle # or gem install gosu
|
26
|
-
./bin/ruby_arena.rb path_to/robot.rb path_to/another_robot.rb
|
23
|
+
gem install ruby_arena
|
24
|
+
ruby_arena path_to/robot.rb path_to/another_robot.rb
|
27
25
|
```
|
28
26
|
|
29
27
|
You can run game with some predefined robots (levels).
|
30
28
|
|
31
29
|
```
|
32
|
-
|
33
|
-
```
|
34
|
-
|
35
|
-
You can see example robot here: https://gist.github.com/mrhead/7917528. Just put it to some dir in ruby_arena.
|
36
|
-
|
37
|
-
```
|
38
|
-
./bin/ruby_arena.rb test_robots/test_ai.rb test_robots/test_ai.rb # ...
|
30
|
+
ruby_arena -l 0 path_to/your_ai.rb
|
39
31
|
```
|
40
32
|
|
41
33
|
### Example robots (AIs)
|
42
34
|
|
43
|
-
|
35
|
+
You can use [source code of level robots](https://github.com/mrhead/ruby_arena/tree/master/lib/ruby_arena/levels) as reference.
|
44
36
|
|
45
|
-
|
46
|
-
* https://gist.github.com/mrhead/8086991
|
47
|
-
* https://gist.github.com/mrhead/8087011
|
48
|
-
|
49
|
-
Please note that mentioned Ais are not were nice (code) and pretty stupid right now, but at least you can try to run them.
|
37
|
+
If you have your own robots (well AIs), then feel free to publish them as gists and add them here.
|
50
38
|
|
51
39
|
### How to create your own robot (AI)
|
52
40
|
|
53
|
-
Just extend `Ai` class and implement your own `#tick` method.
|
41
|
+
Just extend `RubyArena::Ai` class and implement your own `#tick` method.
|
54
42
|
|
55
43
|
```
|
56
|
-
class TestAi < Ai
|
44
|
+
class TestAi < RubyArena::Ai
|
57
45
|
def tick(events)
|
58
46
|
fire # do nothing but fire when possible
|
59
47
|
end
|
@@ -94,7 +82,7 @@ turn(2)
|
|
94
82
|
turn(2)
|
95
83
|
```
|
96
84
|
|
97
|
-
Will do just turn by 2 degrees.
|
85
|
+
Will do just turn by 2 degrees. It is the same for other actions.
|
98
86
|
|
99
87
|
## Current status
|
100
88
|
|
@@ -114,5 +102,12 @@ However you can already start the game and the battle between robots! Detais wer
|
|
114
102
|
* 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.
|
115
103
|
* If something is hard to implement or change, then please refactor the code first so change is easy and then implement it.
|
116
104
|
|
105
|
+
### Contributors
|
106
|
+
|
107
|
+
I would like to thank to each of the [contributors](https://github.com/mrhead/ruby_arena/graphs/contributors).
|
108
|
+
|
109
|
+
## License
|
110
|
+
|
111
|
+
[MIT LICENSE](https://github.com/mrhead/ruby_arena/blob/master/LICENSE.md)
|
117
112
|
[robocode]: http://robocode.sourceforge.net/
|
118
113
|
[rrobots]: http://rrobots.rubyforge.org/
|
data/Rakefile
CHANGED
data/lib/ruby_arena.rb
CHANGED
@@ -10,8 +10,10 @@ require 'ruby_arena/gui'
|
|
10
10
|
require 'ruby_arena/value_sanitizer'
|
11
11
|
require 'ruby_arena/movable'
|
12
12
|
require 'ruby_arena/robot'
|
13
|
-
require 'ruby_arena/
|
14
|
-
require 'ruby_arena/
|
13
|
+
require 'ruby_arena/levels/level0_ai'
|
14
|
+
require 'ruby_arena/levels/level1_ai'
|
15
|
+
require 'ruby_arena/levels/level2_ai'
|
16
|
+
require 'ruby_arena/levels/level3_ai'
|
15
17
|
require 'ruby_arena/level'
|
16
18
|
require 'ruby_arena/game'
|
17
19
|
require 'ruby_arena/bullet'
|
data/lib/ruby_arena/level.rb
CHANGED
@@ -3,13 +3,25 @@ module RubyArena
|
|
3
3
|
LEVELS = {
|
4
4
|
0 => {
|
5
5
|
robots: [
|
6
|
-
{ ai:
|
6
|
+
{ ai: Level0Ai, x: 600, y: 300, heading: 90 }
|
7
7
|
],
|
8
|
-
user_robot_options: { x: 200, y: 300 }
|
8
|
+
user_robot_options: { x: 200, y: 300, heading: 90 }
|
9
9
|
},
|
10
10
|
1 => {
|
11
11
|
robots: [
|
12
|
-
{ ai:
|
12
|
+
{ ai: Level1Ai, x: 600, y: 300, heading: 90 }
|
13
|
+
],
|
14
|
+
user_robot_options: { x: 200, y: 300, heading: -90 }
|
15
|
+
},
|
16
|
+
2 => {
|
17
|
+
robots: [
|
18
|
+
{ ai: Level2Ai, x: 600, y: 300, heading: -90, energy: 200 }
|
19
|
+
],
|
20
|
+
user_robot_options: { x: 200, y: 300, heading: 90 }
|
21
|
+
},
|
22
|
+
3 => {
|
23
|
+
robots: [
|
24
|
+
{ ai: Level3Ai, x: 600, y: 300 }
|
13
25
|
],
|
14
26
|
user_robot_options: { x: 200, y: 300 }
|
15
27
|
}
|
data/lib/ruby_arena/robot.rb
CHANGED
@@ -40,7 +40,7 @@ module RubyArena
|
|
40
40
|
execute_actions(actions)
|
41
41
|
reset_actions
|
42
42
|
move
|
43
|
-
|
43
|
+
keep_robot_in_arena
|
44
44
|
end
|
45
45
|
|
46
46
|
def execute_actions(actions)
|
@@ -166,7 +166,7 @@ module RubyArena
|
|
166
166
|
arena.robots.find_all { |robot| robot != self }
|
167
167
|
end
|
168
168
|
|
169
|
-
def
|
169
|
+
def keep_robot_in_arena
|
170
170
|
@x = min_x if x < min_x
|
171
171
|
@x = max_x if x > max_x
|
172
172
|
@y = min_y if y < min_y
|
data/lib/ruby_arena/version.rb
CHANGED
data/spec/level_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe RubyArena::Level do
|
|
15
15
|
it 'returns options for cpu robots' do
|
16
16
|
level = RubyArena::Level.new(0)
|
17
17
|
|
18
|
-
expect(level.options_for_cpu_robots.first).to eq({ ai: RubyArena::
|
18
|
+
expect(level.options_for_cpu_robots.first).to eq({ ai: RubyArena::Level0Ai, x: 600, y: 300, heading: 90 })
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -23,7 +23,7 @@ describe RubyArena::Level do
|
|
23
23
|
it 'returns options for user robot' do
|
24
24
|
level = RubyArena::Level.new(0)
|
25
25
|
|
26
|
-
expect(level.options_for_user_robot).to eq({ x: 200, y: 300 })
|
26
|
+
expect(level.options_for_user_robot).to eq({ x: 200, y: 300, heading: 90 })
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_arena
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrik Bóna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|
@@ -78,7 +78,7 @@ files:
|
|
78
78
|
- ".travis.yml"
|
79
79
|
- Gemfile
|
80
80
|
- Gemfile.lock
|
81
|
-
- LICENSE.
|
81
|
+
- LICENSE.md
|
82
82
|
- README.md
|
83
83
|
- Rakefile
|
84
84
|
- bin/ruby_arena
|
@@ -92,8 +92,10 @@ files:
|
|
92
92
|
- lib/ruby_arena/game.rb
|
93
93
|
- lib/ruby_arena/gui.rb
|
94
94
|
- lib/ruby_arena/level.rb
|
95
|
-
- lib/ruby_arena/
|
96
|
-
- lib/ruby_arena/
|
95
|
+
- lib/ruby_arena/levels/level0_ai.rb
|
96
|
+
- lib/ruby_arena/levels/level1_ai.rb
|
97
|
+
- lib/ruby_arena/levels/level2_ai.rb
|
98
|
+
- lib/ruby_arena/levels/level3_ai.rb
|
97
99
|
- lib/ruby_arena/movable.rb
|
98
100
|
- lib/ruby_arena/option_parser.rb
|
99
101
|
- lib/ruby_arena/robot.rb
|