{"id":2133,"date":"2025-09-14T23:44:43","date_gmt":"2025-09-15T03:44:43","guid":{"rendered":"https:\/\/www.a2life.info\/w\/?p=2133"},"modified":"2025-09-30T23:25:52","modified_gmt":"2025-10-01T03:25:52","slug":"ai%e3%81%ab%e3%82%b3%e3%83%bc%e3%83%89%e3%82%92%e6%9b%b8%e3%81%84%e3%81%a6%e3%82%82%e3%82%89%e3%81%a3%e3%81%a6%e5%a4%b1%e6%95%97%e3%81%97%e3%81%9f%e8%a9%b1","status":"publish","type":"post","link":"https:\/\/www.a2life.info\/w\/?p=2133","title":{"rendered":"AI\u306b\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u3082\u3089\u3063\u3066\u5931\u6557\u3057\u305f\u8a71"},"content":{"rendered":"\n<p>\u5c06\u68cb\u306e\u5c40\u9762\u3092\u8a18\u8ff0\u3059\u308b\u66f8\u5f0f\u306bSFEN\u3068\u3044\u3046\u8a18\u8ff0\u65b9\u5f0f\u304c\u3042\u308b\u3002<br>\n\u3053\u308c\u306f\u76e4\u4e0a\u306e\u99d2\u306e\u914d\u7f6e\u3001\u624b\u756a\u3001\u5148\u624b\u3068\u5f8c\u624b\u306e\u6301\u3061\u99d2\u3001\u624b\u6570\u306a\u3069\u304c\u30b3\u30f3\u30d1\u30af\u30c8\u306b\u6587\u5b57\u5217\u306b\u307e\u3068\u3081\u3089\u308c\u305f\u3082\u306e\u3067\u3001Kyokumen.jp\u306e\u5c40\u9762\u691c\u7d22\u306b\u4f7f\u308f\u308c\u3066\u3044\u305f\u308a\u3001\u5c06\u68cb\u30a8\u30f3\u30b8\u30f3\u306e\u5b9a\u8de1\u30d5\u30a1\u30a4\u30eb\u306b\u3082\u4f7f\u308f\u308c\u3066\u3044\u305f\u308a\u3059\u308b\u3002<\/p>\n\n\n\n<p>SFEN\u306e\u66f8\u5f0f\u306b\u3064\u3044\u3066\u306f<a href=\"https:\/\/shogi.wiki\/doku.php\/sfen\">\u3053\u306e\u8a18\u4e8b<\/a>\u306b\u3046\u307e\u304f\u8aac\u660e\u3055\u308c\u3066\u3044\u308b\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u3001Yaneuraou\u3055\u3093\u304cMIT License\u3067\u65b0\u305f\u306b\u516c\u958b\u3055\u308c\u305f233\u4e07\u624b\u306e\u5b9a\u8de1\u30d5\u30a1\u30a4\u30eb\u3092\u307f\u305f\u3068\u3053\u308d\u3001\u5f8c\u624b\u756a\u306e\u5c40\u9762\u304c\u306a\u304f\u3001\u5148\u624b\u5f8c\u624b\u76e4\u9762\u3092\u53cd\u8ee2\u3057\u3066\u691c\u7d22\u3059\u308b\u65b9\u6cd5\u304c\u3068\u3089\u308c\u3066\u3044\u308b\u3002\u3064\u307e\u308a\u3001\u3000\u4f8b\u3048\u3070\u521d\u671f\u753b\u9762\u304b\u3089\u5f8c\u624b\u304c\uff13\u56db\u6b69\u3068\u6307\u3057\u305f\u5c40\u9762\u304c\u5148\u624b\u756a\u3068\u3057\u3066\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u3002\u3000\u5c4b\u6839\u88cf\u738b\u306e\u30a8\u30f3\u30b8\u30f3\u306b\u306fflippedBoard\u3068\u3044\u3046\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u304c\u3042\u308a\u3001\u3053\u308c\u3092On\u3059\u308b\u3060\u3051\u3067\u5bfe\u5fdc\u3059\u308b\u3088\u3046\u8a2d\u8a08\u3055\u308c\u3066\u3044\u308b\u306e\u3060\u304c\u3001\u5b9a\u8de1\u30d5\u30a1\u30a4\u30eb\u3092\u30d6\u30e9\u30a6\u30b6\u3067\u5c06\u68cb\u76e4\u4e0a\u306b\u8868\u793a\u3055\u305b\u308b\u81ea\u5206\u306eWeb\u30da\u30fc\u30b8\u306b\u8ffd\u52a0\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u5f8c\u624b\u306e\u624b\u756a\u306e\u6642\u306b\u691c\u7d22\u3092\u304b\u3051\u308bSFEN\u306e\u5c40\u9762\u3092\u53cd\u8ee2\u3055\u305b\u3066\u30b5\u30fc\u30d0\u30fc\u306b\u554f\u3044\u5408\u308f\u305b\u308b\u5fc5\u8981\u304c\u751f\u3058\u305f\u3002\u30b5\u30fc\u30d0\u30fc\u304b\u3089\u5e30\u3063\u3066\u304f\u308b\u5019\u88dc\u624b\u3082\u540c\u69d8\u306b\u3001\u4f8b\u3048\u3070\uff12\u516d\u6b69\u3092\uff18\u56db\u6b69\u306a\u3069\u3068\u53cd\u8ee2\u3055\u305b\u308b\u5fc5\u8981\u304c\u3042\u308b<\/p>\n\n\n\n<p>\u6700\u521d\u306e\u5c40\u9762\u3092\u53cd\u8ee2\u3055\u305b\u308b\u90e8\u5206\u3001TypeScript\u95a2\u6570\u3068\u3057\u3066\u7528\u610f\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code has-light-gray-color has-dark-gray-background-color has-text-color has-background has-link-color wp-elements-40407106c2c39bcc9312a25f0cfd7103\"><code lang=\"typescript\" class=\"language-typescript line-numbers\">\n\n&lt;pre>export const flipSFEN=(sfen:string):string=> {\n    const [board, turn, hands, moveCount] = sfen.split(' ');\n    const swapUpperLower=(str:string)=>{\n        const strArr=str.split('');\n        return strArr.map(char=>{\n            if (char===char.toUpperCase() &amp;&amp; char!==char.toLowerCase()){\n                \/\/string is uppercase\n                return char.toLowerCase(); \/\/change to uppercase\n            } else \/\/string is lowercase or number\/symbol\n            {\n                if(char!==char.toUpperCase()){ \/\/string is not symbol nor number. therefore string is lowercase\n                    return char.toUpperCase(); \/\/change to lower case\n                }\n                \/\/ string is number\/symbol\n                return char;\n            }\n\n\n        }).join('');\n    }\n\n    const pivotHands=(hands:string)=>{\n\n        const flipped=swapUpperLower(hands);\n        const reversedHandsArray=flipped.split('').reverse();\n\n        let pivotPoint=-1\n        for (const [index,hand] of reversedHandsArray.entries()){\n            if (hand.toLowerCase()===hand &amp;&amp; hand.toUpperCase()!==hand){\n                pivotPoint = index;\n                break;\n\n            }\n\n        }\n        if (pivotPoint&amp;gt;0) \/\/if pivotpoint is either -1 or 0 then there is no need to manipulate flipped.\n        {\n            const breakPoint=flipped.length-pivotPoint;\n            return flipped.slice(breakPoint)+flipped.slice(0,breakPoint);\n        }\n        else return flipped\n\n    }\n    \/\/ Flip the board rows\n\n    const flippedBoard = board\n        .split('\/')\n        .reverse()\n        .map(row => {\n            return row\n                .split('')\n                .map(char => {\n                   return swapUpperLower(char);\n                })\n                .reduce((acc,item)=>{\n                    const {elementArray, promoted}=acc\n                    if (item==='+'){ return {elementArray,promoted:true}}\n                    if (promoted){\n                        item='+'+item.charAt(0)\n\n                    }\n                    elementArray[elementArray.length]=item\n\n                    return {elementArray,promoted:false};\n\n\n            },{elementArray:[] as string[], promoted:false})\n                .elementArray  \/\/create a row array with promoted piece as +(piece name)\n                .reverse()  \/\/ reverse board columns\n                .join(''); \/\/ processed one board row\n        })\n        .join('\/'); \/\/assemble 9 rows\n\n    \/\/ Flip the turn\n    const flippedTurn = turn === 'b' ? 'w' : 'b';\n    const flipHands =pivotHands(hands);\n\n    \/\/ Return the new SFEN\n    return `${flippedBoard} ${flippedTurn} ${flipHands} ${moveCount}`;\n}\n<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3067\u4f55\u3092\u3084\u3063\u3066\u3044\u308b\u304b\u3068\u3044\u3046\u3068<\/p>\n\n\n\n<p>\uff11\uff0e\u307e\u305a\u306f\u3000SFEN\u6587\u5b57\u5217\u3092\u30b9\u30da\u30fc\u30b9\u3092\u30c7\u30ea\u30df\u30bf\u30fc\u3068\u3057\u3066\u6587\u5b57\u5217\u30a2\u30ec\u30a4\u306b\u5206\u89e3\u3059\u308b\u3002<br>\n\uff12\uff0e\u305d\u308c\u305e\u308c\u306e\u30a2\u30ec\u30a4\u56e0\u5b50\u3092\u3000board, turn, hands, moveCount\u3068\u3044\u3046\u5909\u6570\u306b\u308f\u308a\u3042\u3066\u308b\u3002\u3000\u3061\u306a\u307f\u306bMoveCount\u306f\u4eca\u56de\u306e\u5b9a\u8de1\u30d5\u30a1\u30a4\u30eb\u306b\u4f7f\u7528\u3059\u308b\u306b\u306f\u30bc\u30ed\u306b\u7f6e\u304d\u63db\u3048\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002\uff08\u4e0a\u306e\u30b3\u30fc\u30c9\u3067\u306f\u672a\u53cd\u6620\uff09<br>\n\uff13\uff0eboard\uff08\u99d2\u306e\u76e4\u9762\u4f4d\u7f6e\u60c5\u5831\uff09\u3092\u3055\u3089\u306bdelimeter &#8216;\/&#8217; \u3067\u5404\u5217\u306b\u5206\u89e3\u3057\u305f\u30a2\u30ec\u30a4\u3092\u751f\u6210<br>\n\uff14. array.reverse()\u3092\u4f7f\u3063\u3066\u5217\u9806\u3092\u3072\u3063\u304f\u308a\u8fd4\u3059\u3002\u4e0a\u6bb5\u306e\u5217\u304c\u4e0b\u6bb5\u306b\u3001\u4e0b\u6bb5\u306e\u5217\u304c\u4e0a\u6bb5\u306b\u306a\u308b\u3002<br>\n\uff15\uff0e\u3055\u3089\u306b\u3001\u3055\u3089\u306b\u5404\u5217\u306e\u6587\u5b57\u5217\u3092\u4e00\u6587\u5b57\u3065\u3064\u306b\u5206\u89e3\u3057\u3066\u30a2\u30ec\u30a4\u3092\u4f5c\u308b\u3002<br>\n\uff16\uff0e\u5927\u6587\u5b57\u306e\u99d2\uff08\u5f8c\u624b\u306e\u99d2\uff09\u3092\u5c0f\u6587\u5b57\uff08\u5148\u624b\u306e\u99d2\uff09\u3001\u5c0f\u6587\u5b57\u306e\u99d2\uff08\u5148\u624b\u306e\u99d2\uff09\u3092\u5927\u6587\u5b57\u306b\u7f6e\u63db\u3059\u308b<br>\n\uff17\uff0earray.reduce()\u3092\u4f7f\u3063\u3066\u3001\uff0b\u30b7\u30f3\u30dc\u30eb\uff08\u6210\u308a\u99d2\uff09\u56e0\u5b50\u3068\u6b21\u306e\u99d2\u306e\u56e0\u5b50\u3092\u7e4b\u3052\u3066\u4e00\u3064\u306e\u30a2\u30ec\u30fc\u56e0\u5b50\u306b\u307e\u3068\u3081\u308b<\/p>\n\n\n\n<p>8. \u3053\u308c\u3092.reverse()\u3067\u5de6\u53f3\u53cd\u8ee2<br>\n9.\u3000\u5404\u5217\u306e\u30a2\u30ec\u30a4\u3092\u6587\u5b57\u5217\u306b\u5909\u63db<br>\n10\u3002\u5404\u5217\u306e\u6587\u5b57\u5217\u30a2\u30ec\u30fc\u3092\u3092&#8217;\u30c7\u30ea\u30df\u30bf\u30fc\/&#8217;\u3067\u63a5\u5408\u3057\u3001\u4e00\u3064\u306e\u6587\u5b57\u5217\u3092\u751f\u6210\u3002\u2192flippedBoard<br>\n11. \u624b\u756a\u3082\u3072\u3063\u304f\u308a\u8fd4\u3059\u3000(flippedTurn)<br>\n12. \u6301\u3061\u99d2\u3092\u5148\u624b\u3068\u5f8c\u624b\u5165\u308c\u66ff\u3048\u308b (pivotHands)\u3000\u3053\u306e\u90e8\u5206\u3001\u4f7f\u3063\u305f\u30ed\u30b8\u30c3\u30af\u306f\u4ee5\u4e0b\u306e\u3068\u304a\u308a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">B3Ps14p\u3092 S14Pb3p\u3068\u3057\u305f\u3044\u3002\n\u307e\u305a\u306f\u5927\u6587\u5b57\u5c0f\u6587\u5b57\u3092\u5165\u308c\u66ff\u3048\u308b\nb3p2S14P\u3000(flipped)\n\u6700\u521d\u306e\u5927\u6587\u5b57\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u53d6\u308c\u3070\u3088\u3044\u3068\u601d\u3048\u308b\u304c\u3001\u6570\u5b57\u304c\u3064\u3044\u305f\u5834\u5408\uff08\uff12S\uff09\u3068\u306a\u3063\u3066\u3044\u305f\u5834\u5408\u306fNG\n\u306a\u306e\u3067\u6587\u5b57\u5217\u3092\u9006\u8ee2\u3055\u305b\u3066\u307f\u308b\nP41S2p3b reversed\n\u3053\u308c\u3067\u6700\u521d\u306e\u5c0f\u6587\u5b57\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u53d6\u308b\u3002\u4e0a\u306e\u4f8b\u3060\u30685\u3002\u6587\u5b57\u5217\u9577\u30558\u306a\u306e\u3067\u30008\uff0d5\uff1d3\nsecondPart =flipped.slice(0,3) = b3p\nfirstPart = flipped.slice(3) =2S14P\n\u3053\u308c\u3092\u7d44\u307f\u7acb\u3066\u308b\nfinal = firstPart+secondPart = 2S14Pb3p\n\u3046\u307e\u304f\u3044\u3063\u3066\u3044\u308b\u306e\u3067\u306f\uff1f\n\n\u5148\u624b\u306e\u6301\u3061\u99d2\u3060\u3051\u306e\u5834\u5408\u3000\u4f8b\u3048\u3070\u3000\uff12P\n\u5c0f\u6587\u5b57\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306f\u30de\u30a4\u30ca\u30b9\uff11\u3000\u3053\u306e\u5834\u5408\u306f\u51e6\u7406\u3092\u30b9\u30ad\u30c3\u30d7\n\u5f8c\u624b\u306e\u6301\u3061\u99d2\u3060\u3051\u306e\u5834\u5408\u3000\u4f8b\u3048\u3070\uff11\uff14\uff50\u3000\u9006\u8ee2\u6587\u5b57\u5217\u3067\u306e\u5c0f\u6587\u5b57\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306f\uff10\u3000\u3053\u306e\u5834\u5408\u3082\u51e6\u7406\u3092\u30b9\u30ad\u30c3\u30d7\n\n<\/pre>\n\n\n\n<p>13 .flifppedboard flippedTurn flippedHands moveCount\u3092\u4e00\u3064\u306e\u6587\u5b57\u5217\u306b\u3064\u306a\u304e\u5408\u308f\u305b\u3001\u3053\u306e\u5024\u3092\u8fd4\u3059<br>\n\u3068\u307e\u3042\u3001\u66f8\u3044\u3066\u3057\u307e\u3048\u3070\u7c21\u5358\u306a\u4f5c\u696d\u306e\u9023\u7d9a\u3060\u304c\u3001\u5b9f\u306f\u3053\u306e\u30b3\u30fc\u30c9\u3001\u6700\u521dAI\u306b\u805e\u3044\u3066\u63d0\u793a\u3055\u308c\u305f\u3082\u306e\u304c\u52d5\u304b\u306a\u304f\u3066\u3001\u4fee\u6b63\u3092\u5165\u308c\u59cb\u3081\u305f\u3089\u3001\u7d50\u5c40\u4e03\u5272\u304c\u305f\u306f\u66f8\u304d\u76f4\u3057\u3066\u3057\u307e\u3063\u305f\u3001\u3068\u3044\u3046\u3082\u306e\u306b\u306a\u308b\u3002<\/p>\n\n\n\n<p>\u6700\u521d\u3001Brave\u3000Brouser\u306e\u691c\u7d22\u7a93\u306b\u3000&#8221;Given sfen string, write a javascript function that returns flipped sfen&#8221; \u3068\u6253\u3063\u305f\u3089\u3042\u3063\u3055\u308a\u56de\u7b54\u3092\u3088\u3053\u3057\u305f\u306e\u3067\u3053\u308c\u3092TypeScript\u306b\u66f8\u304d\u76f4\u3057\u3001\u305d\u306e\u307e\u307e\u5b9a\u8de1\u30d5\u30a1\u30a4\u30eb\u306b\u4f7f\u3063\u3066\u307f\u305f\u306e\u3060\u305f\u3001\u5c40\u9762\u691c\u7d22\u304c\u307e\u3063\u305f\u304f\u30d2\u30c3\u30c8\u3057\u306a\u304b\u3063\u305f\u3002\u3000\u3000\u30b3\u30fc\u30c9\u3092\u89e3\u6790\u3057\u3066\u5206\u304b\u3063\u305f\u3053\u3068\u306fAI\u304c\u304f\u308c\u305f\u56de\u7b54\u306f\u4e0a\u8a18\u306e\u30b9\u30c6\u30c3\u30d7\u304b\u3089\u3000\uff17\uff0c\uff18\u305d\u3057\u3066\uff11\uff12\u306e\u51e6\u7406\u304c\u629c\u3051\u3066\u3044\u305f\u3002\u305d\u306e\u7d50\u679c\u76e4\u9762\u306e\u4e0a\u4e0b\u53cd\u8ee2\u306f\u3057\u305f\u304c\u3001\u305d\u306e\u3042\u3068\u304c\u5de6\u53f3\u53cd\u8ee2\u3092\u3057\u3066\u3044\u306a\u3044\u305f\u3081\u3001\u30df\u30e9\u30fc\u30a4\u30e1\u30fc\u30b8\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u3001\u3055\u3089\u306b\u6301\u3061\u99d2\u304c\u3042\u3063\u305f\u5834\u5408\u306f\u5148\u624b\u3068\u5f8c\u624b\u304c\u9006\u306e\u307e\u307e\u3002\u3000Web\u30da\u30fc\u30b8\u306e\u4ed5\u7d44\u307f\u306f\u3053\u306esfen\u3092\u30b5\u30fc\u30d0\u30fc\u306b\u9001\u3063\u3066\u30b5\u30fc\u30d0\u30fc\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u3053\u306esfen\u306b\u5bfe\u5fdc\u3059\u308bmoves\u60c5\u5831\u3092\u8fd4\u3057\u3066\u3082\u3089\u3044\u3001\u6b21\u306e\u6307\u3057\u624b\u306e\u5019\u88dc\u3092\u30ea\u30b9\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u3068\u3044\u3046\u3082\u306e\u306a\u306e\u3067\u3001\u30df\u30e9\u30fc\u30a4\u30e1\u30fc\u30b8\u306e\u5c40\u9762\u7167\u4f1a\u306b\u306f\u30d2\u30c3\u30c8\u3059\u308b\u5019\u88dc\u624b\u306f\u3042\u308a\u307e\u305b\u3093\u3068\u3044\u3046\u7b54\u3048\u3057\u304b\u8fd4\u3063\u3066\u3053\u306a\u3044\u3002<\/p>\n\n\n\n<p>AI\u306fSFEN\u304c\u4f55\u305f\u308b\u304b\u3092\u3042\u307e\u308a\u7406\u89e3\u3067\u304d\u306a\u3044\u307e\u307e\u3001WEB\u306b\u843d\u3061\u3066\u3044\u308b\u60c5\u5831\u3092\u304b\u304d\u96c6\u3081\u3066\u4f7f\u3063\u305f\u3088\u3046\u3067\u3001\u30d7\u30ed\u30f3\u30d7\u30c8\u3067\u3001SFEN\u306e\u5b9a\u7fa9\u304b\u3089\u59cb\u3081\u3001\u671f\u5f85\u3055\u308c\u308b\u30a2\u30a6\u30c8\u30d7\u30c3\u30c8\u306e\u30a4\u30e1\u30fc\u30b8\u3092\u3057\u3063\u304b\u308a\u4f1d\u3048\u3066\u304a\u304b\u306a\u3051\u308c\u3070\u3060\u3081\u3060\u3063\u305f\u304b\u3002<\/p>\n\n\n\n<p>\u9006\u306b\u826f\u3044\u306d\u3068\u601d\u3063\u305f\u306e\u306f\u30a2\u30ec\u30a4\u3084\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u95a2\u6570\u3092\u30c1\u30a7\u30a4\u30cb\u30f3\u30b0\u3057\u3066\u8a18\u8ff0\u3059\u308b\u3001\u3044\u308f\u3086\u308bFunctional\u306a\u66f8\u304d\u65b9\u306b\u306a\u3063\u3066\u3044\u3066\u30b9\u30de\u30fc\u30c8\u3067\u3042\u308b\u3002\u3000\u3053\u308c\u306f\u771f\u4f3c\u3057\u305f\u3044\u3002<\/p>\n\n\n\n<p>\u3068\u306b\u304b\u304f\u3001AI\u306b\u4ed5\u4e8b\u3092\u3055\u305b\u305f\u3089\u3001\u4eca\u306e\u6642\u70b9\u3067\u306f\u691c\u8a3c\u304c\u5927\u4e8b\u306a\u308f\u3051\u3060\u304c\u3001\u305d\u308c\u306a\u3089\u6700\u521d\u304b\u3089\u63d0\u4f9b\u3055\u308c\u305f\u30b3\u30fc\u30c9\u306f\u53c2\u8003\u307e\u3067\u306b\u7559\u3081\u3066\u304a\u3044\u3066\u3001\u5b9f\u969b\u306b\u4f7f\u3046\u30b3\u30fc\u30c9\u306f\u81ea\u5206\u3067\u66f8\u3044\u305f\u307b\u3046\u304c\u697d\u3057\u3044\u304b\u3082\u306d\uff08\u4ed5\u4e8b\u3067\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3057\u3066\u3044\u308b\u4eba\u306f\u3053\u3046\u306f\u8a00\u3048\u307e\u3044\uff09\u3002<\/p>\n\n\n\n<p>\u8ffd\u8a18\uff1aYaneuraou\u3055\u3093\u304b\u3089flipsfen\u3092python\u3067\u4f5c\u6210\u3057\u305f\u6642\u306e\u985b\u672b\u306e\u30ea\u30f3\u30af\u3092\u6559\u3048\u3066\u3044\u305f\u3060\u3044\u305f\u3002\u3000<a href=\"https:\/\/yaneuraou.yaneu.com\/2023\/12\/15\/chatgpt-wrote-a-program-to-flip-a-shogi-board\/\" target=\"_blank\" rel=\"noopener\">https:\/\/yaneuraou.yaneu.com\/2023\/12\/15\/chatgpt-wrote-a-program-to-flip-a-shogi-board\/<\/a>\u3000\u3000\u540c\u3058\u3088\u3046\u306a\u3068\u3053\u308d\u3067\u30cf\u30de\u3063\u3066\u3044\u308b\u3093\u3060\u3001\u3068\u53ef\u7b11\u3057\u304f\u306a\u3063\u305f\u534a\u9762\u3002\u3000\u3061\u3087\u3063\u3068\u5f85\u3066\u3001\u3053\u308c\u306f2\u5e74\u524d\u306e\u8a18\u4e8b\u3002\u3000\u3053\u308c\u3092\u8aad\u3093\u3067\u3044\u305f\u3089\u3053\u3093\u306a\u306b\u6642\u9593\u3092\u4f7f\u308f\u306a\u304f\u3066\u3082\u3088\u304b\u3063\u305f\u3058\u3083\u3093\u3000\u3068\u3082\u601d\u3063\u305f\u6b21\u7b2c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c06\u68cb\u306e\u5c40\u9762\u3092\u8a18\u8ff0\u3059\u308b\u66f8\u5f0f\u306bSFEN\u3068\u3044\u3046\u8a18\u8ff0\u65b9\u5f0f\u304c\u3042\u308b\u3002 \u3053\u308c\u306f\u76e4\u4e0a\u306e\u99d2\u306e\u914d\u7f6e\u3001\u624b\u756a\u3001\u5148\u624b\u3068\u5f8c\u624b\u306e\u6301\u3061\u99d2\u3001\u624b\u6570\u306a\u3069\u304c\u30b3\u30f3\u30d1\u30af\u30c8\u306b\u6587\u5b57\u5217\u306b\u307e\u3068\u3081\u3089\u308c\u305f\u3082\u306e\u3067\u3001Kyokumen.jp\u306e\u5c40\u9762\u691c\u7d22\u306b\u4f7f\u308f\u308c\u3066\u3044\u305f\u308a\u3001\u5c06\u68cb\u30a8\u30f3\u30b8\u30f3\u306e\u5b9a\u8de1\u30d5\u30a1\u30a4\u30eb\u306b\u3082\u4f7f\u308f\u308c\u3066\u3044\u305f\u308a\u3059\u308b\u3002 SFEN\u306e\u66f8\u5f0f\u306b\u3064\u3044\u3066\u306f\u3053\u306e\u8a18\u4e8b\u306b\u3046\u307e\u304f\u8aac\u660e\u3055\u308c\u3066\u3044\u308b\u3002 \u4eca\u56de\u3001Yaneuraou\u3055\u3093\u304cMIT License\u3067\u65b0\u305f\u306b\u516c\u958b\u3055\u308c\u305f233\u4e07\u624b\u306e\u5b9a\u8de1\u30d5\u30a1\u30a4\u30eb\u3092\u307f\u305f\u3068\u3053\u308d\u3001\u5f8c\u624b\u756a\u306e\u5c40\u9762\u304c\u306a\u304f\u3001\u5148\u624b\u5f8c\u624b\u76e4\u9762\u3092\u53cd\u8ee2\u3057\u3066\u691c\u7d22\u3059\u308b\u65b9\u6cd5\u304c\u3068\u3089\u308c\u3066\u3044\u308b\u3002\u3064\u307e\u308a\u3001\u3000\u4f8b\u3048\u3070\u521d\u671f\u753b\u9762\u304b\u3089\u5f8c\u624b\u304c\uff13\u56db\u6b69\u3068\u6307\u3057\u305f\u5c40\u9762\u304c\u5148\u624b\u756a\u3068\u3057\u3066\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u3002\u3000\u5c4b\u6839\u88cf\u738b\u306e\u30a8\u30f3\u30b8\u30f3\u306b\u306fflippedBoard\u3068\u3044\u3046\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u304c\u3042\u308a\u3001\u3053\u308c\u3092On\u3059\u308b\u3060\u3051\u3067\u5bfe\u5fdc\u3059\u308b\u3088\u3046\u8a2d\u8a08\u3055\u308c\u3066\u3044\u308b\u306e\u3060\u304c\u3001\u5b9a\u8de1\u30d5\u30a1\u30a4\u30eb\u3092\u30d6\u30e9\u30a6\u30b6\u3067\u5c06\u68cb\u76e4\u4e0a\u306b\u8868\u793a\u3055\u305b\u308b\u81ea\u5206\u306eWeb\u30da\u30fc\u30b8\u306b\u8ffd\u52a0\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u5f8c\u624b\u306e\u624b\u756a\u306e\u6642\u306b\u691c\u7d22\u3092\u304b\u3051\u308bSFEN\u306e\u5c40\u9762\u3092\u53cd\u8ee2\u3055\u305b\u3066\u30b5\u30fc\u30d0\u30fc\u306b\u554f\u3044\u5408\u308f\u305b\u308b\u5fc5\u8981\u304c\u751f\u3058\u305f\u3002\u30b5\u30fc\u30d0\u30fc\u304b\u3089\u5e30\u3063\u3066\u304f\u308b\u5019\u88dc\u624b\u3082\u540c\u69d8\u306b\u3001\u4f8b\u3048\u3070\uff12\u516d\u6b69\u3092\uff18\u56db\u6b69\u306a\u3069\u3068\u53cd\u8ee2\u3055\u305b\u308b\u5fc5\u8981\u304c\u3042\u308b \u6700\u521d\u306e\u5c40\u9762\u3092\u53cd\u8ee2\u3055\u305b\u308b\u90e8\u5206\u3001TypeScript\u95a2\u6570\u3068\u3057\u3066\u7528\u610f\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308b\u3002 &nbsp; \u3053\u306e\u30b3\u30fc\u30c9\u3067\u4f55\u3092\u3084\u3063\u3066\u3044\u308b\u304b\u3068\u3044\u3046\u3068 \uff11\uff0e\u307e\u305a\u306f\u3000SFEN\u6587\u5b57\u5217\u3092\u30b9\u30da\u30fc\u30b9\u3092\u30c7\u30ea\u30df\u30bf\u30fc\u3068\u3057\u3066\u6587\u5b57\u5217\u30a2\u30ec\u30a4\u306b\u5206\u89e3\u3059\u308b\u3002 \uff12\uff0e\u305d\u308c\u305e\u308c\u306e\u30a2\u30ec\u30a4\u56e0\u5b50\u3092\u3000board, turn, hands, moveCount\u3068\u3044\u3046\u5909\u6570\u306b\u308f\u308a\u3042\u3066\u308b\u3002\u3000\u3061\u306a\u307f\u306bMoveCount\u306f\u4eca\u56de\u306e\u5b9a\u8de1\u30d5\u30a1\u30a4\u30eb\u306b\u4f7f\u7528\u3059\u308b\u306b\u306f\u30bc\u30ed\u306b\u7f6e\u304d\u63db\u3048\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002\uff08\u4e0a\u306e\u30b3\u30fc\u30c9\u3067\u306f\u672a\u53cd\u6620\uff09 \uff13\uff0eboard\uff08\u99d2\u306e\u76e4\u9762\u4f4d\u7f6e\u60c5\u5831\uff09\u3092\u3055\u3089\u306bdelimeter &#8216;\/&#8217; \u3067\u5404\u5217\u306b\u5206\u89e3\u3057\u305f\u30a2\u30ec\u30a4\u3092\u751f\u6210 \uff14. array.reverse()\u3092\u4f7f\u3063\u3066\u5217\u9806\u3092\u3072\u3063\u304f\u308a\u8fd4\u3059\u3002\u4e0a\u6bb5\u306e\u5217\u304c\u4e0b\u6bb5\u306b\u3001\u4e0b\u6bb5\u306e\u5217\u304c\u4e0a\u6bb5\u306b\u306a\u308b\u3002 \uff15\uff0e\u3055\u3089\u306b\u3001\u3055\u3089\u306b\u5404\u5217\u306e\u6587\u5b57\u5217\u3092\u4e00\u6587\u5b57\u3065\u3064\u306b\u5206\u89e3\u3057\u3066\u30a2\u30ec\u30a4\u3092\u4f5c\u308b\u3002 \uff16\uff0e\u5927\u6587\u5b57\u306e\u99d2\uff08\u5f8c\u624b\u306e\u99d2\uff09\u3092\u5c0f\u6587\u5b57\uff08\u5148\u624b\u306e\u99d2\uff09\u3001\u5c0f\u6587\u5b57\u306e\u99d2\uff08\u5148\u624b\u306e\u99d2\uff09\u3092\u5927\u6587\u5b57\u306b\u7f6e\u63db\u3059\u308b \uff17\uff0earray.reduce()\u3092\u4f7f\u3063\u3066\u3001\uff0b\u30b7\u30f3\u30dc\u30eb\uff08\u6210\u308a\u99d2\uff09\u56e0\u5b50\u3068\u6b21\u306e\u99d2\u306e\u56e0\u5b50\u3092\u7e4b\u3052\u3066\u4e00\u3064\u306e\u30a2\u30ec\u30fc\u56e0\u5b50\u306b\u307e\u3068\u3081\u308b 8. \u3053\u308c\u3092.reverse()\u3067\u5de6\u53f3\u53cd\u8ee2 9.\u3000\u5404\u5217\u306e\u30a2\u30ec\u30a4\u3092\u6587\u5b57\u5217\u306b\u5909\u63db 10\u3002\u5404\u5217\u306e\u6587\u5b57\u5217\u30a2\u30ec\u30fc\u3092\u3092&#8217;\u30c7\u30ea\u30df\u30bf\u30fc\/&#8217;\u3067\u63a5\u5408\u3057\u3001\u4e00\u3064\u306e\u6587\u5b57\u5217\u3092\u751f\u6210\u3002\u2192flippedBoard 11. \u624b\u756a\u3082\u3072\u3063\u304f\u308a\u8fd4\u3059\u3000(flippedTurn) 12. \u6301\u3061\u99d2\u3092\u5148\u624b\u3068\u5f8c\u624b\u5165\u308c\u66ff\u3048\u308b (pivotHands)\u3000\u3053\u306e\u90e8\u5206\u3001\u4f7f\u3063\u305f\u30ed\u30b8\u30c3\u30af\u306f\u4ee5\u4e0b\u306e\u3068\u304a\u308a B3Ps14p\u3092 S14Pb3p\u3068\u3057\u305f\u3044\u3002 \u307e\u305a\u306f\u5927\u6587\u5b57\u5c0f\u6587\u5b57\u3092\u5165\u308c\u66ff\u3048\u308b b3p2S14P\u3000(flipped) \u6700\u521d\u306e\u5927\u6587\u5b57\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u53d6\u308c\u3070\u3088\u3044\u3068\u601d\u3048\u308b\u304c\u3001\u6570\u5b57\u304c\u3064\u3044\u305f\u5834\u5408\uff08\uff12S\uff09\u3068\u306a\u3063\u3066\u3044\u305f\u5834\u5408\u306fNG \u306a\u306e\u3067\u6587\u5b57\u5217\u3092\u9006\u8ee2\u3055\u305b\u3066\u307f\u308b P41S2p3b reversed \u3053\u308c\u3067\u6700\u521d\u306e\u5c0f\u6587\u5b57\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u53d6\u308b\u3002\u4e0a\u306e\u4f8b\u3060\u30685\u3002\u6587\u5b57\u5217\u9577\u30558\u306a\u306e\u3067\u30008\uff0d5\uff1d3 secondPart =flipped.slice(0,3) = b3p firstPart = flipped.slice(3) =2S14P \u3053\u308c\u3092\u7d44\u307f\u7acb\u3066\u308b final = firstPart+secondPart = 2S14Pb3p \u3046\u307e\u304f\u3044\u3063\u3066\u3044\u308b\u306e\u3067\u306f\uff1f \u5148\u624b\u306e\u6301\u3061\u99d2\u3060\u3051\u306e\u5834\u5408\u3000\u4f8b\u3048\u3070\u3000\uff12P \u5c0f\u6587\u5b57\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306f\u30de\u30a4\u30ca\u30b9\uff11\u3000\u3053\u306e\u5834\u5408\u306f\u51e6\u7406\u3092\u30b9\u30ad\u30c3\u30d7 \u5f8c\u624b\u306e\u6301\u3061\u99d2\u3060\u3051\u306e\u5834\u5408\u3000\u4f8b\u3048\u3070\uff11\uff14\uff50\u3000\u9006\u8ee2\u6587\u5b57\u5217\u3067\u306e\u5c0f\u6587\u5b57\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306f\uff10\u3000\u3053\u306e\u5834\u5408\u3082\u51e6\u7406\u3092\u30b9\u30ad\u30c3\u30d7 13 .flifppedboard flippedTurn flippedHands moveCount\u3092\u4e00\u3064\u306e\u6587\u5b57\u5217\u306b\u3064\u306a\u304e\u5408\u308f\u305b\u3001\u3053\u306e\u5024\u3092\u8fd4\u3059 \u3068\u307e\u3042\u3001\u66f8\u3044\u3066\u3057\u307e\u3048\u3070\u7c21\u5358\u306a\u4f5c\u696d\u306e\u9023\u7d9a\u3060\u304c\u3001\u5b9f\u306f\u3053\u306e\u30b3\u30fc\u30c9\u3001\u6700\u521dAI\u306b\u805e\u3044\u3066\u63d0\u793a\u3055\u308c\u305f\u3082\u306e\u304c\u52d5\u304b\u306a\u304f\u3066\u3001\u4fee\u6b63\u3092\u5165\u308c\u59cb\u3081\u305f\u3089\u3001\u7d50\u5c40\u4e03\u5272\u304c\u305f\u306f\u66f8\u304d\u76f4\u3057\u3066\u3057\u307e\u3063\u305f\u3001\u3068\u3044\u3046\u3082\u306e\u306b\u306a\u308b\u3002 \u6700\u521d\u3001Brave\u3000Brouser\u306e\u691c\u7d22\u7a93\u306b\u3000&#8221;Given sfen string, write a javascript function that returns flipped sfen&#8221; \u3068\u6253\u3063\u305f\u3089\u3042\u3063\u3055\u308a\u56de\u7b54\u3092\u3088\u3053\u3057\u305f\u306e\u3067\u3053\u308c\u3092TypeScript\u306b\u66f8\u304d\u76f4\u3057\u3001\u305d\u306e\u307e\u307e\u5b9a\u8de1\u30d5\u30a1\u30a4\u30eb\u306b\u4f7f\u3063\u3066\u307f\u305f\u306e\u3060\u305f\u3001\u5c40\u9762\u691c\u7d22\u304c\u307e\u3063\u305f\u304f\u30d2\u30c3\u30c8\u3057\u306a\u304b\u3063\u305f\u3002\u3000\u3000\u30b3\u30fc\u30c9\u3092\u89e3\u6790\u3057\u3066\u5206\u304b\u3063\u305f\u3053\u3068\u306fAI\u304c\u304f\u308c\u305f\u56de\u7b54\u306f\u4e0a\u8a18\u306e\u30b9\u30c6\u30c3\u30d7\u304b\u3089\u3000\uff17\uff0c\uff18\u305d\u3057\u3066\uff11\uff12\u306e\u51e6\u7406\u304c\u629c\u3051\u3066\u3044\u305f\u3002\u305d\u306e\u7d50\u679c\u76e4\u9762\u306e\u4e0a\u4e0b\u53cd\u8ee2\u306f\u3057\u305f\u304c\u3001\u305d\u306e\u3042\u3068\u304c\u5de6\u53f3\u53cd\u8ee2\u3092\u3057\u3066\u3044\u306a\u3044\u305f\u3081\u3001\u30df\u30e9\u30fc\u30a4\u30e1\u30fc\u30b8\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u3001\u3055\u3089\u306b\u6301\u3061\u99d2\u304c\u3042\u3063\u305f\u5834\u5408\u306f\u5148\u624b\u3068\u5f8c\u624b\u304c\u9006\u306e\u307e\u307e\u3002\u3000Web\u30da\u30fc\u30b8\u306e\u4ed5\u7d44\u307f\u306f\u3053\u306esfen\u3092\u30b5\u30fc\u30d0\u30fc\u306b\u9001\u3063\u3066\u30b5\u30fc\u30d0\u30fc\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u3053\u306esfen\u306b\u5bfe\u5fdc\u3059\u308bmoves\u60c5\u5831\u3092\u8fd4\u3057\u3066\u3082\u3089\u3044\u3001\u6b21\u306e\u6307\u3057\u624b\u306e\u5019\u88dc\u3092\u30ea\u30b9\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u3068\u3044\u3046\u3082\u306e\u306a\u306e\u3067\u3001\u30df\u30e9\u30fc\u30a4\u30e1\u30fc\u30b8\u306e\u5c40\u9762\u7167\u4f1a\u306b\u306f\u30d2\u30c3\u30c8\u3059\u308b\u5019\u88dc\u624b\u306f\u3042\u308a\u307e\u305b\u3093\u3068\u3044\u3046\u7b54\u3048\u3057\u304b\u8fd4\u3063\u3066\u3053\u306a\u3044\u3002 AI\u306fSFEN\u304c\u4f55\u305f\u308b\u304b\u3092\u3042\u307e\u308a\u7406\u89e3\u3067\u304d\u306a\u3044\u307e\u307e\u3001WEB\u306b\u843d\u3061\u3066\u3044\u308b\u60c5\u5831\u3092\u304b\u304d\u96c6\u3081\u3066\u4f7f\u3063\u305f\u3088\u3046\u3067\u3001\u30d7\u30ed\u30f3\u30d7\u30c8\u3067\u3001SFEN\u306e\u5b9a\u7fa9\u304b\u3089\u59cb\u3081\u3001\u671f\u5f85\u3055\u308c\u308b\u30a2\u30a6\u30c8\u30d7\u30c3\u30c8\u306e\u30a4\u30e1\u30fc\u30b8\u3092\u3057\u3063\u304b\u308a\u4f1d\u3048\u3066\u304a\u304b\u306a\u3051\u308c\u3070\u3060\u3081\u3060\u3063\u305f\u304b\u3002 \u9006\u306b\u826f\u3044\u306d\u3068\u601d\u3063\u305f\u306e\u306f\u30a2\u30ec\u30a4\u3084\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u95a2\u6570\u3092\u30c1\u30a7\u30a4\u30cb\u30f3\u30b0\u3057\u3066\u8a18\u8ff0\u3059\u308b\u3001\u3044\u308f\u3086\u308bFunctional\u306a\u66f8\u304d\u65b9\u306b\u306a\u3063\u3066\u3044\u3066\u30b9\u30de\u30fc\u30c8\u3067\u3042\u308b\u3002\u3000\u3053\u308c\u306f\u771f\u4f3c\u3057\u305f\u3044\u3002 \u3068\u306b\u304b\u304f\u3001AI\u306b\u4ed5\u4e8b\u3092\u3055\u305b\u305f\u3089\u3001\u4eca\u306e\u6642\u70b9\u3067\u306f\u691c\u8a3c\u304c\u5927\u4e8b\u306a\u308f\u3051\u3060\u304c\u3001\u305d\u308c\u306a\u3089\u6700\u521d\u304b\u3089\u63d0\u4f9b\u3055\u308c\u305f\u30b3\u30fc\u30c9\u306f\u53c2\u8003\u307e\u3067\u306b\u7559\u3081\u3066\u304a\u3044\u3066\u3001\u5b9f\u969b\u306b\u4f7f\u3046\u30b3\u30fc\u30c9\u306f\u81ea\u5206\u3067\u66f8\u3044\u305f\u307b\u3046\u304c\u697d\u3057\u3044\u304b\u3082\u306d\uff08\u4ed5\u4e8b\u3067\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3057\u3066\u3044\u308b\u4eba\u306f\u3053\u3046\u306f\u8a00\u3048\u307e\u3044\uff09\u3002 \u8ffd\u8a18\uff1aYaneuraou\u3055\u3093\u304b\u3089flipsfen\u3092python\u3067\u4f5c\u6210\u3057\u305f\u6642\u306e\u985b\u672b\u306e\u30ea\u30f3\u30af\u3092\u6559\u3048\u3066\u3044\u305f\u3060\u3044\u305f\u3002\u3000https:\/\/yaneuraou.yaneu.com\/2023\/12\/15\/chatgpt-wrote-a-program-to-flip-a-shogi-board\/\u3000\u3000\u540c\u3058\u3088\u3046\u306a\u3068\u3053\u308d\u3067\u30cf\u30de\u3063\u3066\u3044\u308b\u3093\u3060\u3001\u3068\u53ef\u7b11\u3057\u304f\u306a\u3063\u305f\u534a\u9762\u3002\u3000\u3061\u3087\u3063\u3068\u5f85\u3066\u3001\u3053\u308c\u306f2\u5e74\u524d\u306e\u8a18\u4e8b\u3002\u3000\u3053\u308c\u3092\u8aad\u3093\u3067\u3044\u305f\u3089\u3053\u3093\u306a\u306b\u6642\u9593\u3092\u4f7f\u308f\u306a\u304f\u3066\u3082\u3088\u304b\u3063\u305f\u3058\u3083\u3093\u3000\u3068\u3082\u601d\u3063\u305f\u6b21\u7b2c\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48,16],"tags":[61],"class_list":["post-2133","post","type-post","status-publish","format-standard","hentry","category-programming","category-16","tag-typescript"],"_links":{"self":[{"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=\/wp\/v2\/posts\/2133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2133"}],"version-history":[{"count":19,"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=\/wp\/v2\/posts\/2133\/revisions"}],"predecessor-version":[{"id":2197,"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=\/wp\/v2\/posts\/2133\/revisions\/2197"}],"wp:attachment":[{"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}