From: Eric Cheymol FREE FR> Date: 29 sep 2002 Subject: Re: Is there a PGN Equivalent for Shogi?? Le dimanche, 29 sep 2002, à 22:18 Europe/Paris, Joseph Peterson a écrit : > Well, there is a "PSN" that was used by ShogiBoard. It's almost > exactly > like PGN... but there was no specification made as far as I'm aware. A PSN specs page already existed. I have just looked for it on the web but I didn't succeed. Anyway, I captured the following page in november 1998, and I found mails in shogi-l talking about PSN notation in 1997. Here is a copy/paste of this page : ---------------------------------- Portable Shogi Notation PSN is a format for writing shogi gamescores using ASCII. The notation described here is the (a restricted) version used by the java shogi board (by Patrick Davin). 1. File layout A PSN file may contain more than one game. A game is divided in two section; first a header of meta information, then the game score. If parsing a game, and a header line is encountered this is taken to be the intro of a new game. 1.1 Header Section The header section contains meta information about the game and is composed of a set of lines in the format as follow: HEADER = '[' KEYWORD SPC some-text ']' KEYWORD = 'Sente'|'Gote'|'Date'|'Event'|'Time'|'Result'| 'Handicap'|'FEN'|some-text SPC = ' ' Or in plain english, start the line with [ followed by a keyword (meta-information identifier), the information in quotes and closed by a ]. Example: [Sente "The Champion"], [Result "1-0"] 1.1.1 Special headers Though the header section is mostly used for meta information, two special headers exists that has a direct influence on the game; Handicap and FEN. Handicap The Handicap header is used to specify that white/gote is playing with some handicap. According to the handicap specified, some of gotes pieces is removed. Note that it is gote that will start the game, so the first move sequence number is: 1.... The legal values for handicap is; «8 piece», «7 piece» ... «2 piece», «rook and lance», «rook», «bishop», «right lance» and «lance». FEN The fen header is a compressed notation for describing a specific game situation. It is a string of 13 arguments, where the arguments are seperated with «/» (slash) or « » (space). The first 9 arguments describe the board, read left-to-right top-to-bottom (western style). Followed by black hand, white hand, player-to-move and next move sequence number. Each of the first 9 arguments describe one row (rank) on the board with one token per cell. Legal tokens are; single digit, lower and upper case of the characters [plnsgbrk] and the pluss (+) sign. A digit -- n -- signifies that n consectutive cells are empty, starting with current. The characters defines a piece at current location. Lower case character indicate white/gote, and upper case for black/sente. If the character is preceeded with the + sign, then the piece is promoted. The black hand is a string of 7 digits, reflecting the number of pieces in hand in the following order; P L N S G B R. Note that it is a single digit per piece, and therefor max 9 pieces of one type in hand (relevant for pawns). The white hand are represented just as for black, but with an extra shortcut notation. Using the single character «t» (tee), the rest of the pieces not used on the board or in blacks hand are placed on whites hand. The 12th argument is the single letter «g» or «s» defining whether it is Sente or Gote to move next. The last argument is the pair number of the next move. E.g if sente moved last at pair 12, the next pair number is also 12 but the 12th argument will be «g». Example: [FEN "5B2g/5s1kl/5g3/9/8P/6N2/9/9/7+r1 0012001/T s 1"] will result in the following board (a 19 move tsume problem by "Ito Sokan" -- 1723. Gif image Game: 1 MoveSeq: 0 HalfMove: 1 9 8 7 6 5 4 3 2 1 ---------------------------------------- | bb wg | a | ws wk wl | b | wg | c | | d | bp | e | bn | f | | g | | h | wr+ | i ---------------------------------------- P L N S G B R K Black Hand: 0 0 1 2 0 0 1 0 White Hand: 17 3 2 1 2 1 0 0 1.2 The Game score GAMESCORE = SEQNUM | COMMENT | MOVE The game score section is composed of three different tokens; moves, move sequence number and comments. 1.2.1 Move sequence number SEQNUM = DIGIT* '.'|'...' DIGIT = 0..9 The moves in PSN are numbered in pairs (as for chess). A sequence number indicates the pair number of the followin move. For normal pair numbering a single . (dot) follows the number, but when refering to the second half move of the pari three dots (...) shall be used. Example: 2., 3... 1.2.2 Comments COMMENT = '{' text '}' Comments are text enclosed in a pair of curly-braces. The text inside the braces are not parsed. The comment usually refer to the last move made (preceding move). Example: {Dette er en kommentar}, {dette og} 1.2.3 Move MOVE = NORMALMOVE | DROP NORMALMOVE = ['+'] PIECE [FROMCELL] DESTINATION [PROMOTION] DROP = PIECE '*'|''' DESTINATION PIECE = 'P'|'L'|'N'|'S'|'G'|'B'|'R'|'K' DESTINATION = COLUMN ROW FROMCELL = COLUMN ROW COLUMN = 1..9 ROW = a..i PROMOTION = '+'|'=' There are two flavors of moves; drops and board-movement. A drop is siply the piece id followed by an asterix (*) and then the destination cell. For a normal move there is no characters seperating the piece and the destination cell, except if the origination cell (FROMCELL) are specified. The FROMCELL is optional (as for leading promoted sign and the ending promoting qualifier) except when there is a ambituity. If a promoted piece is moved, the piece ID shall be prefixed with the pluss sign (+). And if a piece is moved into/inside/out-of the promotion zone a + can be (and must if it promotes) appended to the move token to signify that the piece is promoted after the move. To signify no promotion, the equal sign (=) can be used. Example: P7f { Normal move} P*4e { A drop} G4a5b { A move where origination/from-cell is specified} +P3b { A promoted pawn moves } P7g+ { A pawn moves then promotes} N7g= { A night moves into promotion zone, but do not promote } 1.2.4 End of game score A game score can explicitly be ended by writing the result string. A result string is the points gained by the players seperated by interval/minus sign (-). Example: 1-0, 0-1, 1⁄2-1⁄2