Check out Grant Acedrex, our featured variant for April, 2024.


[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Single Comment

Interactive diagrams. Diagrams that interactively show piece moves.[All Comments] [Add Comment or Rating]
A. M. DeWitt wrote on Mon, Dec 14, 2020 07:34 PM UTC in reply to H. G. Muller from Sat Dec 12 03:21 PM:

Your program for pasting games works pretty well. To be honest, I didn't expect you to pull that off, though you probably aren't one to give up easily.

The problem with SAN is that it is very vague. It only shows you the piece ID, where that piece moved to, if it captured, a letter and/or number for disambiguation, and promotion choices, if any (and possibly if en passant capture was used). Basically, it shows you the minimum amount of information that required. However, this also makes parsing the moves very complicated (but not impossible). Game Courier has to deal with this same problem at an even larger scale, as some presets use different coordinate systems compared to SAN (i.e. Shogi and its variants). This is why Game Courier uses the notation it does. The notation my functions use an even simpler notation, with each move being a list of coordinates (and sometimes piece IDs) separated by hyphens, a character unlikely to be used in an actual piece ID. This allows the moves to be parsed quite easily using the following process:

  • Split move string into components and pass to an array, with a space as the delimiter.
  • For each move in the array, split into its components and pass to another array, with a hyphen as the delimiter.
    • Process the move based on the length of the array. Unless stated otherwise, all elements must be coordinates. Piece IDs are uppercase for White and lowercase for Black, and setting the shogiMode flag reverses this.
      • If length 2, single move or drop. First element may be a piece ID or a coordinate.
      • If length 3, single move with promotion or double move. Last element may be a piece ID or a coordinate.
      • If length 4 or more, multiple move with or without promotion. Last element may be a piece ID or a coordinate.
    • If an error occurs, exit loop without moving anything for this move and print an error message (moves successfully parsed before the error are still executed). Otherwise, make the move accordingly

As for FEN code, I am not sure how else to print the current position to and load positions from strings. It seemed like the best system to use for this when I made the functions, since none of my games involved random shuffling of the initial position.