OSDN Git Service

Fix a jishogi bug.
authorbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Fri, 28 Apr 2006 09:57:35 +0000 (09:57 +0000)
committerbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Fri, 28 Apr 2006 09:57:35 +0000 (09:57 +0000)
changelog
shogi-server

index a819657..3d9eb31 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,9 +1,14 @@
-Sat Apr  8 15:42:33 JST 2006  Daigo Moriwaki <daigo@debian.org>
+2006-04-28  Daigo Moriwaki <daigo at debian dot org>
 
 
-       * Support CSA Protocal Version 1.1.
+       * Jishogi kachi declaration did not work. This bug has been fixed.
+         Add debug lines to show a jishogi state.
+
+2006-04-08  Daigo Moriwaki <daigo at debian dot org>
+
+       * Support CSA Protocol Version 1.1.
        * Change the declaration of Jishogi 1.1.
 
        * Change the declaration of Jishogi 1.1.
 
-Fri Mar 10 23:09:43 JST 2006  Daigo Moriwaki <daigo@debian.org>
+2006-03-10  Daigo Moriwaki <daigo at debian dot org>
 
        * Kifu logs are always written in separate files.
        * Add a test case, test/TC_functional.rb
 
        * Kifu logs are always written in separate files.
        * Add a test case, test/TC_functional.rb
index 915ab14..d2b1251 100755 (executable)
@@ -999,11 +999,21 @@ class Board
   end
 
   def good_kachi?(sente)
   end
 
   def good_kachi?(sente)
-    return false if (checkmated?(sente))
+    if (checkmated?(sente))
+      puts "'NG: Checkmating." if $DEBUG
+      return false 
+    end
+    
     ou = look_for_ou(sente)
     ou = look_for_ou(sente)
-    return false if (sente && (ou.y >= 4))
-    return false if (! sente && (ou.y <= 6))
-
+    if (sente && (ou.y >= 4))
+      puts "'NG: Black's OU does not enter yet." if $DEBUG
+      return false     
+    end  
+    if (! sente && (ou.y <= 6))
+      puts "'NG: White's OU does not enter yet." if $DEBUG
+      return false 
+    end
+      
     number = 0
     point = 0
 
     number = 0
     point = 0
 
@@ -1030,16 +1040,27 @@ class Board
       point = point + piece.point
     end
 
       point = point + piece.point
     end
 
-    return false if (number < 10)
+    if (number < 10)
+      puts "'NG: Piece#[%d] is too small." % [number] if $DEBUG
+      return false     
+    end  
     if (sente)
     if (sente)
-      return false if (point < 28)
+      if (point < 28)
+        puts "'NG: Black's point#[%d] is too small." % [point] if $DEBUG
+        return false 
+      end  
     else
     else
-      return false if (point < 27)
+      if (point < 27)
+        puts "'NG: White's point#[%d] is too small." % [point] if $DEBUG
+        return false 
+      end
     end
     end
+
+    puts "'Good: Piece#[%d], Point[%d]." % [number, point] if $DEBUG
     return true
   end
 
     return true
   end
 
-  def handle_one_move(str)
+  def handle_one_move(str, sente)
     if (str =~ /^([\+\-])(\d)(\d)(\d)(\d)([A-Z]{2})/)
       sg = $1
       x0 = $2.to_i
     if (str =~ /^([\+\-])(\d)(\d)(\d)(\d)([A-Z]{2})/)
       sg = $1
       x0 = $2.to_i
@@ -1048,11 +1069,6 @@ class Board
       y1 = $5.to_i
       name = $6
     elsif (str =~ /^%KACHI/)
       y1 = $5.to_i
       name = $6
     elsif (str =~ /^%KACHI/)
-      if (@sente == @current_player)
-        sente = true
-      else
-        sente = false
-      end
       if (good_kachi?(sente))
         return :kachi_win
       else
       if (good_kachi?(sente))
         return :kachi_win
       else
@@ -1282,7 +1298,7 @@ class Game
         end
 
 #        begin
         end
 
 #        begin
-          move_status = @board.handle_one_move(str)
+          move_status = @board.handle_one_move(str, @sente == @current_player)
 #        rescue
 #          log_error("handle_one_move raise exception for #{str}")
 #          move_status = :illegal
 #        rescue
 #          log_error("handle_one_move raise exception for #{str}")
 #          move_status = :illegal