From 1be78c7645eb82a63ea6de71a971cb402b65c69c Mon Sep 17 00:00:00 2001 From: beatles Date: Fri, 28 Apr 2006 09:57:35 +0000 Subject: [PATCH 1/1] Fix a jishogi bug. --- changelog | 11 ++++++++--- shogi-server | 44 ++++++++++++++++++++++++++++++-------------- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/changelog b/changelog index a819657..3d9eb31 100644 --- a/changelog +++ b/changelog @@ -1,9 +1,14 @@ -Sat Apr 8 15:42:33 JST 2006 Daigo Moriwaki +2006-04-28 Daigo Moriwaki - * 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 + + * Support CSA Protocol Version 1.1. * Change the declaration of Jishogi 1.1. -Fri Mar 10 23:09:43 JST 2006 Daigo Moriwaki +2006-03-10 Daigo Moriwaki * Kifu logs are always written in separate files. * Add a test case, test/TC_functional.rb diff --git a/shogi-server b/shogi-server index 915ab14..d2b1251 100755 --- a/shogi-server +++ b/shogi-server @@ -999,11 +999,21 @@ class Board 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) - 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 @@ -1030,16 +1040,27 @@ class Board 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) - return false if (point < 28) + if (point < 28) + puts "'NG: Black's point#[%d] is too small." % [point] if $DEBUG + return false + end 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 + + puts "'Good: Piece#[%d], Point[%d]." % [number, point] if $DEBUG 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 @@ -1048,11 +1069,6 @@ class Board 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 @@ -1282,7 +1298,7 @@ class Game 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 -- 2.11.0