<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/joshua_son_of_nun/strategy/targeting_reaction.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -62,7 +62,7 @@ class GameSimulator
     players.each do |player|
       placement = {}
       ships.each do |ship|
-        placement[ship] = Space(player.send(&quot;#{ship}_placement&quot;)).spaces_for_placement(player.send(ship).length)
+        placement[ship] = Space(player.send(&quot;#{ship}_placement&quot;)).spaces_for_placement(player.instance_variable_get(&quot;@#{ship}&quot;).length)
       end
       
       ship_placement[player.name] = placement
@@ -110,7 +110,7 @@ class GameSimulator
   end
   
   def strategy_name(player)
-    player.strategy.class.name.split(&quot;::&quot;).last
+    player.instance_variable_get('@strategy').class.name.split(&quot;::&quot;).last
   end
   
   def summarized_results</diff>
      <filename>game_simulator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,5 +8,6 @@ require 'joshua_son_of_nun/strategy/base'
 require 'joshua_son_of_nun/strategy/random'
 require 'joshua_son_of_nun/strategy/diagonal'
 require 'joshua_son_of_nun/strategy/knight'
+require 'joshua_son_of_nun/strategy/targeting_reaction'
 
 require 'joshua_son_of_nun/player'
\ No newline at end of file</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,10 +3,9 @@ module JoshuaSonOfNun
     ROWS = ('A'..'J').to_a
     COLUMNS = ('1'..'10').to_a
     
-    attr_reader :width, :height, :occupied_spaces, :valid_spaces
+    attr_reader :occupied_spaces, :valid_spaces
     
     def initialize
-      @width, @height = 10, 10
       @occupied_spaces, @valid_spaces = [], []
       ROWS.each do |row|
         COLUMNS.each do |column|
@@ -23,11 +22,9 @@ module JoshuaSonOfNun
     end
     
     def accomodate?(space, ship_length)
-      success = true
-      space.spaces_for_placement(ship_length).each do |possible_space|
+      space.spaces_for_placement(ship_length).inject(true) do |success, possible_space|
         success &amp;= !occupied_spaces.include?(possible_space) &amp;&amp; valid_spaces.include?(possible_space)
       end
-      success
     end
     
     def placement(ship_length)</diff>
      <filename>lib/joshua_son_of_nun/board.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,38 +1,35 @@
 module JoshuaSonOfNun
   class Player
-    attr_reader :personal_board, :opponent_board, :strategy
-    attr_reader :carrier, :battleship, :destroyer, :submarine, :patrolship
-    
     def battleship_placement
-      battleship.initial_placement
+      @battleship.initial_placement
     end
     
     def carrier_placement
-      carrier.initial_placement
+      @carrier.initial_placement
     end
     
     def destroyer_placement
-      destroyer.initial_placement
+      @destroyer.initial_placement
     end
     
     def patrolship_placement
-      patrolship.initial_placement
+      @patrolship.initial_placement
     end
     
     def submarine_placement
-      submarine.initial_placement
+      @submarine.initial_placement
     end
     
     def next_target
-      strategy.next_target.to_s
+      @strategy.next_target.to_s
     end
     
     def target_result(coordinates, was_hit, ship_sunk)
-      strategy.register_result! was_hit, ship_sunk
+      @strategy.register_result!(was_hit, ship_sunk)
     end
     
-    def enemy_targeting(coordinates); end
-    def game_over(result, disqualification_reason=nil); end
+    def enemy_targeting(*args); end
+    def game_over(*args); end
     
     private
       def reset(*args)
@@ -42,10 +39,10 @@ module JoshuaSonOfNun
         @opponent_board = Board.new
         
         @battleship = Battleship.new(@personal_board)
-        @carrier = Carrier.new(@personal_board)
-        @destroyer = Destroyer.new(@personal_board)
+        @carrier    = Carrier.new(@personal_board)
+        @destroyer  = Destroyer.new(@personal_board)
         @patrolship = Patrolship.new(@personal_board)
-        @submarine = Submarine.new(@personal_board)
+        @submarine  = Submarine.new(@personal_board)
         
         @strategy = Strategy.select(@opponent_board)
       end</diff>
      <filename>lib/joshua_son_of_nun/player.rb</filename>
    </modified>
    <modified>
      <diff>@@ -23,14 +23,6 @@ module JoshuaSonOfNun
       adjacent_row_range.include?(other.row_index) &amp;&amp; adjacent_column_range.include?(other.column_index)
     end
     
-    def adjacent_column_range
-      ((column_index == 0 ? 0 : column_index-1)..column_index+1)
-    end
-    
-    def adjacent_row_range
-      ((row_index == 0 ? 0 : row_index-1)..row_index+1)
-    end
-    
     def column_index
       COLUMNS.index(column)
     end
@@ -49,25 +41,15 @@ module JoshuaSonOfNun
       successful_spaces = successful_illegal_spaces.dup
       
       if row_index == other.row_index
-        left_index = (column_index &lt; other.column_index ? column_index : other.column_index)
-        right_index = left_index + 1
-        
-        left, right = surrounding_linear_spaces(left_index, right_index, illegal_spaces, successful_spaces) do |i, row, column|
-          Space.new(row, COLUMNS[i])
-        end
+        left, right = assign_left_and_right(other.column_index, illegal_spaces, successful_spaces)
       elsif column_index == other.column_index
-        top_index = (row_index &lt; other.row_index ? row_index : other.row_index)
-        bottom_index = top_index + 1
-        
-        top, bottom = surrounding_linear_spaces(top_index, bottom_index, illegal_spaces, successful_spaces) do |i, row, column|
-          Space.new(ROWS[i], column)
-        end
+        top, bottom = assign_top_and_bottom(other.row_index, illegal_spaces, successful_spaces)
       end
       
       [top, left, bottom, right].compact
     end
     
-    def linear_to?(other)
+    def linear?(other)
       row_index == other.row_index || column_index == other.column_index
     end
     
@@ -76,10 +58,9 @@ module JoshuaSonOfNun
     end
     
     def spaces_for_placement(ship_length)
-      args = if orientation == 'horizontal'
-        lambda {|i| [row, COLUMNS[column_index + i].to_s]}
-      else
-        lambda {|i| [ROWS[row_index + i].to_s, column]}
+      args = case orientation
+      when 'horizontal': lambda {|i| [row, COLUMNS[column_index + i].to_s]}
+      when 'vertical':   lambda {|i| [ROWS[row_index + i].to_s, column]}
       end
       
       (0..(ship_length - 1)).collect {|i| Space.new(*args.call(i)) rescue nil}
@@ -134,6 +115,32 @@ module JoshuaSonOfNun
     end
     
     private
+      def adjacent_column_range
+        ((column_index == 0 ? 0 : column_index-1)..column_index+1)
+      end
+      
+      def adjacent_row_range
+        ((row_index == 0 ? 0 : row_index-1)..row_index+1)
+      end
+      
+      def assign_left_and_right(other_column_index, illegal_spaces, successful_spaces)
+        left_index = (column_index &lt; other_column_index ? column_index : other_column_index)
+        right_index = left_index + 1
+        
+        surrounding_linear_spaces(left_index, right_index, illegal_spaces, successful_spaces) do |i, row, column|
+          Space.new(row, COLUMNS[i])
+        end
+      end
+      
+      def assign_top_and_bottom(other_row_index, illegal_spaces, successful_spaces)
+        top_index = (row_index &lt; other_row_index ? row_index : other_row_index)
+        bottom_index = top_index + 1
+        
+        surrounding_linear_spaces(top_index, bottom_index, illegal_spaces, successful_spaces) do |i, row, column|
+          Space.new(ROWS[i], column)
+        end
+      end
+      
       def surrounding_linear_spaces(side_one_index, side_two_index, illegal_spaces, successful_spaces, &amp;space_creation_block)
         side_one_spaces  = (0..side_one_index).collect {|i| space_creation_block.call(i, row, column)}
         side_two_spaces = (side_two_index..9).collect {|i| space_creation_block.call(i, row, column)}
@@ -153,9 +160,9 @@ module JoshuaSonOfNun
           
           [:side_one_space, :side_two_space].each do |key|
             space = spaces[key]
-            if !space.nil? &amp;&amp; unsuccessful_spaces.detect {|s| space.adjacent?(s)} &amp;&amp; !successful_spaces.detect {|s| space.adjacent?(s)}
-              spaces[key] = nil
-            end
+            spaces[key] = nil if !space.nil? &amp;&amp;
+                                 unsuccessful_spaces.detect {|s| space.adjacent?(s)} &amp;&amp;
+                                 !successful_spaces.detect {|s| space.adjacent?(s)}
           end
         end
         </diff>
      <filename>lib/joshua_son_of_nun/space.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 module JoshuaSonOfNun
   module Strategy
     def self.strategies
-      [['Random']*3, 'Diagonal', ['Knight']*2].flatten
+      [['Random']*4, 'Diagonal', ['Knight']*2].flatten
     end
     
     def self.select(board)
@@ -9,23 +9,18 @@ module JoshuaSonOfNun
     end
     
     class Base
-      attr_reader :board, :current_target, :expended_targets, :immediate_targets,
+      attr_reader :current_target, :expended_targets, :immediate_targets,
                   :possible_targets, :successful_targets, :targets
       
       def initialize(board)
-        @board = board
-        @possible_targets = @board.valid_spaces.dup
+        @possible_targets = board.valid_spaces.dup
         @targets = assign_targets
         @expended_targets, @successful_targets, @immediate_targets = [], [], []
       end
       
       def next_target
-        new_target = immediate_targets.shift
-        unless new_target.nil?
-          targets.delete(new_target)
-        else
-          new_target = targets.shift
-        end
+        new_target = immediate_targets.shift || targets.first
+        targets.delete(new_target)
         
         @current_target = new_target
         expended_targets &lt;&lt; @current_target
@@ -48,38 +43,5 @@ module JoshuaSonOfNun
           Space.directions[rand(Space.directions.size)]
         end
     end
-    
-    class TargetingReaction
-      attr_reader :strategy, :ship_sunk
-      
-      alias_method :ship_sunk?, :ship_sunk
-      
-      def initialize(strategy, ship_sunk)
-        @strategy, @ship_sunk = strategy, ship_sunk
-      end
-      
-      def react!
-        return [] if ship_sunk?
-        
-        if targets_lined_up?
-          targets = strategy.successful_targets
-          reject_expended(targets[-2].linear_spaces(targets.last, strategy.expended_targets, strategy.successful_targets))
-        else
-          reject_expended(strategy.current_target.crosswise_spaces)
-        end
-      end
-      
-      protected
-        def reject_expended(spaces)
-          spaces.reject do |space|
-            strategy.expended_targets.include?(space)
-          end
-        end
-        
-        def targets_lined_up?
-          targets = strategy.successful_targets
-          targets.size &gt; 1 &amp;&amp; targets[-2].linear_to?(targets.last)
-        end
-    end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/joshua_son_of_nun/strategy/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,11 +5,6 @@ describe JoshuaSonOfNun::Board do
     @model = JoshuaSonOfNun::Board.new
   end
   
-  it &quot;should have a width and height&quot; do
-    @model.width.should == 10
-    @model.height.should == 10
-  end
-  
   it &quot;should know about which spaces are valid&quot; do
     @model.valid_spaces.should include(Space('A1'))
     @model.valid_spaces.should include(Space('A10'))</diff>
      <filename>spec/joshua_son_of_nun/board_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,29 +5,18 @@ describe JoshuaSonOfNun::Player do
     @model = JoshuaSonOfNun::Player.new
   end
   
-  it &quot;should know about it's ships&quot; do
-    @model.carrier.should_not be_nil
-    @model.battleship.should_not be_nil
-    @model.destroyer.should_not be_nil
-    @model.submarine.should_not be_nil
-    @model.patrolship.should_not be_nil
-  end
-  
-  it &quot;should have a game board&quot; do
-    @model.personal_board.should_not be_nil
-    @model.opponent_board.should_not be_nil
-  end
-  
   it &quot;should conform to the battleship API&quot; do
-    100.times do
-      @model.next_target.should_not == ''
-    end
-    lambda {@model.target_result('A1', false, false)}.should_not raise_error
-    lambda {@model.new_game('bob')}.should_not raise_error
     @model.carrier_placement.should_not be_nil
     @model.battleship_placement.should_not be_nil
     @model.destroyer_placement.should_not be_nil
     @model.submarine_placement.should_not be_nil
     @model.patrolship_placement.should_not be_nil
+    
+    100.times do
+      @model.next_target.should_not == ''
+    end
+    
+    lambda {@model.target_result('A1', false, false)}.should_not raise_error
+    lambda {@model.new_game('bob')}.should_not raise_error
   end
 end
\ No newline at end of file</diff>
      <filename>spec/joshua_son_of_nun/player_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>fcf66e9e8608ffbaca7f109b3367aefb9f893899</id>
    </parent>
  </parents>
  <author>
    <name>Steve Iannopollo</name>
    <email>steve@iannopollo.com</email>
  </author>
  <url>http://github.com/siannopollo/joshua_son_of_nun/commit/9de3cdc5320673520a1b9010c18ce3f8a11391cd</url>
  <id>9de3cdc5320673520a1b9010c18ce3f8a11391cd</id>
  <committed-date>2008-11-29T14:16:28-08:00</committed-date>
  <authored-date>2008-11-29T14:16:28-08:00</authored-date>
  <message>Small refactorings</message>
  <tree>211347f20e0f6c1881c02d151c32ddb89b398494</tree>
  <committer>
    <name>Steve Iannopollo</name>
    <email>steve@iannopollo.com</email>
  </committer>
</commit>
