OSDN Git Service

Fixed wrong determination of sennichite.
authorbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Sun, 16 Mar 2008 07:38:48 +0000 (07:38 +0000)
committerbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Sun, 16 Mar 2008 07:38:48 +0000 (07:38 +0000)
changelog
shogi-server

index 08d6b88..3af57fb 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,3 +1,11 @@
+2008-03-16 Daigo Moriwaki <daigo at debian dot org>
+
+       * [shogi-server]
+         - Erroneously, Board#to_s's current player was always Black.
+           It caused wrong determination of sennichite since it did not
+           care about the current player of a state. This has been fixed.
+           Thanks Takada-san for reporting this bug.
+
 2008-03-10 Daigo Moriwaki <daigo at debian dot org>
 
        * [util/players-graph.rb]
index 232c8f5..00ef4e1 100755 (executable)
@@ -1124,6 +1124,7 @@ class Board
     @gote_history  = Hash::new(0)
     @array = [[], [], [], [], [], [], [], [], [], []]
     @move_count = 0
+    @teban = nil # black => true, white => false
   end
   attr_accessor :array, :sente_hands, :gote_hands, :history, :sente_history, :gote_history
   attr_reader :move_count
@@ -1158,6 +1159,7 @@ class Board
     (1..9).each do |i|
       PieceFU::new(self, i, 7, true)
     end
+    @teban = true
   end
 
   def have_piece?(hands, name)
@@ -1196,6 +1198,7 @@ class Board
       @array[x0][y0].move_to(x1, y1)
     end
     @move_count += 1
+    @teban = @teban ? false : true
     return true
   end
 
@@ -1486,7 +1489,6 @@ class Board
     end
 
     move_to(x0, y0, x1, y1, name, sente)
-    str = to_s
 
     update_sennichite(sente)
     return :normal
@@ -1525,7 +1527,7 @@ class Board
       end
       a.push("\n")
     end
-    a.push("+\n")
+    a.push("%s\n" % [@teban ? "+" : "-"])
     return a.join
   end
 end