From: Daigo Moriwaki Date: Sat, 7 Apr 2018 06:07:34 +0000 (+0900) Subject: [shogi-server] Give more penalty on assigning matches with same players. (Closes... X-Git-Tag: 20180407^2 X-Git-Url: http://git.osdn.net/view?p=shogi-server%2Fshogi-server.git;a=commitdiff_plain;h=e40247f1908aadad6ed15e89a3b6bde935960095 [shogi-server] Give more penalty on assigning matches with same players. (Closes #38178) --- diff --git a/changelog b/changelog index 75667d2..707b575 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,9 @@ +2018-04-07 Daigo Moriwaki + + * [shogi-server] Give more penalty on assigning matches with same + players. + (Closes #38178) + 2017-09-03 Daigo Moriwaki * [shogi-server] Write game results in categorical files diff --git a/shogi_server/pairing.rb b/shogi_server/pairing.rb index cc2ea62..f2094e8 100644 --- a/shogi_server/pairing.rb +++ b/shogi_server/pairing.rb @@ -496,6 +496,11 @@ module ShogiServer (history.last_opponent(p1.player_id) == p2.player_id || history.last_opponent(p2.player_id) == p1.player_id)) ret += 400 + if p1.estimated_rate != 0 || p2.estimated_rate != 0 + # unrated players should make games with various players. + very_large = 4000 + ret += very_large + end end # 2.2 Human vs Human diff --git a/test/TC_pairing.rb b/test/TC_pairing.rb index 86970ca..aa49ea9 100644 --- a/test/TC_pairing.rb +++ b/test/TC_pairing.rb @@ -424,6 +424,11 @@ class TestLeastDiff < Test::Unit::TestCase @abcdxyz.name = "abcdxyz" @abcdxyz.rate = 2300 + @unrated = ShogiServer::BasicPlayer.new + @unrated.player_id = "unrated" + @unrated.name = "unrated" + @unrated.estimated_rate = 450 + $league.add(@a) $league.add(@b) $league.add(@c) @@ -580,6 +585,32 @@ class TestLeastDiff < Test::Unit::TestCase assert_equal(@abcdefg2.rate - @abcdefg1.rate + 800, @pairing.calculate_diff_with_penalty(players,nil)) end + def test_calculate_diff_with_unrated_player + players = [@unrated, @a] + dummy = nil + def @history.make_record(game_result) + {:game_id => "wdoor+floodgate-900-0-a-unrated-1", + :black => "a", :white => "unrated", + :winner => "unrated", :loser => "a"} + end + @history.update(dummy) + assert_equal(4000 + 400 + (@a.rate - @unrated.estimated_rate).abs, + @pairing.calculate_diff_with_penalty(players,@history)) + end + + def test_calculate_diff_with_unrated_player_2 + players = [@a, @unrated] + dummy = nil + def @history.make_record(game_result) + {:game_id => "wdoor+floodgate-900-0-a-unrated-1", + :black => "a", :white => "unrated", + :winner => "unrated", :loser => "a"} + end + @history.update(dummy) + assert_equal(4000 + 400 + (@a.rate - @unrated.estimated_rate).abs, + @pairing.calculate_diff_with_penalty(players,@history)) + end + def test_get_player_rate_0 assert_equal(2150, @pairing.get_player_rate(@x, @history))