ruby_arena 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a7683767c61f9ba12e956de9c4a7ddaff97653fc
4
- data.tar.gz: 6b613e090ef7477e2c0b6bd0f4c4680fdbc67881
3
+ metadata.gz: 7853e804e75c4a2b050b17d2d1a352f7b67b10f5
4
+ data.tar.gz: aa1d37e5c373ee9c276fe017f797ae248134786f
5
5
  SHA512:
6
- metadata.gz: 3b358f8e27cecf896b8bdfd39400a5fe623d0a662505ebe63f0020f909f8e44e52c20116c2f276d95ff034903f0c42427dbe0b529922236fdb9262686465f69b
7
- data.tar.gz: ae3790d093b6a7597cd72d92cba6b7835d21e6de8d417cb741d683de54be98304221879ccc8fa16a53da05b726a58e9c3ef0be276bdf1926a2c298ae32e9fa25
6
+ metadata.gz: 90939f040ac27e8b9a7687a9cac5c12f32a04f035a1fd1f4f9c22d2e16e92ffe47c8c9e738b95c9a8f51c4c7347f3bf963573e972b8ee23be982594f3d5ca942
7
+ data.tar.gz: 12ae3cfab0cb7525401364ae3b844c2c3c296989865b706cdca83440e0dd3f5375d5c02bb9e27658b443ddaabbbdabfaf2bab6d26e8707543bfc6e6d3c587a58
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  /.rspec
2
2
  /test_robots/*
3
+ /pkg
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby_arena (0.0.1.alpha)
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!
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
- git@github.com:mrhead/ruby_arena.git
24
- cd ruby_arena
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
- ./bin/ruby_arena.rb -l 0 path_to/your_ai.rb
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
- If you have your own robot (well AI), then please publish it as gist and then add it here:
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
- * https://gist.github.com/mrhead/7917528
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. In is the same for other actions.
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
@@ -1,3 +1,4 @@
1
+ require "bundler/gem_tasks"
1
2
  require "rspec/core/rake_task"
2
3
 
3
4
  RSpec::Core::RakeTask.new(:spec)
@@ -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/level0'
14
- require 'ruby_arena/level1'
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'
@@ -3,13 +3,25 @@ module RubyArena
3
3
  LEVELS = {
4
4
  0 => {
5
5
  robots: [
6
- { ai: Level0, x: 600, y: 300 }
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: Level1, x: 600, y: 300 }
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
  }
@@ -1,5 +1,5 @@
1
1
  module RubyArena
2
- class Level0 < Ai
2
+ class Level0Ai < Ai
3
3
  def tick(events)
4
4
  end
5
5
  end
@@ -0,0 +1,6 @@
1
+ module RubyArena
2
+ class Level1Ai < Ai
3
+ def tick(events)
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ module RubyArena
2
+ class Level2Ai < Ai
3
+ def tick(events)
4
+ fire
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ module RubyArena
2
+ class Level3Ai < Ai
3
+ def tick(events)
4
+ accelerate
5
+ turn(6)
6
+ if events[:scanned_robots].any?
7
+ turn_gun(-10)
8
+ fire
9
+ end
10
+ end
11
+ end
12
+ end
@@ -40,7 +40,7 @@ module RubyArena
40
40
  execute_actions(actions)
41
41
  reset_actions
42
42
  move
43
- fix_position
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 fix_position
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
@@ -1,3 +1,3 @@
1
1
  module RubyArena
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -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::Level0, x: 600, y: 300 })
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.2
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-25 00:00:00.000000000 Z
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.txt
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/level0.rb
96
- - lib/ruby_arena/level1.rb
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
@@ -1,9 +0,0 @@
1
- module RubyArena
2
- class Level1 < Ai
3
- def tick(events)
4
- set_radar_view_angle(5)
5
- turn_gun(4)
6
- fire if events[:scanned_robots].any?
7
- end
8
- end
9
- end