[情報] 另一個五子棋禁手的小 bug

看板PttBug作者 (yvb)時間16年前 (2008/06/27 00:21), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
除了先前所述的 bug 之外, 尚有另一個 bug. 此 bug 需先將前一個 bug fix 後才會發現. 狀況: 附錄的五子棋譜, 下 A 會誤判為禁手. 說明: 在 dirchk() 的 if ((style == 3) || (style == 2)) { 中, 有一段 if ((dirchk(ku, nx, ny, color, 0, dx, dy) == 0x06) && 而 dirchk() 的第五個參數, 表示是否進行禁手判斷, 此處誤寫為 0, 因此造成 以白棋的規則, 檢查是否為活四. 建議: 將 if ((dirchk(ku, nx, ny, color, 0, dx, dy) == 0x06) && 的 0 改為 1 或 limit, 即 改為 if ((dirchk(ku, nx, ny, color, 1, dx, dy) == 0x06) && 或 改為 if ((dirchk(ku, nx, ny, color, limit, dx, dy) == 0x06) && 另解: 盈月與繁星 (MoonStar, 某 BBS 站) 的處理方式為 將 if ((dirchk(ku, nx, ny, color, 0, dx, dy) == 0x06) && 的 0 改為 2, 即 改為 if ((dirchk(ku, nx, ny, color, 2, dx, dy) == 0x06) && 並在 style >>= 4; 前一行加上 if (limit==2) return (style>>4); [註] 目前 Ptt 站上 五子棋型檢查的程式碼, 乃 MoonStar (站名) 於 1998.11 開發完成第一版; MoonStar 並於 1999.04 根據 一篇 殺手文出題 的 "禁點判斷" 而發現上述 bug, 並修正之. 附錄: 如下圖, A 不為禁手點. 因下了 A 後, b 仍為雙三禁手, 且 A, c, d 將構成長連禁, 故下 A 為活三. A B C D E F G H I J K L M N 15╔╤╤╤╤╤╤╤╤╤╤╤╤╤╗ 14╟┼┼┼┼┼┼┼┼┼┼┼┼┼╢ 13╟┼┼┼┼┼┼┼┼┼┼┼┼┼╢ 12╟┼┼+┼┼┼+┼┼┼+┼┼╢ 11╟┼┼┼┼┼┼┼┼┼┼┼┼┼╢ 10╟┼┼┼●○○┼┼●○┼┼┼╢ 9╟┼┼┼┼●┼○○┼●┼┼┼╢ 8╟┼┼●dcA●●b┼+┼┼╢ 7╟┼┼┼┼○┼┼┼●○┼┼┼╢ 6╟┼┼┼┼┼○●┼┼○┼┼┼╢ 5╟┼┼┼┼┼┼┼┼┼┼┼┼┼╢ 4╟┼┼+┼┼┼+┼┼┼+┼┼╢ 3╟┼┼┼┼┼┼┼┼┼┼┼┼┼╢ 2╟┼┼┼┼┼┼┼┼┼┼┼┼┼╢ 1╚╧╧╧╧╧╧╧╧╧╧╧╧╧╝ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 60.199.200.53
文章代碼(AID): #18Oy7zJC (PttBug)