<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -25,9 +25,6 @@ module RPS
         
         puts round if @verbose
       end
-      
-      puts &quot;------------------&quot;
-      puts self
     end
     
     def wins(player)
@@ -52,6 +49,7 @@ module RPS
     end
     
     def to_s
+      puts &quot;------------------&quot;
       result = &quot;&quot;
       if winner
         result &lt;&lt; &quot;Winner is #{winner}\n&quot;</diff>
      <filename>lib/game.rb</filename>
    </modified>
    <modified>
      <diff>@@ -30,13 +30,13 @@ module RPS
       end
       result
     end
-    
+
    private
-   
+
     def execute
       @first_player_move = first_player.next
       @second_player_move = second_player.next
-      
+
       if first_player_move &gt; second_player_move
         @winner = first_player
       elsif first_player_move &lt; second_player_move
@@ -45,6 +45,5 @@ module RPS
         @winner = false
       end
     end
-    
   end
 end</diff>
      <filename>lib/round.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,53 +1,81 @@
 require 'lib/move'
+require 'thread'
 
 module RPS
   MOVES = [Move.new(:rock, :paper), Move.new(:scissors, :rock), Move.new(:paper, :scissors)].freeze
   @@bots = []
-  
+  @@threaded = false
+  @@options = %w{ --threaded }
+
   def self.add(bot_klass)
     @@bots &lt;&lt; bot_klass
   end
-  
+
   def self.bots
     @@bots
   end
 
-  def self.select(bots)
-    return if bots.empty?
-    @@bots.reject! {|b| !bots.include?(b.to_s)}
+  def self.extract_bots(options)
+    options - @@options
+  end
+
+  def self.set_options(options)
+    @@threaded = options.include?('--threaded')
   end
 
-  def self.run(bots)
-    select(bots)
+  def self.select_bots(options)
+    return if options.empty?
+    @@bots.reject {|b| options.include?(b.to_s)}
+  end
+
+  def self.run(options)
+    set_options(options)
+    select_bots(extract_bots(options))
     game_record = {}
     @@bots.each do |bot|
       game_record[bot] = {:wins =&gt; 0, :losses =&gt; 0, :draws =&gt; 0}
     end
-    
+
+    puts 'Running in parallel' if @@threaded
+
+    lock = Mutex.new
+    t = []
+
     @@bots.each do |bot|
       (@@bots - [bot]).each do |other_bot|
-        game = Game.new(bot, other_bot)
-        game.execute
-
-        
-        if game.winner.class == bot
-          game_record[bot][:wins]        += 1
-          game_record[other_bot][:losses] += 1
-        elsif game.winner.class == other_bot
-          game_record[other_bot][:wins]  += 1
-          game_record[bot][:losses]       += 1
+        if @@threaded
+          t &lt;&lt; Thread.new do
+            game(bot, other_bot, game_record, lock)
+          end
         else
-          game_record[other_bot][:draws] += 1
-          game_record[bot][:draws]       += 1
+          game(bot, other_bot, game_record, lock)
         end
       end
     end
-    
-    
+
+    t.each {|thread| thread.join} if @@threaded
+
     puts &quot;------------------\n\n&quot;
     game_record.each do |bot, data|
       puts bot.to_s + &quot;\t\tW#{data[:wins]}, L#{data[:losses]}, D#{data[:draws]}&quot;
-      
+    end
+  end
+
+  def self.game(bot, other_bot, game_record, lock)
+    game = Game.new(bot, other_bot)
+    game.execute
+    lock.synchronize do
+      if game.winner.class == bot
+        game_record[bot][:wins]        += 1
+        game_record[other_bot][:losses] += 1
+      elsif game.winner.class == other_bot
+        game_record[other_bot][:wins]  += 1
+        game_record[bot][:losses]       += 1
+      else
+        game_record[other_bot][:draws] += 1
+        game_record[bot][:draws]       += 1
+      end
+      puts game
     end
   end
 end</diff>
      <filename>lib/rps.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b58cc1f83fc75bf336692aefc09a928efebfd412</id>
    </parent>
  </parents>
  <author>
    <name>wmoxam</name>
    <email>wesley.moxam@savvica.com</email>
  </author>
  <url>http://github.com/wmoxam/rubyrps/commit/0c9ad1b880ef1b8cc4a9a3615087d5fa6db9ec90</url>
  <id>0c9ad1b880ef1b8cc4a9a3615087d5fa6db9ec90</id>
  <committed-date>2008-08-08T10:29:23-07:00</committed-date>
  <authored-date>2008-08-08T10:29:23-07:00</authored-date>
  <message>Can run the matches in parallel now
./run --threaded</message>
  <tree>b148fa46159a2d08292f4f8923e9fbfd510b8eb4</tree>
  <committer>
    <name>wmoxam</name>
    <email>wesley.moxam@savvica.com</email>
  </committer>
</commit>
