• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

shogi-server source


Commit MetaInfo

Revisionf1ee2bbc2a4bdbc15079f0d0de9200a2cf6681a5 (tree)
Zeit2013-03-24 22:01:51
AutorDaigo Moriwaki <daigo@debi...>
CommiterDaigo Moriwaki

Log Message

Fixed a bug which was found in a long test.

Ändern Zusammenfassung

Diff

--- a/shogi_server/pairing.rb
+++ b/shogi_server/pairing.rb
@@ -388,17 +388,6 @@ module ShogiServer
388388 players.shuffle
389389 end
390390
391- def average_rate(players)
392- n=0
393- sum=0
394- players.find_all{|p| p.rate}.each do |p|
395- n += 1
396- sum += p.rate
397- end
398-
399- return n > 0 ? sum/n : 2150 # interger
400- end
401-
402391 # Returns a player's rate value.
403392 # 1. If it has a valid rate, return the rate.
404393 # 2. If it has no valid rate, return average of the following values:
@@ -504,9 +493,9 @@ module ShogiServer
504493 min_score = s
505494 end
506495 end
507- log_message("Floodgate: the least score %d (%d per player)" % [min_score, min_score/players.size])
496+ log_message("Floodgate: the least score %d (%d per player) [%s]" % [min_score, min_score/players.size, scores.join(" ")])
508497
509- players = matches[min_index]
498+ players.replace(matches[min_index])
510499 end
511500 end
512501
--- a/test/TC_pairing.rb
+++ b/test/TC_pairing.rb
@@ -475,11 +475,12 @@ class TestLeastDiff < Test::Unit::TestCase
475475 end
476476
477477 def test_match_three_players
478- players = [@a,@b,@h]
478+ players = [@h,@a,@b]
479479 assert_equal(300, @pairing.calculate_diff_with_penalty([@a,@b,@h],nil))
480480 assert_equal(2200, @pairing.calculate_diff_with_penalty([@b,@h,@a],nil))
481481 r = @pairing.match(players)
482482 assert_pairs([@a,@b,@h], r)
483+ assert_pairs([@a,@b,@h], players)
483484 end
484485
485486 def test_calculate_diff_with_penalty