NAME
Game::Shogi::Notation - shogi moves written as Hodges and Japanese notation, and games replayed
SYNOPSIS
use Game::Shogi::Notation;
my $N = 'Game::Shogi::Notation';
my $board = Game::Shogi::Engine->new;
print $N->hodges($board, '7g7f'), "\n"; # P-7f
print $N->japanese($board, '7g7f', marks => 1), "\n"; # ▲7六歩
my $log = $N->record(undef, qw(7g7f 3c3d 2g2f 4a3b));
print join(' ', map { $_->{japanese} } @{ $log->{moves} }), "\n";
my ($final, $result) = $N->replay($start_sfen, @usi);
DESCRIPTION
The ways a move is written down. USI is what a log stores (see Game::Shogi::Move); the forms here are worked out from the position the move was made in, because both say which piece moved only when another could have made the same move.
METHODS
hodges
Game::Shogi::Notation->hodges($board, $usi)
The move in the western notation Hodges set down: the piece, its origin only when another piece of the same kind could make the move, - for a move, x for a capture or * for a drop, the square, and + or = only when a promotion was possible. undef when the move is not legal on the board.
japanese
Game::Shogi::Notation->japanese($board, $usi, previous => '2d', marks => 1)
The move in Japanese notation: the square (同 when it is previous, the square the last move reached), the piece, then when another piece of the same kind could make the move, 上, 引 or 寄 if that tells them apart, else 直 for a gold-like piece moving straight forward, else 右 or 左 from the mover's side and, if needed, the movement among the pieces on that side. Then 成, or 不成 when a promotion was possible and not taken; and 打 for a drop only when a piece on the board could have reached the square. With marks, ▲ or △ first. undef when the move is not legal.
record
my $log = Game::Shogi::Notation->record($start_sfen, @usi);
A game written down: start, the start SFEN (the standard start for undef); moves, one hash reference a move with usi, side, hodges and japanese; sfen, the position at the end; and result, a Game::Shogi::Result or undef. Croaks, naming the move and the reason, at the first move that is not legal or comes after the game ended.
replay
my ($board, $result) = Game::Shogi::Notation->replay($start_sfen, @usi);
The board after the moves, and its result or undef. Croaks as "record" does.
AUTHOR
LNATION <email@lnation.org>
LICENSE AND COPYRIGHT
This software is Copyright (c) 2026 by LNATION <email@lnation.org>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)