NAME
Game::Senet::Terminal - Senet, played in a terminal
VERSION
Version 0.02
SYNOPSIS
use Game::Senet::Terminal;
exit Game::Senet::Terminal->run(@ARGV);
my $terminal = Game::Senet::Terminal->new(rules => 'skyruk', level => 2);
exit $terminal->start;
Or, from a shell, the senet program that comes with this distribution.
DESCRIPTION
The board drawn in a terminal as its S of thirty houses, the four sticks shown as they fell, and a game played against the program, between two people at one keyboard, or by the program against itself.
This is the one module in the distribution that reads a keyboard, writes to a screen, asks the time or draws on chance of its own (for a seed, when it is not given one). Everything else is a game that does none of those.
Choosing a move
The sticks say how far a piece goes, so a move is a choice of piece and nothing more.
In a terminal, with Term::ReadKey installed, the pieces that can move are walked with the arrow keys, and the board is redrawn for each as it would stand after that move: [ ] the house the piece leaves, < > where it lands, ( ) the house a swapped piece goes back to, and { } the last move each side made. A line under the board says the same in words. Enter makes the move. A move that is the only one the throw allows still waits for enter.
Once the game is over, enter, space or q leaves, n starts a new game and u takes the last turn back. A line left empty does the same as enter.
Anywhere else, and with picking off, the moves are listed with numbers and a line is read: a number, or a move such as 12-15 or 26-off.
What is never left out
A throw that allowed no move is shown with its sticks and stays on the screen: the last four things that happened are always under the board. A throw of 1, 4 or 5 that gives another throw says so.
Marks are shapes
Light and dark pieces differ in shape and not only in colour, the signs of the marked houses stay drawn under a piece, and each mark is its own pair of brackets. With colour off nothing is lost.
METHODS
run
my $status = Game::Senet::Terminal->run(@argv);
Reads the options, plays, and returns 0 when the game was won, drawn or left, 1 when the person playing the program lost, and 2 for an option it does not know or a value it cannot use. It never calls exit.
options
The fields a launcher may offer, in the form Game::Terminal::Kit::Options reads.
new
my $terminal = Game::Senet::Terminal->new(%options);
mode, rules, pieces, level, side, first, seed, pace, record, and game to carry one on; in, out, keysource and sleeper for driving it from a test; interactive, colour, unicode and picking to override what is found out. Every option is also a method that reads it.
start
Plays until the game is left, and returns as run does.
game
in
out
interactive
colour
unicode
picking
mode
side
level
rules
pieces
first
seed
pace
record
keysource
history
sleeper
The options, each read and set by its name.
board_lines
my $lines = $terminal->board_lines($move);
The board drawn as a list of lines, as it would stand after $move, or as it stands when no move is given.
screen
my $lines = $terminal->screen($mode);
Everything one frame shows, in the mode plain, pick, wait, ended or help.
show
Draws a frame.
candidates
The moves the throw allows, the game's legal.
steer
$terminal->steer($key);
Moves the cursor among the candidates: arrows by where each is drawn, tab and back-tab in the track's order, a digit straight to one.
place_of
my ($column, $row) = Game::Senet::Terminal->place_of($house);
Where a house is drawn.
pick
Reads keys until a move is chosen or something else asked, and returns it as the text command takes.
command
my $leave = $terminal->command($text);
Does what a typed line asks, a move or a word, and returns true to leave.
readout
my $text = $terminal->readout($move);
A move in its display form, and in words what it does.
sticks_text
The sticks drawn, a light face and a dark face each its own glyph.
roll_words
my $words = $terminal->roll_words($roll, $again, $bound);
What a roll is worth, said: a roll of 5 is spelled out as no light face.
events
Everything said under the board so far, oldest first.
help_lines
take_back
play_again
swap
person_turn
save
$terminal->save($file);
Writes the game's record to a file.
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)