Блог пользователя Aspergillus

Автор Aspergillus, 3 месяца назад, По-английски

I recently read about the Sprague grundy theorem on cp-algorithms, and I have been thinking about the extension of the example given in the website. Below I explain the game and the solution, can anyone with some experience on this theorem tell me if I am correct or correct me please? The game is as follows, we have several piles of stones. In one move we can pick a pile and then remove

i) if it has at least 3 stones then remove three numbers from it, then optionally we can split the pile into two parts.

ii) if at least two stones, we can remove two stones from it

iii) if it has only one stone then we can remove a single stone from it.

(as one may identify, this is similar to the example given the the cp-algorithms.com article on the Sprague-Grundy Theorem (crosses-crosses), only different thing is we have several strips, equivalently stone piles) A player has to do any one of the three moves in his/her turn. The one who has no moves loses as usual. My algorithm for solving this would be to calculate the grundy number for each pile (I will xor sum them later using bouton's theorem) the grundy number can be calculated by calculating the mex of G(n — 2), G(I — 2) xor G(n — I — 1) (for all I in 2 to n — 1) and G(n — 1). The term G(I — 2) xor G(n — I — 1) for each possible I is there to account for the optional splitting of the piles, which is indeed a valid state that the initial pile points to. Terms are added in the set (whose mex we will find later) keeping in mind that they satisfy the criteria, eg, G(n — 1) should be included in the set only when n == 1. etc. I calculate the mex recursively, then xor sum the result to find the grundy number of the final state.

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится