Nim
Nim
A game is a particular path....
In[]:=
NimMoves[list:{_Integer..}]:=Catenate[Table[If[list[[i]]0,Nothing,ReplacePart[list,i#]&/@Range[0,list[[i]]-1]],{i,Length[list]}]]
In[]:=
NimMoves[(list:{_Integer..}),maxdelta_Integer]:=Catenate[Table[If[list[[i]]0,Nothing,ReplacePart[list,i#]&/@Range[list[[i]]-maxdelta,list[[i]]-1]],{i,Length[list]}]]
In[]:=
NimMoves[{3,2,1}]
Out[]=
{{0,2,1},{1,2,1},{2,2,1},{3,0,1},{3,1,1},{3,2,0}}
This picture is not foliated like game moves....
In[]:=
ResourceFunction["MultiwaySystem"][<|"StateEvolutionFunction"NimMoves,"StateEquivalenceFunction"SameQ,"StateEventFunction"Identity,"EventDecompositionFunction"Identity,"EventApplicationFunction"Identity,"SystemType""None","EventSelectionFunction"Identity|>,{{3,2,1}},4,"StatesGraph","StateRenderingFunction"(Inset[Style[Row[#2],Black],#1,BackgroundLighter[Blue,.9]]&)]
Out[]=
In[]:=
Graph[%,GraphLayout"LayeredDigraphEmbedding"]
Out[]=
In[]:=
NimMoves[{3,3,3}]
Out[]=
{{0,3,3},{1,3,3},{2,3,3},{3,0,3},{3,1,3},{3,2,3},{3,3,0},{3,3,1},{3,3,2}}
In[]:=
NimMultiwaySystem[init_List,t_,args___]:=ResourceFunction["MultiwaySystem"][<|"StateEvolutionFunction"NimMoves,"StateEquivalenceFunction"SameQ,"StateEventFunction"Identity,"EventDecompositionFunction"Identity,"EventApplicationFunction"Identity,"SystemType""None","EventSelectionFunction"Identity|>,init,t,args,"StateRenderingFunction"(Inset[Style[Row[#2],Black],#1,BackgroundLighter[Blue,.9]]&)]
In[]:=
NimMultiwaySystem[maxdelta_Integer->init_List,t_,args___]:=ResourceFunction["MultiwaySystem"][<|"StateEvolutionFunction"(NimMoves[#,maxdelta]&),"StateEquivalenceFunction"SameQ,"StateEventFunction"Identity,"EventDecompositionFunction"Identity,"EventApplicationFunction"Identity,"SystemType""None","EventSelectionFunction"Identity|>,init,t,args,"StateRenderingFunction"(Inset[Style[Row[#2],Black],#1,BackgroundLighter[Blue,.9]]&)]
In[]:=
NimMultiwaySystem[{{1,1}},5,"StatesGraph"]
Out[]=
In[]:=
NimMultiwaySystem[{{2,2}},5,"StatesGraph"]
Out[]=
In[]:=
NimMultiwaySystem[{{3,3}},5,"StatesGraph"]
Out[]=
In[]:=
NimMultiwaySystem[{{3,3,3}},10,"StatesGraph"]
Out[]=
Single Pile Nim
Single Pile Nim
Sliding Block Puzzle
Sliding Block Puzzle
The 3×2 case
The 3×2 case
2×2
2×2
3×3
3×3