• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

shogi-server source


Commit MetaInfo

Révisioneed74ba8dc18b3843e263ed35eeeeab4c086f520 (tree)
l'heure2012-12-28 17:44:29
AuteurDaigo Moriwaki <beatles@user...>
CommiterDaigo Moriwaki

Message de Log

Applied a patch from the wdoor-stable branch: Improved the logic avoiding human-human match.

commit 81d6582813f9af7f2c23c0f056ee6960b3299e05
Author: Daigo Moriwaki <beatles@users.sourceforge.jp>
Date: Fri Dec 28 15:23:45 2012 +0900

>

- 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.

Change Summary

Modification

--- a/changelog
+++ b/changelog
@@ -1,3 +1,12 @@
1+2012-12-28 Daigo Moriwaki <daigo at debian dot org>
2+
3+ * [shogi-server]
4+ - shogi_server/pairing.rb:
5+ + There was a bug in the logic avoiding human-human match.
6+ This issue has been fixed.
7+ + Improved the logic avoiding human-human match. Human-human
8+ matches will less likely happen.
9+
110 2012-01-07 Daigo Moriwaki <daigo at debian dot org>
211
312 * [shogi-server]
--- a/shogi_server/pairing.rb
+++ b/shogi_server/pairing.rb
@@ -163,7 +163,7 @@ module ShogiServer
163163 for i in 0..(humans.size-2) # -2
164164 next if humans[i].odd?
165165 if humans[i]+1 == humans[i+1]
166- pairing_possible = i
166+ pairing_possible = humans[i]
167167 break
168168 end
169169 end
@@ -173,7 +173,7 @@ module ShogiServer
173173 end
174174
175175 current_index = pairing_possible
176- j = (current_index == 0 ? current_index : current_index-1)
176+ j = [0, current_index - 2].max
177177 while j < players.size
178178 break if players[j].is_computer?
179179 j += 1
--- a/test/TC_pairing.rb
+++ b/test/TC_pairing.rb
@@ -144,6 +144,26 @@ class TestStartGameWithoutHumans < Test::Unit::TestCase
144144 @d.win = 1000
145145 @d.loss = 2000
146146 @d.rate = 2000
147+ @e = ShogiServer::BasicPlayer.new
148+ @e.name = "e"
149+ @e.win = 3000
150+ @e.loss = 3000
151+ @e.rate = 3000
152+ @f = ShogiServer::BasicPlayer.new
153+ @f.name = "f"
154+ @f.win = 4000
155+ @f.loss = 4000
156+ @f.rate = 4000
157+ @g = ShogiServer::BasicPlayer.new
158+ @g.name = "g"
159+ @g.win = 5000
160+ @g.loss = 5000
161+ @g.rate = 5000
162+ @h = ShogiServer::BasicPlayer.new
163+ @h.name = "h"
164+ @h.win = 6000
165+ @h.loss = 6000
166+ @h.rate = 6000
147167 end
148168
149169 def test_match_one_player
@@ -276,8 +296,8 @@ class TestStartGameWithoutHumans < Test::Unit::TestCase
276296 players = [@a,@b,@c,@d]
277297 @pairing.match(players)
278298 assert_equal(2, $paired.size)
279- assert(same_pair?([@a,@b], $paired[0]))
280- assert(same_pair?([@c,@d], $paired[1]))
299+ assert(same_pair?([@a,@c], $paired[0]))
300+ assert(same_pair?([@b,@d], $paired[1]))
281301 end
282302
283303 def test_match_four_players_abcd_human
@@ -291,6 +311,20 @@ class TestStartGameWithoutHumans < Test::Unit::TestCase
291311 assert(same_pair?([@a,@b], $paired[0]))
292312 assert(same_pair?([@c,@d], $paired[1]))
293313 end
314+
315+ def test_match_eight_players_efgh_human
316+ @e.name += "_human"
317+ @f.name += "_human"
318+ @g.name += "_human"
319+ @h.name += "_human"
320+ players = [@a,@b,@c,@d,@e,@f,@g,@h]
321+ @pairing.match(players)
322+ assert_equal(4, $paired.size)
323+ assert(same_pair?([@e,@c], $paired[0]))
324+ assert(same_pair?([@d,@g], $paired[1]))
325+ assert(same_pair?([@a,@f], $paired[2]))
326+ assert(same_pair?([@b,@h], $paired[3]))
327+ end
294328 end
295329
296330