In the previous article, we carefully studied the NIM game and learned how to find a winning strategy. But if you add or change the NIM rules, can you quickly find a winning strategy? For example, if there are n piles of stones, one, two, or three of the 1st piles of stones can be taken each time, and an odd number of stones can be taken from the 2nd piles, you can get any stone from 3rd piles or later ...... This may seem complicated, but I believe that if you have mastered the content of this section, similar ever-changing problems will not be a problem. Now let's look at a game that seems more general: Given a directed acyclic graph and a pawn on a starting vertex, the two players move the piece along a directed edge in turn, and those who cannot move the piece are judged to be negative. In fact, this game can be considered as an abstract model of all impartial combinatorial games. That is to say, any ICG can regard each situation as a vertex, and abstract each situation and its sub-situation into a directed graph game by a directed edge ". Next we will define the SD-garundy function on the vertex of the directed acyclic graph. First define the Mex (minimal excludant) operation, which is applied to a set operation, indicating the smallest non-negative integer that does not belong to this set. For example, Mex {0, 1, 2, 4} = 3, Mex {2, 3, 5} = 0, and Mex {} = 0. For a given directed acyclic graph, the following G function is defined for each vertex of the graph. g (x) = Mex {G (y) | Y is the successor of x }. Let's take a look at the nature of SG functions. First, all the vertex corresponding to the terminal position, that is, the vertex without an outbound edge, and its SG value is 0, because its successor set is an empty set. Then for a vertex x whose g (x) = 0, all its successor y satisfies g (y )! = 0. For a G (x )! = 0 vertex, there must be a successor y to meet G (y) = 0. The above three statements show that the postion represented by vertex x is P-position when and only when g (x) = 0 (exactly corresponds to the three sentences defined by P-positioin/n-position ). By calculating the SG value of each vertex in a directed acyclic graph, we can find a winning strategy for each situation. However, the usage of SG functions is far less simple. If we make directed graph games more complex, for example, a directed graph does not have only one piece, but has n pieces. You can choose one to move each time, how can we find a winning strategy? Let's take another look at the significance of the SG value of the vertex. When g (x) = K, it indicates that for any 0 <= I <K, a successor y of X satisfies g (y) = I. That is to say, when the SG value of a piece is K, we can change it to 0, to 1 ,...... , Into the K-1, but never keep K unchanged. I don't know if you can think of the NIM game based on this. The rule of the NIM game is: each time you select a pile of K stones, you can change it to 0, to 1 ,...... , Into the K-1, but never keep K unchanged. This indicates that if the SG value of the vertex where n pieces are located is considered as the corresponding number of stones in N heaps, then each winning strategy of this Nim game corresponds to the winning strategy of the original n pieces! For N pawns, set the SG values of the corresponding vertex to (A1, A2 ,..., an), set up another situation (A1, A2 ,..., an) when a winning strategy of the NIM game is to turn AI into K, a winning strategy of the original game is to move the I-th piece to the vertex where the SG value is K. This sounds a little amazing-how can I go back to the NIM game after a lap. In fact, we only need to prove that the digraph game of multiple pawns is P-position. Only when the SG function where all pawns are located is different or 0. This proves that it is almost identical to the Bouton's theorem in the previous section. You just need to change a few nouns as appropriate. Just now, in order to make the problem look easier, I thought that N pieces were moving on a directed graph. However, if it is not on a directed graph, but on a directed graph, each piece can be moved by a piece (that is, a directed graph), which will not bring any changes to the conclusion. So we can define sum of graph games: Set G1, G2 ,...... And GN are N directed graph games. The game G is defined as G1, G2 ,...... , GN sum, the movement rule of game G is: select a sub-game GI and move the Above pawn. SD-Grundy theorem is: G (G) = g (G1) ^ g (G2) ^... ^ g (GN ). That is to say, the SG function value of the game's sum is the exclusive or of the SG function value of all its sub-games. Consider one sentence at the beginning of this article: any ICG can be abstracted into a directed graph game. Therefore, the concepts of "SG function" and "game sum" are not limited to directed graph games. We define the SG value for each position of each ICG, or the sum of n icg. So when we face a game composed of N game groups, we only need to find the SG value for each game to find its situation, we can regard all these SG values as the NIM stone heap, and then follow the method of finding Nim's winning strategy to find the winning strategy of this game! Go back to the question at the beginning of this article. There are n piles of stones, each time you can get 1, 2 or 3 from 1st piles of stones, you can get an odd number from 2nd piles of stones, you can get any stone from 3rd piles or later ...... We can think of it as three sub-games, with 1st sub-games containing only one pile of stones. Each time we get one, two, three, it is easy to see that the SG value of X stones is X % 4. The 2nd sub-game also has only one pile of stones. Each time it can take an odd number of stones, you can know through simple drawing that the SG value of this game when there are X stones is X % 2. 3rd games with N-2 heap stones, is a nim game. For each situation of the original game, the SG value of the three sub-games is different or the SG value of the entire game is obtained, then you can determine whether there is a winning strategy and make a decision based on the SG value. In fact, three sub-games are more conservative, and n sub-games are simply considered. Among them, 1st and 2 sub-games are described above, and 3rd and later sub-games are all "1 pile of stones, each time a few pieces can be retrieved, it is called "any stone game". In this super simple game, the SG value of X stones is obviously X. In fact, isn't the NIM game of N heap stones itself the sum of N "any stone games? Therefore, for us, the concept of SG functions and "game's sum" does not allow us to combine and create strange games, instead, we try to split some seemingly complex games into several sub-games, and find its SG function for each sub-game that is much simpler than the original game, then, the original game's SG function is obtained in an exclusive way to solve the problem. In the following articles, I will explain the questions in OJ! |