å€åºå ã§ããŸããã¬ã€ããã«ã¯ãããã€ãã®åããå ã«èŠãå¿ èŠããããŸãããã®ã¹ãã«ã¯ãå€ãã®åé¡ãæ±ããŠãã解決çãããŸãéçºããŸãã åœç¶ã®ããšãªãããããæ¥ããããã®äºæã®æ ŒåãæžããŠãçæ³çã«ã¯åé¡ã«åã蟌ãã®ãããã ãããšããèãã«æãããŸãããç¹ã«ãadumããã®èããæ¿èªããã®ã§ã ç§èªèº«ã¯ãæ°ç§ã§çŽ1ã®é床ã§å€ããå°ãªããæå³ã®ããåããè©Šè¡ããéåžžã«ãããããªæ¹æ³ã§ããã解決ããŠããã®ã§ãæ€çŽ¢ã®éå§æ¹æ³ãå®æçã«å¿ããŠããŸãïŒãããŠããã¯ãäžããããåé¡3ãèªä¿¡ãæã£ãŠè§£æ±ºããã®ã«ååã§ãïŒãé床ãšç²ŸåºŠã¯æãåçŽãªæ€çŽ¢ãã€ãŸãdfsã§æ©èœããã¿ã¹ã¯ã®è€éãããæ°æ¥éããšè©äŸ¡ããŸããã ããã«ãç§ã¯ãã®æ ŒåãæãåçŽãªdfsã䜿ã£ãŠãæ£é¢ãããçŽ æ©ãæžã蟌ãããšããŸããããã¡ãã£ãšããè¿·æã«ã€ãŸãããŸããã èãçŽããã«ãç§ã¯æ¢ã«æ±ºããããäœçœ®ãä¿åããããã®ãã£ãã·ã¥ãéå§ããããã«å¥ã®è¿·æã«ã€ãŸãããŸããïŒå¥ã®åãã®ã·ãŒã±ã³ã¹ã§ãã®äœçœ®ã«æ¥ããšãäžåºŠèŠã€ãã£ã解決çã¯ééã£ãŠãããããããŸããã ããã§ç§ã¯äœããã¹ããããããã«ãã³ã°ã¢ããããŸãããããã®ãã©ãã«ã¯ç°¡åã«è§£æ±ºã§ãããšå€æããŸãããå°ãèããŠã¿ãã ãã§ãã ç§ã¯é·ãéèãããã®ãããã¯ã®æºåãã§ããŠãããã®ãèšäºãã¢ã«ãŽãªãºã ãªã©ãèŠãããšãçã«ããªã£ãŠãããšå€æããŸããã ç§ãæåã«åºäŒã£ãã®ã¯ãç¹å®ã®ãã©ã ãæ·±ã第äžèšŒæçªå·æ€çŽ¢ãã§ãããèšäºã®ãµã€ãºãæ°ããŒãžãããªãããšãèŠãŠãåãã§èªã¿å§ããŸããã ãã®èšäºã«ã¯ãMartinMÃŒllerãšAkishi Kishimotoã«ããä»ã®åæ§ã®èšäºãžã®ãªã³ã¯ãããããããã®èšäºã«ã¯ãªã³ã¯ããããKishimotoã«ãã200ããŒãžã®è«æãžã®ãªã³ã¯ããããåé¡ã®èŠæš¡ãèªèããŸãããéåžžã«åçŽãªãã®ã§ãããã»ãšãã©ã®å Žåãã¢ã«ãŽãªãºã ã®è€éãã¯éåžžã«è€éã§ããå Žåã«ãã£ãŠã¯ã質åã¯ãã¹ãŠã®ãªãã·ã§ã³ãã©ã®ããã«ãœãŒããããã§ã¯ãªããããŒãäžã§äœããèŠã€ããæ¹æ³ïŒåå¿è ã§ãããã«äœããããïŒãäœããã£ããã£ãŸãã¯é²åŸ¡ããå¿ èŠãããããç解ããæ¹æ³ïŒäººã«ãšã£ãŠãäºçŽ°ãªããšïŒãããã³ã©ã®ãããªåãããããŸãã ããã¯ïŒã»ãšãã©ã®å Žåãæããã§ãïŒãªãã·ã§ã³ã®å®éã®åæã«é¢ããŠã¯ã決å®ããããšèšããŸãïŒãã ããå¹æçãªåæã¢ã«ãŽãªãºã ã¯éåžžã«æ³šæãå¿ èŠã§ãïŒã äžè¬ã«ãç§ã®IQã¯æããã«å€åºå ã§ãã®ãããªåé¡ã解決ããã®ã«ååã§ã¯ãªãããšã«æ°ä»ãããã¹ãŠã®æå³ã®ããåããšç®æšãäºåã«èšå®ãããŠããæãåçŽãªã±ãŒã¹ã®ãœã«ããŒãå°ãªããšãæžããã°ãããšå€æããŸãã-ããã¯åé¡ã§ãéåžžã«åœ¹ç«ã¡ãŸãã
ç§ã®ç¥ãéãããã¹ãŠã解決ããããã°ã©ã ã¯ã»ãšãã©ãããŸããã
-Thomas Wolfã®GoToolsïŒæ倧15ã®å¯èœãªåããã¯ããŒãºããœãŒã¹ãéåžžã«é«åºŠãªéç解æãåããç°¡åãªdfsã
-Martin Mullerã®Tsumego ExplorerïŒã¡ãªã¿ã«7ãäžããããŸãïŒïŒæ倧30ã®å¯èœãªç§»åããªãŒãã³ãœãŒã¹JavaïŒã©ãã§å ¥æã§ãããã¯æ確ã§ã¯ãããŸãããïŒãMullerã®èšäºãšè«æã§èª¬æãããŠããéåžžã«é«åºŠãªéçåæã«ããé«åºŠãªl-df-pn-ræ€çŽ¢å²žæ¬ã
-Martin Mullerã®FuegoïŒãªãŒãã³ãœãŒã¹ã®C ++ïŒSourceForgeããããŠã³ããŒãå¯èœïŒã䜿çšããŠãæ¬æ Œçãª2+ããããæäŸãããŸãïŒç§ãããæããã«åŒ·åãªã®ã§ããã®åŒ·ãã¯è©äŸ¡ã§ããŸããïŒã
MÃŒllerãadumãjsæ ŒåãèããŠããŸããïŒãããŠãæ Œåã¯gosbleblemsã«åã蟌ãããšãã§ããããã«jsäžã«ãªããã°ãªããŸããïŒããããããªãããããæžãããšã¯çã«ããªã£ãŠããŸã-ç¹ã«MÃŒllerãšKishimotoãå€ãã®èšäºãšãã®ãããã¯ã«é¢ããããã°ã©ã ã§ããã
å·Šã¯å žåçãªã€ããã§ãã äžè¬çãªã±ãŒã¹ã§ã¯ãã¿ã¹ã¯ã¯é»ãšçœã®äž¡æ¹ã«å¯ŸããŠæé©ãªåãïŒããã³å¿ èŠãã©ããïŒãèŠã€ããããšã§ãã æããã«ãçœãå ã«åããå Žåã圌ãã¯ã³ãŒããŒããã£ããã£ããŸãã é»ãæåã«ç§»åãããšãè§åºŠãä¿åã§ããŸããã解ã®1ã€ã¯koã«ã€ãªãããé»ãkoã«è² ããå Žåã¯è§åºŠã倱ãããã1ã€ã®è§£ã¯koãªãã§è§åºŠãä¿åããŸããããã¯éåžžæãŸããããšã§ãã
ç°¡åã«ããããã«ãããŒããèŠãŠã解決ããããã«æŽçããå¿ èŠããããã¹ãŠã®æå³ã®ããåããèŠã€ããæ¹æ³ããããšä»®å®ããŸãïŒå®éãããã¯ãã¹ãŠã®åããæåã§èšå®ãããããšãæå³ããŸãïŒã ããŒãbã§èª°ãåã€ãã瀺ãé¢æ°Rãå®çŸ©ããŸãã
- é»ãå§ãŸãåã£ãå Žåã
- é»ãå§ãŸãè² ããå Žåã
Rã®å®çŸ©ã«ãããé»ã¯ç§ã®ãã©ã³ã¹ã厩ãããšããŠãæåã®åãããã矩åããããŸã-ããã¯çœãšé»ã絶ããééããç¶æ³ãæé€ããŸãã çœäººã«ã€ããŠãåæ§ã§ãã é»ãšçœã®äž¡æ¹ã倱ãããå Žåããããã¯ã»ã¯ã§ãã 次ã«ããã®é¢æ°ã次ã®ããã«ååž°çã«å®çŸ©ã§ããŸãã
å°ããããã«ããã§ããããã®æ¬è³ªã¯ã·ã³ãã«ã§ãã
- Rã®å®çŸ©ã«ããããã©ãã¯ã¯äœããã®åããäœåãªããããŠãããããå¯èœãªéããã¹ãŠã®åãã®äžãããã¹ããéžæããŸãã ãããã£ãŠããã¹ãŠã®ç§»åã®æ倧å€ã¯mã§ãã
- ãã®åŸãåãã¯çœã«ãªãã圌ãã¯åãããããããªããã決ãããããããŸãã-ããã¯æå°ã§ãã ãã¯ã€ããåããããå Žåãçµæ㯠ããã§ãb + mã¯ãé»ãç³mãè¿œå ãããããŒãbã§ãã
- çœãåããéããå ŽåïŒãããŠããããRã®å®çŸ©ãšççŸããªãå ŽåïŒãé»ã«ã¯éžæè¢ããããŸãïŒåãããããã»ãŒãããããã²ãŒã ãçµäºããŸã-ããã¯2çªç®ã®æ倧å€ã§ãã é»ãåãã°ãå€æ ããããŠããããã倱æããå ŽåãRïŒb + mïŒã¯èª°ãåã£ããã決å®ããŸãïŒå®éã«ã¯ãããã¯ãæç²ããå¿ èŠãããç³ãããŒãäžã«ãããã©ããã確èªããããã ãã§ãïŒã
çœã«ã€ããŠå¯Ÿç§°åŒãåŸãããŸãã ãé¡ããšæ°ãããšããã¹ãŠã®ãªãã·ã§ã³ãåæããåçŽãªdfsãåŸãããŸããããã¯ã5ãã€ã³ãã®æãåçŽãªæ»æã§ãéåžžã«ãã£ãããšåäœããŸãã 次ã®ããã«æžãããšãã§ããŸãã
function solve(board: Board, color: Color): Result { var result = -color; // that's a loss for (const move of board.getMovesFor(color)) { const nextBoard = board.fork().play(move); result = bestFor(color, // it's +color's turn, so he chooses result, bestFor(-color, // now it's -color's turn solve(nextBoard, -color), // -color makes a move bestFor(color, // -color can pass, but then it's +color's turn again solve(nextBoard, color), // +color makes two moves in a row estimate(nextBoard)))); // neither player makes a move } return result; }
ãã®ã¢ã«ãŽãªãºã ã¯ãæãåçŽãªç§ãç§ã§ããããšã蚌æããããã«å€ãã®æéã浪費ããããšã«æ³šæããŠãã ããã çœãšé»ã®ã°ã«ãŒãã«å ±éã®èªç±ã®ã¿ãããããããã®èªç±ãå€æ°ããå Žåããã®ã¢ã«ãŽãªãºã ã¯æåã«æåã®èªç±ã§ãã¬ã€ããããšãããããæ©èœããªãããšãèŠã€ãã次ã«2çªç®ã®èªç±ã§ãã¬ã€ããåã³åãŠãªãããšãèŠã€ããŸãã ãã®ã¢ã«ãŽãªãºã ããã¹ãŠã®ãªãã·ã§ã³ãå埩ããããã«è¡ã移åã®æ°ã«ã€ããŠãåçŽãªååž°åŒãäœæããããšãã§ããŸãã æé·ã¯ææ°é¢æ°ä»¥äžã§ãã ãã®åé¡ã¯ãããããéç解æã«ãã£ãŠã®ã¿è§£æ±ºã§ããŸãã
ããã§ãåãããŒãã2å解決ãããªãããã«ããå¿ èŠããããŸãã ããšãã°ã5ãã€ã³ãã®é«æ¶éè·¯ã®è§£æ±ºçãèŠã€ããããå¥ã®äœçœ®ããã®é«æ¶éè·¯ã«äžãã£ãå Žåã«åå©çšã§ããŸãã ãã®ãããªãœãªã¥ãŒã·ã§ã³ãã£ãã·ã¥ã¯éåžžã転眮ããŒãã«ïŒttïŒãšåŒã°ããŸãã ãã®ããŒãã«ã®ããŒã¯ãããŒãã®ããã·ã¥+æåã«è¡ã人ã®è²ã§ãã æåã¯ããã®ããã«åçŽã«å®è£ ããŸããã
const tt: { [key: string]: Result } = {}; function solve(board: Board, color: Color): Result { const key = color + board.hash(); var result = -color; // that's a loss if (key in tt) return tt[key]; for (const move of board.getMovesFor(color)) { const nextBoard = board.fork().play(move); result = bestFor(color, // it's +color's turn, so he chooses result, bestFor(-color, // now it's -color's turn solve(nextBoard, -color), // -color makes a move bestFor(color, // -color can pass, but then it's +color's turn again solve(nextBoard, color), // +color makes two moves in a row estimate(nextBoard)))); // neither player makes a move } return tt[key] = result; }
ãã®ã³ãŒãã®åé¡ã¯ãç³ã®äœçœ®ãèŠãã ãã§ã¯å€æã§ããªãäœçœ®ãããããšã§ãã ããšãã°ããã¯ã€ãã®åãã¯å·ŠåŽã«ãããŸããã誰ãåã€ããç解ããããšã¯äžå¯èœã§ãããªããªãããã¯ã€ãããã©ãã¯ã®ç³ãæãããããšãã§ãããã©ããã¯äžæã ããã§ãïŒã€ãŸããå žåçãªå ±åãŸãã¯2移åãµã€ã¯ã«ïŒ ã«ãŒã«ã®ãã®å°ããªä¿®æ£-äœçœ®ãç¹°ãè¿ãããšã¯ã§ããŸãã-ã¯ã²ãŒã äžã«åœããåã®ããšã§ãããåââé¡ãåŒãèµ·ããããšã¯ãããŸããããŸããã¹ãŒããŒã³ã«ãŒã«ïŒã€ãŸããæ°åã®ç§»åã䌎ããµã€ã¯ã«ã®çŠæ¢ïŒã¯ãæ¯æ¥10ã²ãŒã ããã¬ã€ããŠãäžçäŒããŸãã å¥åŠãªããšã«ãã¢ã«ãŽãªãºã ã®åæäžã«ãããã€ãã®åãã®é·ãïŒ5-7ã§ãã®ããã«åããŸãïŒã®ãµã€ã¯ã«ãååšãããšããä»®æ³çãªå¯èœæ§ã確å®ã«å®çŸããããããèæ ®ãããªãå Žåãçµæãæ£ãããªãããã¢ã«ãŽãªãºã ãã«ãŒãããŸãã ãããã£ãŠããã®äžèŠä»®æ³ã®åé¡ã¯ã岞æ¬ã®è«æãå埩ã®ååšäžã§ã®æ£ç¢ºãã€å¹ççãªæ€çŽ¢ã¢ã«ãŽãªãºã ããšããŠ200ããŒãžãæäžãããŸããïŒå®éãç§ã¯ãããå§åããããšããŠããŸãïŒã
ãã®åé¡ã®è§£æ±ºçã¯ãã¥ã©ãŒãšå²žæ¬ã®èšäºã§äœåºŠãèšåãããŠããã次ã®ããã«èãããŸãïŒè§£æ±ºçã®æ€çŽ¢ã§ç¹°ãè¿ããèŠã€ãããªãã£ãå Žåãããã¯åœŒãããã®äœçœ®ã«æ¥ãæ¹æ³ã«äŸåããŸããã ããªããããã«ã€ããŠèããå Žåãã¹ããŒãã¡ã³ãã¯ãŸã£ããæããã§ã¯ãããŸããã ç§ã蚌æã«ããããããŠãããšããç§ã¯ãã¥ã©ãŒã«æçŽãæžããŸããããããŠã圌ã¯ããã§ããããã¯éåžžã«åŒ·ããŠæ®éçãªå£°æã§ããã蚌æã¯è«æã®ã©ããã«ããããã§ãã ããã«ã¯ãã®èšŒæ ãèŠã€ãããŸããã§ããããæ¢ã«è§£æ±ºããããã¹ã«äŸåããªããã¹ãŠã®æ±ºå®ãïŒã¡ã¢ãªäžè¶³ã®ããïŒåé€ãããããšã¯ãªããšä»®å®ããã°æ©èœããç¬èªã®èšŒæ ãèããŸããã
説æã®ããã«ãç§ã¯æ¥ç¥ããã«èª°ãããåçãã³ããŒããŸãã:)å¯èœãªåãã®ã°ã©ãã¯éåžžãåçã®äžã®ãã®ããªãŒã®ããã«èŠããŸãã ãã®ã°ã©ãã®äžéšã¯ãããŒãäžã®ç³ã®äœçœ®ãè¡šããè²ã¯èª°ãåããã瀺ããŸãã ç°¡åã«ããããïŒãããŠäžè¬æ§ã倱ãããšãªãïŒã13çªç®ã®ããžã·ã§ã³ãå ã«æ±ºå®ãããæ€çŽ¢ããã»ã¹ã§ãµã€ã¯ã«ãèŠã€ãããªãã£ãéã«Blackãéå§ããŠåã£ãããšãå€æãããšä»®å®ããŸãã ãœãªã¥ãŒã·ã§ã³ã¯ããªãŒã§ããïŒãµã€ã¯ã«ã¯ãããŸããïŒãåé»ãé ç¹ãã1ã€ã®åããè¡ããïŒãœãªã¥ãŒã·ã§ã³ã®æ¬è³ªã¯ä»»æã®äœçœ®ã§æ£ããåãã瀺ãããšã§ãããããå¿ èŠãããŸããïŒããã¹ãŠã®å¯èœãªåãã¯åçœãé ç¹ããè¡ãããŸãïŒãœãªã¥ãŒã·ã§ã³çœã®åãããšã«é»ã®åãããããé»ã®åå©ã«ã€ãªããããšã蚌æããå¿ èŠããããŸãïŒã ããã§ãã¹ããŒãã¡ã³ããçå®ã§ã¯ãªãã13ã®äœçœ®ã§èŠã€ãã£ã解ããããå«ãŸãããã¹ã«äŸåãããšä»®å®ããŸãã ã©ãããããã決å®ãééããæ¹æ³ããããŸãã ãã®ãããªãã¹ããã·ãžã§ã³ããªãŒãšäº€å·®ããªãã£ãå Žåããã®ãã¹ã«åœ±é¿ãäžããããšã¯ã§ããŸããããã®ä»®æ³ãã¹ã«ã¯ãããªãŒã®å°ãªããšã1ã€ã®é ç¹ãå«ãŸããŸãã ãã®ããŒã¯ãåãããããå¿ããã«ãã®çµè·¯ã«æ²¿ã£ãŠããŒã¯13ã«é²ãã§ãã ããã
- 13ã®ãœãªã¥ãŒã·ã§ã³ã¯æ¢ã«ãã£ãã·ã¥ãããŠããã
- ãµã€ã¯ã«ãæ€åºããã«èŠã€ãã£ããã¹ãŠã®äžéãœãªã¥ãŒã·ã§ã³ããã£ãã·ã¥ã«æ®ããŸããã
é ç¹17ããå§ããŠã13ã«å°éããããšãããšããŸãã蚌æã®æ¬è³ªã¯ã決å®ããªãŒã«ãµã€ã¯ã«ããªãããã17ãã13ã«æ¥ç¶ããããã«ããªãŒãè¶ ããå¿ èŠãããããšã§ãã é ç¹17ã¯çœïŒãŸããã¯ããããã¯èµ€ã§ããããããçœã§ãããšä»®å®ããŸãïŒã§ããããããã£ãŠãããããã®ãã¹ãŠã®åãã¯ããªãŒå ã«ãããŸãã 25çªç®ã®ãã©ãã¯ããŒã¯ã«éãããšããŸãããã é ç¹ã¯é»ã§ããããããã®ãœãªã¥ãŒã·ã§ã³ïŒæ£ãã移åïŒã¯ãã£ãã·ã¥ã«æžã蟌ãŸãïŒããããã¯äœãåé€ãããŸããïŒã25ã®ãœãªã¥ãŒã·ã§ã³ãèŠã€ãã£ãåŸããã®ä»®æ³ãã¹ã«æ²¿ã£ãŠé²ããããæ¢è£œã®ãœãªã¥ãŒã·ã§ã³ããã£ãã·ã¥ããååŸãããŸã ããªãŒå ã«ããçœãããŒã¯ã«å ¥ããŸãã ã§ãããããã®ä»®æ³çãªéããã©ããåãã®ãªãè¡ãè©°ãŸãã«é¥ããŸã§åŸ ã¡ãŸãã
ã芧ã®ãšãããã«ãŒãã®åé¡ã解決ããã«ã¯ãããªãã®éãå¿ èŠã§ãã
- äœçœ®ã§ã¯ãªããã¹ã®è§£æ±ºçãæ¢ããŸãïŒè§£æ±ºïŒãã¹ïŒããŒã[]ãè²ïŒè²ïŒã
- æ€çŽ¢äžã«ç¹°ãè¿ãã«ééããå ŽåããããæåãšèŠãªããŸãããåæã«ãç¹°ãè¿ããããã¹ã®å é ãæããŸãïŒãã¹ã®ã€ã³ããã¯ã¹ãèŠããŠãããŠãã ããïŒã ãã¢ïŒçµæãã€ã³ããã¯ã¹ïŒã®æå³ã¯ã解ã¯ç¡æ¡ä»¶ã§ã¯ãªããç¹å®ã®äœçœ®ã§ã®ç¹°ãè¿ãã«äŸåãããšããããšã§ãã
- ãã¹ãŠã®å¯èœãªåãã®äžã§ãã¹ãŠãæåã«ã€ãªããå Žåãç¹°ãè¿ãã瀺ããã¹ãŠã®ã€ã³ããã¯ã¹ã®äžã§æå°å€ãèŠã€ãããã®æå°å€ãè¿ããŸãã
- åã¡æãããå Žåã¯ãå¯èœãªéã倧ããªç¹°ãè¿ãã€ã³ããã¯ã¹ãæã€ãã®ãéžæããããšãæãŸããã§ãã æè¯ã®å Žåãã²ã€ã³ã¯ç¡æ¡ä»¶ã«ãªããŸãã ãã¹ã«äŸåããŸããã
ããïŒããã³ç³ã®èªç±åºŠãæ倧åããä»ã®äººã®èªç±åºŠãæå°åããåçŽãªãã¥ãŒãªã¹ãã£ãã¯ïŒã¯ãæãåçŽãªå€§å·¥ã®æ£æ¹åœ¢ã解ãã®ã«ååã§ãã
æåã®äŸã®ããã«ããã£ãšé¢çœãããšã解決ããã«ã¯ãcoãèæ ®ããå¿ èŠããããŸãã èããããã¢ãããŒãã®1ã€ã¯ããåçã«ãæ€èšããããšã§ãã æ€çŽ¢ããã»ã¹ã§ç¹°ãè¿ããçºçããå Žåã¯ãæ€çŽ¢ã2ã€ã®ã±ãŒã¹ã«åå²ããŸãïŒè åšãããå Žåãšãªãå ŽåïŒãããã®ããã«ã¯ã³ãŒãå šäœã培åºçã«ã·ã£ãã«ããå¿ èŠããããŸãã å¥ã®ã¢ãããŒãã¯ã次ã®ãéçããªäŒèšã§ãã
- æ°ãããã©ã¡ãŒã¿ãŒã¯ãå€éšã®è åšã®æ°ã§ãã ãã®ãã©ã¡ãŒã¿ãŒã+3ã®å Žåãé»ã«ã¯ããã«3ã€ã®è åšãããã-2ã®å Žåãçœã«ã¯2ã€ã®è åšããããŸãã
- 決å®ããã»ã¹äžã«ç¹°ãè¿ããçºçãããã®ç¹°ãè¿ãã«å¯Ÿããè åšãããå Žåãç¡é§ã«ãªãããã¹ããªã»ãããããŸãïŒå®éãè åšã®ç®æšã¯ããã¹ããªã»ãããããŒãããæ€çŽ¢ãéå§ããããšã§ãïŒã
- ãã£ãã·ã¥å ã®æ±ºå®ã¯ãåäžã®æ°å€ïŒ+1ãŸãã¯-1ïŒãšããŠã§ã¯ãªããäž¡åŽã®æ°åã®ç¡éã®é åãšããŠæžã蟌ãŸããããããã®å ±è åšã®æ°ã«å¯ŸããŠçµæãæžã蟌ãŸããŸãïŒ-2å ±è åšã®å Žåãçœãå ±è åšã1ã€ã ãæã€å Žåãçœãåã¡ãŸãã secaãå€æããè åšããªããã°é»ãåã¡ãŸãã æããã«ãé»ãNåã®è åšã§åã£ãå Žåã圌ã¯N + 1ã§ãåã¡ãŸãã çœäººã«ã€ããŠãåæ§ã§ãã ããã¯ããœãªã¥ãŒã·ã§ã³ã2ã€ã®æ°åã®åœ¢åŒã§èšè¿°ã§ããããšã瀺ããŠããŸããåå©ããã®ã«ååãªé»ã®è åšã®æ°ïŒmaxbïŒãšãåå©ããã®ã«ååãªçœã®è åšã®æ°ïŒminwïŒã§ãã ãããŠãkåã®coè åšãæã€bã®è§£ãæ¢ããŠãããb minwãšmaxbã以åã®è§£æ±ºã®è©Šã¿ããç¥ãããŠããå Žåãk <minwïŒçœåïŒãšk> maxbïŒé»åïŒã®çããããã«è¿ãããšãã§ããŸãã minw <k <maxb解決çãæ¢ãå¿ èŠããããŸãã
interface Results { minw: number; // white wins if nkt <= minw maxb: number; // black wins if nkt >= maxb } const tt: { [key: string]: Results } = {}; function solve(path: Board[], color: Color, nkt: number): Result { function solveFor(color: Color, nkt: number): Result { const board = path[path.length - 1]; const key = color + board; const cached = tt[key] || { minw: -Infinity, maxb: +Infinity }; if (color > 0 && nkt >= cached.maxb) return +1; // black has enough ko treats to win if (color < 0 && nkt <= cached.minw) return -1; // white has enough ko treats to win var result = -color; // that's a loss var depth = Infinity; // where repetition occured /* ... */ if (color > 0 && nkt < cached.maxb) cached.maxb = nkt; if (color < 0 && nkt > cached.minw) cached.minw = nkt; tt[key] = cached; return [result, depth]; } return solveFor(color, nkt); }
ããŠãå€éšã®è åšãèæ ®ããŠåé¡ã解決ããããã«ãæåã«è åšããªããšããä»®å®ã®äžã§ããã解決ããå¿ èŠãããïŒnkt = 0ïŒãçµæãå€ãããŸã§ãã®ãã©ã¡ãŒã¿ãŒãå¢æžãç¶ããŸãã ããã¯ãçè«çã«ã¯æ±ºå®ã°ã©ãã«ãã£ãŠæ±ºå®ã§ããŸããèŠã€ãã£ããœãªã¥ãŒã·ã§ã³ã倱ãããkoã«äŸåããå Žåã1ã€ã®å€éškoè åšãè¿œå ããŠå床解決ããã®ãçã«ããªã£ãŠããŸãã å®éã«ã¯ãç§ã¯ãããããŸããã§ãããå¿ èŠãªè åšã®æ°ã1ãè¶ ããããšã¯ã»ãšãã©ãããŸããã 解決ããããã«2ã€ã®koãç²åŸããå¿ èŠãããåé¡ããããŸãããããã¯ãšããŸããã¯ã§ãããããã£ãŠã| nk2 | <2ã§è§£æ±ºããå Žåãäžè¬ã«ãåé¡ã¯è§£æ±ºãããšèšããŸãã ãã®ããã«ããã£ãã·ã¥ãåããæåã®ãœãªã¥ãŒã·ã§ã³ïŒéåžžã¯nkt = 0ã®å ŽåïŒã®æ€çŽ¢ã«99ïŒ ã®æéãè²»ãããããã®åŸãä»ã®nktã®ãœãªã¥ãŒã·ã§ã³ãïŒJSã§ãïŒã»ãŒç¬æã«èŠã€ããããšã«æ³šæããŠãã ããã
ããã ãã§ãã æé©åã®ãªãJSäžã®ãã®ãããªåçŽãªã©ãã£ã¹ã¯ããã¹ãŠã®äººïŒGCãããŒããããã®ïŒã«äžæãªããžã§ã¯ããäœæããå移åãããŒãå šäœãã³ããŒããåã«ãæ°ç§ã§åèš10åã®ç©ºãã»ã«ããã°ãã解決ã§ããŸãïŒããšãã°æåã«èŠãããã®ïŒã å°ã倧ãããªããšãã»ãšãã©ã®å Žåããã³ã°ããGCãããŒãããŸãã ãã ããã¢ã«ãŽãªãºã ãé«éåããæ¹æ³ã¯ããããããããããã®çš®ã®æé©åã«ã¯æå³ããããŸããã
- é«åºŠãªæ·±ãæ€çŽ¢ãé©çšããŸãïŒdfpnãdfpnrãldfpnrã Mullerã¯ãldppnrã¯27åã®ç©ºãã»ã«ã§ãããå§åã§ãããšæžããŠããŸãã
- éç解æã¢ã«ãŽãªãºã ãæžã-ãŸã Bensonã®ã¢ã«ãŽãªãºã ãå®è£ ããŠããŸããã 誰ãåã£ãããæãããªå Žåãããã¯æ€çŽ¢ãåæ¢ããŸãã ããããããããã¹ãŠãè¿ éã«è§£æ±ºã§ããäž»ãªçç±ã§ããéåžžãé ã®äžã§è§£æ±ºçãèŠã€ããããšã¯ãè©äŸ¡ã§çµããããã€ãã®çãã·ãŒã±ã³ã¹ãæŽçããããã«èŠããŸãã
- ããŒãäžã®äœããæ¢ãæ¹æ³ãšç§»åããå ŽæãèãåºããŸãã ãããè¡ãã«ã¯ãèªåã®èããã泚ææ·±ãã泚ææ·±ã芳å¯ããäœããæ£ç¢ºã«èŠã€ããæ¹æ³ãç解ããã ãã§ãã ãã¡ããããã®æ¢çŽ¢ã®éµã¯ãã°ã«ãŒãã2ã€ã®ç®ãäœãããšãã§ãããã©ãããå€æããããšã«åºã¥ããŠãã°ã«ãŒãïŒå°æ°ã®å¯éããç³ïŒã®æŽ»åãè©äŸ¡ããããšã§ãïŒããã¯åžžã«ã匱ããŠæ¯èŒç倧ããªã°ã«ãŒãã®è¿ãã«é 眮ãããŸãïŒãã®ãããããããã£ããã£ãŸãã¯ä¿åããã®ã«æå³ããããŸãïŒ
- ã¹ã¯ã€ãºããŠã§ããžãã¹ãããããã¯ãã©ããŒãããããªã©ã®ããªãã¯ã©ã€ãã©ãªïŒtesujiïŒãäœæããŸãã ãããã®ããªãã¯ã¯ãå¿ã®äžã§è§£æ±ºçãèŠã€ããäžã§å€§ããªåœ¹å²ãæãããŸããçµå±ã®ãšãããã¹ãããããã¯ãèŠã€ããããã«å¯èœãªãªãã·ã§ã³ããã¹ãŠèšç®ããããã§ã¯ãããŸãã-ç³ã®ç¹åŸŽçãªçµã¿åããã«æ°ã¥ãããã®ããªãã¯ããäœããçµãããšãã§ãããã©ããã確èªããã ãã§ãã
æ°ã«ãã人㯠ã githubã§ã³ãŒããèŠãããšãã§ããŸãã ççŽã«èšã£ãŠãé床ãç ç²ã«ããããšãªãã¢ãžã¥ãŒã«ã«åå²ãããããã«ã©ãã£ã¹ã³ãŒããæŽçããæ¹æ³ãç解ãããããã«ããã¹ãŠãæžãæããŠnafigããå¿ èŠããããŸãããªã© ããŠãåäœãã¹ããæžãããšãã§ããããã«ãããã§ãªããã°ãåå€æŽã®åŸãããã®ããããã¯ãŸã æ©èœããŸããïŒã