|
MATHEMATICA
|
remove = 3; add = 2;
(*Given n and m, list all possible assignments.*)
alltuples[n_, m_] := IntegerPartitions[m + n, {n}] - 1;
(*Given an assignment, list all resultant assignments after one pebbling move; only work for n>=3.*)
pebblemoves[config_] := Block[{n, temp},
n = Length[config];
temp = Table[config, {i, n (n - 1)}] +
Permutations[Join[{-remove, add}, Table[0, {i, n - 2}]]];
temp = Select[temp, Min[#] >= 0 &];
temp = ReverseSort[DeleteDuplicates[ReverseSort /@ temp]]];
(*Given n and m, list all assignments that are P-games.*)
Plist = {};
plist[n_, m_] := Block[{index, tuples},
While[Length[Plist] < n, index = Length[Plist];
AppendTo[Plist, {{Join[{1}, Table[0, {i, index}]]}}]];
Do[AppendTo[Plist[[n]], {}]; tuples = alltuples[n, i];
Do[If[Not[IntersectingQ[pebblemoves[tuples[[j]]],
If[i > (remove - add), Plist[[n, i - (remove - add)]], {}]]],
AppendTo[Plist[[n, i]], tuples[[j]]]], {j, Length[tuples]}],
{i, Length[Plist[[n]]] + 1, m}]; Plist[[n, m]]];
Do[m = 1; While[plist[n, m] != {}, m++]; Print[" n=", n, " m=", m], {n, 3, 24}]
|