• R/O
  • HTTP
  • SSH
  • HTTPS

shogi-server: Commit

shogi-server source


Commit MetaInfo

Revisione40247f1908aadad6ed15e89a3b6bde935960095 (tree)
Time2018-04-07 15:07:34
AuthorDaigo Moriwaki <daigo@debi...>
CommiterDaigo Moriwaki

Log Message

[shogi-server] Give more penalty on assigning matches with same players. (Closes #38178)

Change Summary

Incremental Difference

--- a/changelog
+++ b/changelog
@@ -1,3 +1,9 @@
1+2018-04-07 Daigo Moriwaki <daigo at debian dot org>
2+
3+ * [shogi-server] Give more penalty on assigning matches with same
4+ players.
5+ (Closes #38178)
6+
17 2017-09-03 Daigo Moriwaki <daigo at debian dot org>
28
39 * [shogi-server] Write game results in categorical files
--- a/shogi_server/pairing.rb
+++ b/shogi_server/pairing.rb
@@ -496,6 +496,11 @@ module ShogiServer
496496 (history.last_opponent(p1.player_id) == p2.player_id ||
497497 history.last_opponent(p2.player_id) == p1.player_id))
498498 ret += 400
499+ if p1.estimated_rate != 0 || p2.estimated_rate != 0
500+ # unrated players should make games with various players.
501+ very_large = 4000
502+ ret += very_large
503+ end
499504 end
500505
501506 # 2.2 Human vs Human
--- a/test/TC_pairing.rb
+++ b/test/TC_pairing.rb
@@ -424,6 +424,11 @@ class TestLeastDiff < Test::Unit::TestCase
424424 @abcdxyz.name = "abcdxyz"
425425 @abcdxyz.rate = 2300
426426
427+ @unrated = ShogiServer::BasicPlayer.new
428+ @unrated.player_id = "unrated"
429+ @unrated.name = "unrated"
430+ @unrated.estimated_rate = 450
431+
427432 $league.add(@a)
428433 $league.add(@b)
429434 $league.add(@c)
@@ -580,6 +585,32 @@ class TestLeastDiff < Test::Unit::TestCase
580585 assert_equal(@abcdefg2.rate - @abcdefg1.rate + 800, @pairing.calculate_diff_with_penalty(players,nil))
581586 end
582587
588+ def test_calculate_diff_with_unrated_player
589+ players = [@unrated, @a]
590+ dummy = nil
591+ def @history.make_record(game_result)
592+ {:game_id => "wdoor+floodgate-900-0-a-unrated-1",
593+ :black => "a", :white => "unrated",
594+ :winner => "unrated", :loser => "a"}
595+ end
596+ @history.update(dummy)
597+ assert_equal(4000 + 400 + (@a.rate - @unrated.estimated_rate).abs,
598+ @pairing.calculate_diff_with_penalty(players,@history))
599+ end
600+
601+ def test_calculate_diff_with_unrated_player_2
602+ players = [@a, @unrated]
603+ dummy = nil
604+ def @history.make_record(game_result)
605+ {:game_id => "wdoor+floodgate-900-0-a-unrated-1",
606+ :black => "a", :white => "unrated",
607+ :winner => "unrated", :loser => "a"}
608+ end
609+ @history.update(dummy)
610+ assert_equal(4000 + 400 + (@a.rate - @unrated.estimated_rate).abs,
611+ @pairing.calculate_diff_with_penalty(players,@history))
612+ end
613+
583614 def test_get_player_rate_0
584615 assert_equal(2150, @pairing.get_player_rate(@x, @history))
585616
Show on old repository browser