shogi-server source
Revision | 051a0e7af2694d0dd143541db454b763c1f17482 (tree) |
---|---|
Time | 2013-12-21 17:52:52 |
Author | Daigo Moriwaki <daigo@debi...> |
Commiter | Daigo Moriwaki |
Merge branch '201312-KinPenalty' into wdoor-stable
@@ -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 | + | |
1 | 7 | 2013-12-15 Daigo Moriwaki <daigo at debian dot org> |
2 | 8 | |
3 | 9 | * [webserver] |
@@ -494,6 +494,13 @@ module ShogiServer | ||
494 | 494 | if p1.is_human? && p2.is_human? |
495 | 495 | ret += 800 |
496 | 496 | 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 | |
497 | 504 | end |
498 | 505 | |
499 | 506 | ret |
@@ -411,6 +411,19 @@ class TestLeastDiff < Test::Unit::TestCase | ||
411 | 411 | @x.player_id = "x" |
412 | 412 | @x.name = "x" |
413 | 413 | |
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 | + | |
414 | 427 | $league.add(@a) |
415 | 428 | $league.add(@b) |
416 | 429 | $league.add(@c) |
@@ -420,6 +433,9 @@ class TestLeastDiff < Test::Unit::TestCase | ||
420 | 433 | $league.add(@g) |
421 | 434 | $league.add(@h) |
422 | 435 | $league.add(@x) |
436 | + $league.add(@abcdefg1) | |
437 | + $league.add(@abcdefg2) | |
438 | + $league.add(@abcdxyz) | |
423 | 439 | end |
424 | 440 | |
425 | 441 | def teardown |
@@ -548,6 +564,16 @@ class TestLeastDiff < Test::Unit::TestCase | ||
548 | 564 | assert_equal(@b.rate-@a.rate+400+@h.rate-@g.rate+400, @pairing.calculate_diff_with_penalty(players, @history)) |
549 | 565 | end |
550 | 566 | |
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 | + | |
551 | 577 | def test_get_player_rate_0 |
552 | 578 | assert_equal(2150, @pairing.get_player_rate(@x, @history)) |
553 | 579 |