Message Boards Message Boards

[WSS22] Multiway graphs for minimal chess endgames

Posted 1 year ago

Wolfram Notebook

POSTED BY: Pavel Arkhipov
2 Replies
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?

Show Piece Graph

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]

Show Graph

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

POSTED BY: Dean Gladish

enter image description here -- you have earned Featured Contributor Badge enter image description here 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!

POSTED BY: Moderation Team
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract