MXBT18.07 夢溪筆談·圍棋變局 Mengxi Bitan: Configurations of Go

**《夢溪筆談·卷十八技藝·第七篇》**

小說：唐僧一行[1]曾算棋局都數，凡若干局盡之。 予嘗思之，此固易耳，但數多，非世間名數可能言之。
今略舉大數：凡方二路，用四子，可變八十一局；方三路，用九子，可變一萬九千六百八十三局；方四路，用十六 子，可變四千三百四萬六千七百二十一局；方五路，用二十五子，可變八千四百七十二億八千八百六十萬九千四百 四十三局；**【古法：十萬為億，十億為兆，兆為稊[2]。 算家以萬萬為億，萬億為兆，萬兆萬為垓。 今但以算家數計之。 】**方六路，用三十六子，可變十五兆九十四萬六千三百五十二億八千二百三萬一千九百二十六局[3]；方七路以上， 數多無名可記。 盡三百六十一路，大約連書萬字四十三，即是局之大數[4]。 **【萬字四十三，最下萬字即萬局，第二是萬局，第三是萬億局，第四是一兆局，第五是兆局，第六是萬兆，謂之 一垓，第七是萬垓局，第八是萬萬垓，第九是萬億萬垓。 此外無名可紀，但四十三次萬倍乘之，即是都大數，零中數不與。 】**
其法：初一路可變三局。 **【一黑、一白、一空。 】**自後不以橫直，但增一子，即三因之。 凡三百六十一增，皆三因之，即是都局數。
又法：先計循邊一行為“法”，**【凡十九路， 得一十億六千二百二十六萬一千四百六十七局。 】**凡加一行，即 以「法」累乘之，乘終十九行，亦得上數。
又法：以自「法」相乘**【得一百三十五兆八百五十一萬七千一百七十四億四千八百二十八萬七千三百三十四局，此 是兩行，凡三十八路變成此數也。 】**[5]下位副置之，以下乘上，又以下乘下，置為上位；又副置之，以下乘上，以下乘下；加一“法”，亦得上數。 有數法 可求，唯此法最徑捷。 **【只五次乘，便盡三百六十一路。 】**千變萬化，不出此數，棋之局盡矣。

***Mengxi Bitan* Chapter 18 Technical Arts 7**

According to a story, the Buddhist monk Yi Xing[1] of the Tang dynasty calculated the total number of different configurations that may be placed on a Go board. I have thought of the problem as well, and found the method of calculation rather straightforward. However, the number of configurations is so large that it cannot be properly expressed by the numbers that are commonly known.

Here I shall present some examples. If the board is a 2x2 square grid, then it has four positions, which can produce 81 different configurations. If the board is a 3x3 square grid, then it has nine positions, which can produce 19,683 different configurations. If the board is a 4x4 square grid, then it has sixteen positions, which can produce 43,046,721 different configurations. If the board is a 5x5 square grid, then it has twenty-five positions, which can produce 847,288,609,443 different configurations. **(According to the ancient number system: *yi* is 10 multiplied by 10,000, *zhao* is 10 multiplied by 100,000,000, *ti*[2] is 10,000 multiplied by *zhao*. However, for mathematicians, *yi* is 10000 multiplied by 10,000, *zhao* is 10,000 multiplied by 10,000 *yi*, and *gai* is 10,000 multiplied by 10,000 *zhao*. Here we use the calculation method of the mathematicians.)** If the board is 6x6 square grid, then it has thirty-six positions, which can produce 150,094,635,282,031,926[3] different configurations. If the board is a 7x7 square grid or larger, the number of different configurations is too large to be written out. Exhausting the 361 positions of a true Go board, the number of configurations is approximately the number 10,000 being written consecutively forty-three times[4].
**(This so-called “forty-three 10,000s” means the last 10,000 is 10,000, the second is 108, the third is 1012, the fourth is 1016, the fifth is 1020, the sixth is 1024, which is called one *hai*, the seventh is 1028, the eighth is 1032, the ninth is 1036.** **Beyond that there is no name to express it; however, the product of 10000 to the power of 43 is the approximate order of magnitude of this large number while the remaining digits are not included.)**

The method: first consider a point, which can have three possible configurations. **(Black, white, or empty.)** Each additional position, regardless if it is horizontal or vertical, will contribute an additional multiple of 3. When this is increased to 361 points, the total number of configurations is obtained by a multiple of 3 for every point.

Another method: First calculate the number of configurations of one side and take it as the “base number” (法 *fa*). (**There are 19 points in one line, so the number of configurations is 1,162,261,467.)** If one more line is added to it, multiply it by the “base number”. When it is multiplied 19 times, we get the same number.

Another method: First multiply the “base number” by itself. **(The product is 1,350,851,717,448,287,334[5], which is the number of configurations for two lines with a total of 38 positions.)** Then use the product as the multiplier and multiply the “base number” by the multiplier, and get the second result. After that, multiply the second product by itself and get the third product. Next use the third product as the multiplier and multiply it with the second product to get the fourth product. The total number of configurations is obtained after multiplying the product by itself and then multiplying it with the “base number”. Among these methods, this one is the quickest. **(Only five calculations were made to arrive at the answer for 361 points.)** Of all the myriad changes, the total number of configurations on a *weiqi* board will never exceed this number. This is indeed the final answer.

**【注释】**

[1] 一行：本名**张遂**（公元673年～公元727年），唐朝天文学家、数学家、发明家、僧人。

Yi Xing: Original name Zhang Sui (673 – 727 AD), astronomer, mathematician, inventor and Buddhist monk of the Tang Dynasty.

[2] “稊”应该写为“秭”。

The character “稊” *ti* should be written as “秭” *zi*.

[3] 正确数值应该是150,094,635,296,999,121。

The correct number should be 150,094,635,296,999,121.

[4] 沈括给出 10172，更准确数值大约为 1.7409 x 10172。

Shen Kuo gave the value 10172; however, the more accurate value is 1.7409 x 10172.

[5] 正确数值应该是1,350,851,717,672,992,089。

The correct number should be 1,350,851,717,672,992,089.

**【今译】**

据小说记载：唐朝僧人一行曾算过围棋时可能下出不同局面的总数，一共有多少局，他都算出来了。我也曾经考虑过，这当然容易。但棋局数目太大，不是用现在的大数名称可以表达出来。

现在我大略说一下。如果棋盘是两路见方，就有4个用子位置，可以变化出81种棋局；是三路见方，就有9个用子位置，可以变化出19683种棋局；是四路见方，就有16个用子位置，可以变化出43,046,721种棋局；是五路见方，就有25个用子位置，可以变化出847,288,609,443种棋局。**【根据古法：十万为亿，十亿为兆，万兆为秭。而算家以万万为亿，万万亿为兆，万万兆为垓。】**我们现在用算家的计算方法来计数。如果棋盘是六路见方，就有36个用子位置，可以变化出150,094,635,282,031,926\*种棋局。七路以上布局的，变化的局数无法记下来。如果将棋盘361路的变局全记下的话，大概要连写43个万字才是局的大致数字**。【43个万字，那么最后一个万字表示万局，第2个万字是万万局，第3个万字是万亿局，第4个万字是兆局，第5个万字是万兆局，第6个万字是万万兆局，万万兆为一垓，第7个万字是万垓局，第8个万字是万万垓局，第9个万字是万亿垓局。再往上就没有大数名词好用了。连接43次万倍相乘后所得的积数就是棋局总数的大概。这里只给出第一位的数字，其余的数字都略而不讲。】**

计算棋局的方法，第一个点可以有3种布局。**【或放黑子、或放白子、或空着不放子。】**从它出发，不论横直，每增加一个点，就多成一个3；一直增加到全盘361点，每次都多乘一个3，就得到棋局的总数。

另一种算法：先算出沿边一行的局数，这个数称为基本数，以此作为“法”**。【一行共 19 个点， 共得 1,162,261,467局。】**每加一行，就用“法”乘一次，乘尽 19 行，也得到上述的棋局总数。

还有一种算法：先用“法”自乘**，【得 1,350,851,717,448,287,334局，这是两行共 38 点变化出来的局数。】** 然后乘积作为乘数，用乘积乘“法”，再把两次的乘积相乘，得到第三次乘积；又把这个数作乘积，与第二次乘的积数相乘，再把所得的积相乘，又与“法”相乘，也能得到前段所讲的总数。求棋局总数有几种方法，只有这种方法最快捷。**【只须要五次运算就得出 361 个点所变化出的棋局总数。】**棋盘上可能布置出的局面千变万化，也不会超过这个数，棋局的总数就算尽了。