shogi-server source
Revision | f1ee2bbc2a4bdbc15079f0d0de9200a2cf6681a5 (tree) |
---|---|
Zeit | 2013-03-24 22:01:51 |
Autor | Daigo Moriwaki <daigo@debi...> |
Commiter | Daigo Moriwaki |
Fixed a bug which was found in a long test.
@@ -388,17 +388,6 @@ module ShogiServer | ||
388 | 388 | players.shuffle |
389 | 389 | end |
390 | 390 | |
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 | - | |
402 | 391 | # Returns a player's rate value. |
403 | 392 | # 1. If it has a valid rate, return the rate. |
404 | 393 | # 2. If it has no valid rate, return average of the following values: |
@@ -504,9 +493,9 @@ module ShogiServer | ||
504 | 493 | min_score = s |
505 | 494 | end |
506 | 495 | 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(" ")]) | |
508 | 497 | |
509 | - players = matches[min_index] | |
498 | + players.replace(matches[min_index]) | |
510 | 499 | end |
511 | 500 | end |
512 | 501 |
@@ -475,11 +475,12 @@ class TestLeastDiff < Test::Unit::TestCase | ||
475 | 475 | end |
476 | 476 | |
477 | 477 | def test_match_three_players |
478 | - players = [@a,@b,@h] | |
478 | + players = [@h,@a,@b] | |
479 | 479 | assert_equal(300, @pairing.calculate_diff_with_penalty([@a,@b,@h],nil)) |
480 | 480 | assert_equal(2200, @pairing.calculate_diff_with_penalty([@b,@h,@a],nil)) |
481 | 481 | r = @pairing.match(players) |
482 | 482 | assert_pairs([@a,@b,@h], r) |
483 | + assert_pairs([@a,@b,@h], players) | |
483 | 484 | end |
484 | 485 | |
485 | 486 | def test_calculate_diff_with_penalty |