OSDN Git Service

When there are odd players, RandomPairing will delete a player at random.
authorbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Sun, 17 Feb 2008 11:03:46 +0000 (11:03 +0000)
committerbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Sun, 17 Feb 2008 11:03:46 +0000 (11:03 +0000)
pairing.rb

index c497eff..b922aa4 100644 (file)
@@ -37,6 +37,7 @@ module ShogiServer
     end
     
     def delete_most_playing_player(players)
+      # TODO ??? undefined method `<=>' for nil:NilClass
       max_player = players.max {|a,b| a.win + a.loss <=> b.win + b.loss}
       return players.delete(max_player)
     end
@@ -74,7 +75,7 @@ module ShogiServer
       return if players.size < 2
 
       if players.size % 2 == 1
-        delete_most_playing_player(players)
+        delete_player_at_random(players)
       end
       pairing_and_start_game(players)
     end