Check out Symmetric Chess, our featured variant for March, 2024.

Enter Your Reply

The Comment You're Replying To
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.


Edit Form

Comment on the page Interactive diagrams

Quick Markdown Guide

By default, new comments may be entered as Markdown, simple markup syntax designed to be readable and not look like markup. Comments stored as Markdown will be converted to HTML by Parsedown before displaying them. This follows the Github Flavored Markdown Spec with support for Markdown Extra. For a good overview of Markdown in general, check out the Markdown Guide. Here is a quick comparison of some commonly used Markdown with the rendered result:

Top level header: <H1>

Block quote

Second paragraph in block quote

First Paragraph of response. Italics, bold, and bold italics.

Second Paragraph after blank line. Here is some HTML code mixed in with the Markdown, and here is the same <U>HTML code</U> enclosed by backticks.

Secondary Header: <H2>

  • Unordered list item
  • Second unordered list item
  • New unordered list
    • Nested list item

Third Level header <H3>

  1. An ordered list item.
  2. A second ordered list item with the same number.
  3. A third ordered list item.
Here is some preformatted text.
  This line begins with some indentation.
    This begins with even more indentation.
And this line has no indentation.

Alt text for a graphic image

A definition list
A list of terms, each with one or more definitions following it.
An HTML construct using the tags <DL>, <DT> and <DD>.
A term
Its definition after a colon.
A second definition.
A third definition.
Another term following a blank line
The definition of that term.