Optimised Algebraic Notation

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
leanchess
Posts: 176
Joined: Sun Dec 08, 2019 8:16 pm
Full name: Dmitry Shechtman

Optimised Algebraic Notation

Post by leanchess »

In light of some recent discussions on this forum I came up with the idea of a move notation that would be both reasonably readable by humans and optimised for processing speed.

The notation is case-sensitive; only ASCII characters are used.

A move record MUST consist of the following seven characters:
  1. Moved piece ('P', 'R', 'N', 'B', 'Q' or 'K').
  2. Source file ('a'-'h').
  3. Source rank ('1'-'8').
  4. Captured piece ('-', 'P', 'R', 'N', 'B' or 'Q').
  5. Destination file ('a'-'h').
  6. Destination rank ('1'-'8').
  7. Promoted piece ('-', 'R', 'N', 'B' or 'Q'), or '.' for e.p. capture, or source rook file ('a'-'h') for castling.
This should cover chess and chess960, and should be fairly easy to extend to support other variants (like shogi).

I'd love to hear your feedback (in a polite and respectful manner, please).
R. Tomasi
Posts: 307
Joined: Wed Sep 01, 2021 4:08 pm
Location: Germany
Full name: Roland Tomasi

Re: Optimised Algebraic Notation

Post by R. Tomasi »

I just spent a couple of days implementing a PGN parser, which of course includes parsing moves in SAN notation. Personally, I really do think that SAN is a royal pain, such that in principle I would be in favour of such a notation. The problem that I do see is that SAN is widespread. Using this new notation would break compatibility with old programs. When parsing files, one would always have to be prepared to accept SAN to not break compatibility. That basically voids all positive aspects of any new standard (since we would have to be able to read the old one, anyways).
abulmo2
Posts: 433
Joined: Fri Dec 16, 2016 11:04 am
Location: France
Full name: Richard Delorme

Re: Optimised Algebraic Notation

Post by abulmo2 »

To me the portable algebraic notation used in the UCI protocol is the optimised notation. It just contains the from & to squares and the occasional promoted piece. Nothing else is needed to store a move. Furthermore it is reasonably readable by a human.
Richard Delorme
User avatar
hgm
Posts: 27836
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Optimised Algebraic Notation

Post by hgm »

Why do you think SAN is popular under human chess players? Because they understand long algebraic better?
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Optimised Algebraic Notation

Post by dangi12012 »

abulmo2 wrote: Mon Nov 29, 2021 6:28 pm To me the portable algebraic notation used in the UCI protocol is the optimised notation. It just contains the from & to squares and the occasional promoted piece. Nothing else is needed to store a move. Furthermore it is reasonably readable by a human.
Where is that defined? I read the UCI documentation and i only ever saw "moves" mentionend. Never in which format they are. From stockfish output i can see that From/To is written fully and castling is from/to square for the king (from<->to difference of 2 squares so its clear)
Last edited by dangi12012 on Mon Nov 29, 2021 6:58 pm, edited 1 time in total.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Optimised Algebraic Notation

Post by dangi12012 »

leanchess wrote: Mon Nov 29, 2021 4:57 pm In light of some recent discussions on this forum I came up with the idea of a move notation that would be both reasonably readable by humans and optimised for processing speed.

The notation is case-sensitive; only ASCII characters are used.

A move record MUST consist of the following seven characters:
  1. Moved piece ('P', 'R', 'N', 'B', 'Q' or 'K').
  2. Source file ('a'-'h').
  3. Source rank ('1'-'8').
  4. Captured piece ('-', 'P', 'R', 'N', 'B' or 'Q').
  5. Destination file ('a'-'h').
  6. Destination rank ('1'-'8').
  7. Promoted piece ('-', 'R', 'N', 'B' or 'Q'), or '.' for e.p. capture, or source rook file ('a'-'h') for castling.
This should cover chess and chess960, and should be fairly easy to extend to support other variants (like shogi).

I'd love to hear your feedback (in a polite and respectful manner, please).
On 4/7 why would you not just omit the - if no piece was captured? to have 7 characters always?
On 7 I think e.p. capture is clear on itself. You move the pawn diagonally but the target square is empty.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Optimised Algebraic Notation

Post by dangi12012 »

leanchess wrote: Mon Nov 29, 2021 4:57 pm In light of some recent discussions on this forum I came up with the idea of a move notation that would be both reasonably readable by humans and optimised for processing speed.

The notation is case-sensitive; only ASCII characters are used.

A move record MUST consist of the following seven characters:
  1. Moved piece ('P', 'R', 'N', 'B', 'Q' or 'K').
  2. Source file ('a'-'h').
  3. Source rank ('1'-'8').
  4. Captured piece ('-', 'P', 'R', 'N', 'B' or 'Q').
  5. Destination file ('a'-'h').
  6. Destination rank ('1'-'8').
  7. Promoted piece ('-', 'R', 'N', 'B' or 'Q'), or '.' for e.p. capture, or source rook file ('a'-'h') for castling.
This should cover chess and chess960, and should be fairly easy to extend to support other variants (like shogi).

I'd love to hear your feedback (in a polite and respectful manner, please).
From an efficientcy standpoint I would omit captured piece as this is clear from the moves anyway. Also you dont have to write out which piece you moved.

A small ascii move would be from / to squares in base64 - with promotion encoded as a backwards/diagonal move of 1...5 squares to have that piece and one of the 3 promotion squares encoded.

First 3 moves:
IQ 4w QY

https://en.wikipedia.org/wiki/Base64
Readability is not given i guess. But its interesting anyways since a parser could just read the characters and know what to do with a mailslot array with 2 special cases for castling and EP.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
Sopel
Posts: 389
Joined: Tue Oct 08, 2019 11:39 pm
Full name: Tomasz Sobczyk

Re: Optimised Algebraic Notation

Post by Sopel »

what's wrong with uci notation?
dangi12012 wrote:No one wants to touch anything you have posted. That proves you now have negative reputations since everyone knows already you are a forum troll.

Maybe you copied your stockfish commits from someone else too?
I will look into that.
User avatar
leanchess
Posts: 176
Joined: Sun Dec 08, 2019 8:16 pm
Full name: Dmitry Shechtman

Re: Optimised Algebraic Notation

Post by leanchess »

Perhaps I didn't state my goals sufficiently clearly.

Firstly, the idea was to optimise for speed, not for space. Second, the notation should remain human-readable.

As part of the speed optimisation, it should be self-contained, i.e. translate to a data structure requiring nothing else for performing make/unmake. Does it make any sense?

I am hoping to include this in a proposal for a PGN alternative in the vein of the recently proposed JSON Game Notation. Unfortunately, the discussion in that thread deteriorated beyond all repair, so I'm inclined to create a new topic for that.
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Optimised Algebraic Notation

Post by dangi12012 »

leanchess wrote: Mon Nov 29, 2021 7:27 pm Perhaps I didn't state my goals sufficiently clearly.

Firstly, the idea was to optimise for speed, not for space. Second, the notation should remain human-readable.

As part of the speed optimisation, it should be self-contained, i.e. translate to a data structure requiring nothing else for performing make/unmake. Does it make any sense?

I am hoping to include this in a proposal for a PGN alternative in the vein of the recently proposed JSON Game Notation. Unfortunately, the discussion in that thread deteriorated beyond all repair, so I'm inclined to create a new topic for that.
But "moved piece" and "captured piece" seems redundant to me?
Since for unmake you only would need to remeber that but you wouldnt need to store it in the "OAN" file.
I think its clear to just write E2-E4
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer