Permalink
Browse files

Use all available processors.

  • Loading branch information...
1 parent 9d8fb35 commit f37fd4c896583b474bf72dae8eaa67acfc6c7667 @threedaymonk committed Oct 11, 2011
Showing with 5 additions and 1 deletion.
  1. +1 −0 Gemfile
  2. +2 −0 Gemfile.lock
  3. +2 −1 bin/fitness.rb
View
1 Gemfile
@@ -1,3 +1,4 @@
source :rubygems
gem "colored"
gem "mocha"
+gem "parallel"
View
2 Gemfile.lock
@@ -5,10 +5,12 @@ GEM
metaclass (0.0.1)
mocha (0.10.0)
metaclass (~> 0.0.1)
+ parallel (0.5.9)
PLATFORMS
ruby
DEPENDENCIES
colored
mocha
+ parallel
View
3 bin/fitness.rb
@@ -5,6 +5,7 @@
require "battleship/board"
require "battleship/util"
require "sample_boards"
+require "parallel"
SIZE = 10
FLEET = [5, 4, 3, 3, 2]
@@ -13,7 +14,7 @@
player_class = Battleship::Util.find_player_classes.first
-results = Battleship::SAMPLE_BOARDS.map{ |positions|
+results = Parallel.map(Battleship::SAMPLE_BOARDS) { |positions|
player = player_class.new
player.new_game
board = Battleship::Board.new(SIZE, FLEET, positions)

0 comments on commit f37fd4c

Please sign in to comment.