sergeant_simple 1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ require 'rake'
2
+ require 'spec/rake/spectask'
3
+
4
+ desc "Run all examples with RCov"
5
+ Spec::Rake::SpecTask.new('spec_with_rcov') do |t|
6
+ t.spec_files = FileList['spec/**/*.rb']
7
+ t.rcov = true
8
+ t.rcov_opts = ['-t', '--exclude', 'spec', '--no-html']
9
+ end
data/Rakefile ADDED
@@ -0,0 +1,42 @@
1
+ require 'rake'
2
+ require 'rake/gempackagetask'
3
+ require 'spec/rake/spectask'
4
+ require 'battleship_tournament/submit'
5
+
6
+ desc "Run all specs"
7
+ Spec::Rake::SpecTask.new('spec') do |t|
8
+ t.spec_files = FileList['spec/**/*.rb']
9
+ t.rcov = false
10
+ end
11
+
12
+ PKG_NAME = "sergeant_simple"
13
+ PKG_VERSION = "1.0"
14
+ PKG_TAG = "sergeant_simple-1_0"
15
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
16
+
17
+ spec = Gem::Specification.new do |s|
18
+ s.name = PKG_NAME
19
+ s.version = PKG_VERSION
20
+ s.files = FileList['**/*'].to_a
21
+ s.require_path = 'lib'
22
+ s.test_files = Dir.glob('spec/*_spec.rb')
23
+ s.bindir = 'bin'
24
+ s.executables = []
25
+
26
+ s.summary = "Battleship Player:Sergeant Simple"
27
+
28
+ s.description = "A very simple player."
29
+ s.author = "Micah Martin"
30
+ s.email = "micah@8thlight.com"
31
+ end
32
+
33
+ Rake::GemPackageTask.new(spec) do |pkg|
34
+ pkg.need_zip = false
35
+ pkg.need_tar = false
36
+ end
37
+
38
+ desc "Submit your player"
39
+ task :submit do
40
+ submitter = BattleshipTournament::Submit.new(PKG_NAME)
41
+ submitter.submit
42
+ end
@@ -0,0 +1,70 @@
1
+ module SergeantSimple
2
+ class SergeantSimple
3
+
4
+ def name
5
+ return "Sergeant Simple"
6
+ end
7
+
8
+ def new_game(opponent_name)
9
+ reset
10
+ end
11
+
12
+ def carrier_placement
13
+ return "A1 horizontal"
14
+ end
15
+
16
+ def battleship_placement
17
+ return "B1 horizontal"
18
+ end
19
+
20
+ def destroyer_placement
21
+ return "C1 horizontal"
22
+ end
23
+
24
+ def submarine_placement
25
+ return "D1 horizontal"
26
+ end
27
+
28
+ def patrolship_placement
29
+ return "E1 horizontal"
30
+ end
31
+
32
+ def next_target
33
+ target = target_for_current_shot
34
+ @shots_taken += 1
35
+ return target
36
+ end
37
+
38
+ def target_result(coordinates, was_hit, ship_sunk)
39
+ end
40
+
41
+ def enemy_targeting(coordinates)
42
+ end
43
+
44
+ def game_over(result, disqualification_reason=nil)
45
+ end
46
+
47
+ # Non API methods #####################################
48
+
49
+ attr_reader :targets, :enemy_targeted_sectors
50
+
51
+ def initialize
52
+ reset
53
+ end
54
+
55
+ private ###############################################
56
+
57
+ def reset
58
+ @shots_taken = 0
59
+ end
60
+
61
+ ROWS = %w{ A B C D E F G H I J }
62
+ def target_for_current_shot
63
+ row = ROWS[(@shots_taken) / 10]
64
+ col = @shots_taken % 10 + 1
65
+ return "#{row}#{col}"
66
+ end
67
+
68
+ end
69
+
70
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+ require 'sergeant_simple/sergeant_simple'
3
+
4
+ describe SergeantSimple::SergeantSimple do
5
+
6
+
7
+ end
@@ -0,0 +1,4 @@
1
+ $: << File.expand_path(File.dirname(__FILE__) + "/../lib")
2
+
3
+ require 'rubygems'
4
+ require 'spec'
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sergeant_simple
3
+ version: !ruby/object:Gem::Version
4
+ version: "1.0"
5
+ platform: ruby
6
+ authors:
7
+ - Micah Martin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-03 00:00:00 -06:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: A very simple player.
17
+ email: micah@8thlight.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - Battleship.Rakefile
26
+ - lib
27
+ - lib/sergeant_simple
28
+ - lib/sergeant_simple/sergeant_simple.rb
29
+ - Rakefile
30
+ - spec
31
+ - spec/sergeant_simple
32
+ - spec/sergeant_simple/sergeant_simple_spec.rb
33
+ - spec/spec_helper.rb
34
+ has_rdoc: false
35
+ homepage:
36
+ post_install_message:
37
+ rdoc_options: []
38
+
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ version:
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ version:
53
+ requirements: []
54
+
55
+ rubyforge_project:
56
+ rubygems_version: 1.2.0
57
+ signing_key:
58
+ specification_version: 2
59
+ summary: Battleship Player:Sergeant Simple
60
+ test_files: []
61
+