| 6.170 | Laboratory in Software Engineering
Fall 2003 Final Project: Antichess: TextUI spec Due: See Schedule |
Main must be executed with zero command-line arguments, like this:
java antichess.TextUI
The behavior of the TextUI is unspecified when main is run with one or more command-line arguments.
Init [ruleSet] [initTimeSeconds]
This must be the first command to the TextUI. The parameters are:
Must init first on its own line and exits. If Init is called
twice, the system outputs Cannot init twice, and
does nothing.
Setup [setup-command] :
If this command is called before any call to
StartNewGame or LoadGame, it has the
same effect as [setup-command] would in the "setup" section of a
Save Game file.
If the [setup-command] is not a valid setup command, the system
outputs Invalid setup command on its own line and
does nothing. If
Setup is called after StartNewGame or LoadGame, the system
outputs Cannot setup after game starts on its own
line and does nothing.
StartNewGame [player] [player]:
Each player is denoted as "human" or "computer." The
first player is white and the second player is black. For example,
StartNewGame computer human should start a new game
with the computer playing as white and the human playing as
black.
The system should output New game
started on its own line.
SaveGame [filename]: The system should
save the game to the given filename and report Game
saved on its own line.
LoadGame [filename]: The system should
load the game from the given filename. Once the files is
loaded, print Game loaded on its own line. You
should report Corrupt file if the file does not
have a correct format. We will not require you to determine if
the board is legal. If no game is currently in progress from
a previously executed StartNewGame or LoadGame command,
then assume a human-human game. If a game is currently in progress,
then the players currently playing use the same colors in the new game.
MakeNextMove: If it is a computer
player's turn, the system performs the move that
it believes to be the best. The system prints this move on
its own line, in the format described by the move-desc grammar. If it is a human
player's turn, the system should print Please specify human
move on its own line.
MakeMove [move]: Perform the move specified by
the String move, in the format described by the
move-desc grammar. This command should only be used by
a Human Player. If it is used during a computer player's turn,
nothing will happen to the game state. Do not give feedback. If
the move is not legal, the system should print, on its own line,
Illegal move and not perform the move. If the move is
legal, the system should perform the move and print the move back,
in proper format, on its own line.
PrintBoard: System should print the
current "state" of the game to the screen using the same format
as if it were being saved to a file. Include a newline at the
end of the output also.
IsLegalMove [move]: System should print,
on its own line, either "legal" or "illegal" to specify if the
move is a legal next move.
PrintAllMoves: System should, in
alphanumeric order, print all legal moves for the next player.
Each move should each appear on its own line.
QuitGame: Prints (on its own line)
Exiting game and terminates the present game and
application. QuitGame cannot be the first command.
For each command except MakeNextMove, the specified behavior completes within 10 seconds.
If the user input does not match one of these commands, output
Input error alone on one line.
When a player has won the game, output on its own line:
[Player color] Player has won. For example, if the
black player has won, output: Black Player has won.
At this point, you can assume that the Antichess program has just
been started and therefore, you only need to support a subset of
commands.
In the TextUI, time must be kept against the human and computer players, just as it is in the GUI.
If the clock runs out on a human player, the player can be informed that they have lost after the next TextUI command is entered--it is not necessary to interrupt the player. If the clock runs out on a computer player, the system must immediately report that the other player has won.
All commands except MakeNextMove must complete within 10 seconds. MakeNextMove can take as long as the computer player wishes, subject to the constraints of the game clock.