[WSS22] Multiway graphs for minimal chess endgames

DOWNLOAD-DESKTOP-NOTEBOOK.nb (13 MB)

7 Likes

news-congrads-kkluyshnik-02-04-19.jpg – you have earned Featured Contributor Badge 2015-11-02_10-07-11.png
Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!

2 Likes

showPieceGraph[n_, pieceName_] :=
Module[{positions, edges, vertexStyle, vertexLabels, vertexShapes,
legend},
positions =
DeleteCases[generatePositions[n],
p_ /; p[[5]] != pieceName && p[[5]] != “none”];
edges =
DeleteCases[
generateEdges[positions, n], (_ → p_) /;
p[[5]] != pieceName && p[[5]] != “none”];
vertexStyle = generateVertexStyle[positions, n];
vertexLabels = generateLabels[positions, n];
vertexShapes =
Normal[KeySelect[
evaluationOfPositions[
n], #[[5]] == pieceName || #[[5]] == “none” &]];
vertexShapes =
vertexShapes /. {(a_ → “win”) → (a → “Square”), (a_ →
“draw”) → (a → “Circle”)};
legend = PointLegend[
{Black, Black, Red, Yellow,
Switch[pieceName, “pawn”, Gray, “knight”, Green, “bishop”,
Lighter[Pink], “rook”, Cyan, “queen”, Magenta], Black}, {“draw”,
“win for white”, “mate”, “stalemate”, pieceName,
“the piece was captured”}
];
Legended[
Graph[
edges,
EdgeShapeFunction → ({Arrowheads[{{.01, .1}}], Arrow[#1]} &),
VertexStyle → vertexStyle,
VertexLabels → vertexLabels,
GraphLayout → “SpectralEmbedding”,
ImageSize → 100*Sqrt@Length[positions],
VertexShapeFunction → vertexShapes],
legend]]

The flexible, layered structure..@Pavel Arkhipov thank you for doing this you really saved us.

pieces = {"pawn", "knight", "bishop", "rook", "queen"};
Table[showPieceGraph[3, pieces[[i]]], {i, Length[pieces]}]

How do the natural language processing rules apply here; like let’s say the rules might conflate a car, a piece, with a dog (a foliation position) because they have similar macro behavior?

generateGraph[n_] := Module[
  {positions, edges},
  positions = generatePositions[n];
  edges = generateEdges[positions, n];
  Graph[edges,
   EdgeShapeFunction -> ({Arrowheads[{{.01, .1}}], Arrow[#1]} &),
   VertexStyle -> generateVertexStyle[positions, n],
   VertexLabels -> generateLabels[positions, n],
   VertexShapeFunction -> "Star",
   GraphLayout -> "HighDimensionalEmbedding",
   ImageSize -> 600]]
showGraph[n_] := Legended[
  generateGraph[n],
  Placed[
   SwatchLegend[
    {Black, Black, Red, Yellow, Gray, Green, Lighter[Pink], Cyan, 
     Magenta, Black}, {"draw", "win for white", "mate", "stalemate", 
     "pawn", "knight", "bishop", "rook", "queen", 
     "the piece was captured"},
    LegendMarkers -> {{"\[Star]", 20}, {"\[Star]", 20}, {"\[Star]", 
       20}, {"\[Star]", 20}, {"\[Star]", 20}, {"\[Star]", 
       20}, {"\[Star]", 20}, {"\[Star]", 20}, {"\[Star]", 
       20}, {"\[Star]", 20}},
    LabelStyle -> {FontFamily -> "Academy Engraved LET", 
      FontSize -> 12, FontColor -> "Olive"},
    LegendLayout -> {"Column", 2}
    ],
   {Right, Top}
   ]
  ]

This project is so reasonable. No matter how you put it whether you’re doing some far-fetched graph like the pawn graph or the rook, these are the atomic interactions which make mathematics & physics, as we traditionally know them, possible.

showGraph[3]

Our quantum reward! This is why @Pavel Arkhipov we’ve got experimental mathematics.