NAME
Game::Reversi::Opening - the four discs the players place themselves
VERSION
Version 0.01
SYNOPSIS
my $board = Game::Reversi::Opening->board_for('historic'); # empty
while (Game::Reversi::Opening->in_opening($board)) {
my @places = Game::Reversi::Opening->legal($board, $colour);
$board = Game::Reversi::Opening->apply($board, $square, $colour);
$colour = Game::Reversi::Board->other($colour);
}
DESCRIPTION
Reversi starts with an empty board. The players place the first four discs themselves, alternately, on the four centre squares, capturing nothing. Othello starts with those four discs already down. That is the whole difference between the two games, and it is why this distribution can be called Reversi.
Wikipedia:
The historical version of reversi starts with an empty board, and the first two moves made by each player are in the four central squares of the board. The players place their disks alternately with their colors facing up and no captures are made. A player may choose to not play both pieces on the same diagonal, different from the standard Othello opening.
Twenty four sequences, six positions, two games
Every order of the four squares is legal, so there are 4! = 24 placement sequences. A position is fixed by which pair Black ends up with, and each pair is reachable four ways, so there are six distinct positions. Up to rotation and reflection there are two: the diagonal opening, of which the Othello position is one case, and the parallel opening.
Opening theory covers exactly one of those six. The parallel openings break the symmetry from the first move and have never had a book written about them.
The opening restriction does real work
After only two placements the board can already hold a legal capture by the ordinary rules. Black on d5 and White on e5 means a disc at f5 would outflank e5 and turn it.
The rule says no captures are made during the opening, so that play must be refused even though Game::Reversi::Board would call it legal. An implementation that asked the board for its legal moves during the opening would offer it, and would be wrong in a way that still looks like a working game.
Variants
historic is the default and is the game above. othello is the 1971 fixed start, dark on e4 and d5. It exists for two reasons, and neither is demand: it is one of the six positions the historic opening reaches anyway, and it is the position every published transcript and every published move count starts from, so it is the only external oracle this distribution has.
METHODS
centre
The four centre squares.
is_centre
Whether a square is one of them.
variants, describes
The variant names, and a sentence about one.
board_for
The starting board for a variant. Dies on a name it does not know.
first
The colour that moves first, which is always Black.
in_opening
Whether discs are still being placed. Since the centre fills up and never empties, this is the same question as whether a centre square is free, and it answers itself correctly for the othello variant.
plies_left
How many placements remain.
legal
The placements open to a colour, as Game::Reversi::Move objects with a phase of place. The empty centre squares and nothing else.
check
The Game::Reversi::Error a placement would be refused with, or undef.
apply
A new board with the disc placed and nothing turned. Dies on a placement that "check" would refuse, because by then it is programmer error.
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.