+2012-12-28 Daigo Moriwaki <daigo at debian dot org>
+
+ * [shogi-server]
+ - shogi_server/pairing.rb:
+ + There was a bug in the logic avoiding human-human match.
+ This issue has been fixed.
+ + Improved the logic avoiding human-human match. Human-human
+ matches will less likely happen.
+
2010-10-06 Daigo Moriwaki <daigo at debian dot org>
* [shogi-server]
for i in 0..(humans.size-2) # -2
next if humans[i].odd?
if humans[i]+1 == humans[i+1]
- pairing_possible = i
+ pairing_possible = humans[i]
break
end
end
end
current_index = pairing_possible
- j = (current_index == 0 ? current_index : current_index-1)
+ j = [0, current_index - 2].max
while j < players.size
break if players[j].is_computer?
j += 1
@d.win = 1000
@d.loss = 2000
@d.rate = 2000
+ @e = ShogiServer::BasicPlayer.new
+ @e.name = "e"
+ @e.win = 3000
+ @e.loss = 3000
+ @e.rate = 3000
+ @f = ShogiServer::BasicPlayer.new
+ @f.name = "f"
+ @f.win = 4000
+ @f.loss = 4000
+ @f.rate = 4000
+ @g = ShogiServer::BasicPlayer.new
+ @g.name = "g"
+ @g.win = 5000
+ @g.loss = 5000
+ @g.rate = 5000
+ @h = ShogiServer::BasicPlayer.new
+ @h.name = "h"
+ @h.win = 6000
+ @h.loss = 6000
+ @h.rate = 6000
end
def test_match_one_player
players = [@a,@b,@c,@d]
@pairing.match(players)
assert_equal(2, $paired.size)
- assert(same_pair?([@a,@b], $paired[0]))
- assert(same_pair?([@c,@d], $paired[1]))
+ assert(same_pair?([@a,@c], $paired[0]))
+ assert(same_pair?([@b,@d], $paired[1]))
end
def test_match_four_players_abcd_human
assert(same_pair?([@a,@b], $paired[0]))
assert(same_pair?([@c,@d], $paired[1]))
end
+
+ def test_match_eight_players_efgh_human
+ @e.name += "_human"
+ @f.name += "_human"
+ @g.name += "_human"
+ @h.name += "_human"
+ players = [@a,@b,@c,@d,@e,@f,@g,@h]
+ @pairing.match(players)
+ assert_equal(4, $paired.size)
+ assert(same_pair?([@e,@c], $paired[0]))
+ assert(same_pair?([@d,@g], $paired[1]))
+ assert(same_pair?([@a,@f], $paired[2]))
+ assert(same_pair?([@b,@h], $paired[3]))
+ end
end