• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No 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

Revisão051a0e7af2694d0dd143541db454b763c1f17482 (tree)
Hora2013-12-21 17:52:52
AutorDaigo Moriwaki <daigo@debi...>
CommiterDaigo Moriwaki

Mensagem de Log

Merge branch '201312-KinPenalty' into wdoor-stable

Mudança Sumário

Diff

--- a/changelog
+++ b/changelog
@@ -1,3 +1,9 @@
1+2013-12-21 Daigo Moriwaki <daigo at debian dot org>
2+
3+ * [shogi-server]
4+ - shogi_server/pairing.rb: Impose penalty on matches between
5+ likely kin players.
6+
17 2013-12-15 Daigo Moriwaki <daigo at debian dot org>
28
39 * [webserver]
--- a/shogi_server/pairing.rb
+++ b/shogi_server/pairing.rb
@@ -494,6 +494,13 @@ module ShogiServer
494494 if p1.is_human? && p2.is_human?
495495 ret += 800
496496 end
497+
498+ # 2.3 a match with likely kin players
499+ if (p1.player_id[0..6] == p2.player_id[0..6])
500+ ret += 800
501+ elsif (p1.player_id[0..3] == p2.player_id[0..3])
502+ ret += 400
503+ end
497504 end
498505
499506 ret
--- a/test/TC_pairing.rb
+++ b/test/TC_pairing.rb
@@ -411,6 +411,19 @@ class TestLeastDiff < Test::Unit::TestCase
411411 @x.player_id = "x"
412412 @x.name = "x"
413413
414+ @abcdefg1 = ShogiServer::BasicPlayer.new
415+ @abcdefg1.player_id = "abcdefg1"
416+ @abcdefg1.name = "abcdefg1"
417+ @abcdefg1.rate = 2100
418+ @abcdefg2 = ShogiServer::BasicPlayer.new
419+ @abcdefg2.player_id = "abcdefg2"
420+ @abcdefg2.name = "abcdefg2"
421+ @abcdefg2.rate = 2200
422+ @abcdxyz = ShogiServer::BasicPlayer.new
423+ @abcdxyz.player_id = "abcdxyz"
424+ @abcdxyz.name = "abcdxyz"
425+ @abcdxyz.rate = 2300
426+
414427 $league.add(@a)
415428 $league.add(@b)
416429 $league.add(@c)
@@ -420,6 +433,9 @@ class TestLeastDiff < Test::Unit::TestCase
420433 $league.add(@g)
421434 $league.add(@h)
422435 $league.add(@x)
436+ $league.add(@abcdefg1)
437+ $league.add(@abcdefg2)
438+ $league.add(@abcdxyz)
423439 end
424440
425441 def teardown
@@ -548,6 +564,16 @@ class TestLeastDiff < Test::Unit::TestCase
548564 assert_equal(@b.rate-@a.rate+400+@h.rate-@g.rate+400, @pairing.calculate_diff_with_penalty(players, @history))
549565 end
550566
567+ def test_calculate_diff_with_kin_4_players
568+ players = [@abcdefg1, @abcdxyz]
569+ assert_equal(@abcdxyz.rate - @abcdefg1.rate + 400, @pairing.calculate_diff_with_penalty(players,nil))
570+ end
571+
572+ def test_calculate_diff_with_kin_7_players
573+ players = [@abcdefg1, @abcdefg2]
574+ assert_equal(@abcdefg2.rate - @abcdefg1.rate + 800, @pairing.calculate_diff_with_penalty(players,nil))
575+ end
576+
551577 def test_get_player_rate_0
552578 assert_equal(2150, @pairing.get_player_rate(@x, @history))
553579