The Game
type and related functions.
At the moment, a game is little more than a sequence of moves, and a current position. There is no support for annotation in the form of comments or variations. Support for tree-like games with recursive variations and comments are planned for a future version of this library.
Type representing a chess game.
empty : Game
A new game starting from the standard opening position.
fromPgn : String -> Maybe Game
Tries to create a Game
from a PGN string. Returns Nothing
if PGN
parsing fails, or if there are illegal or ambiguous moves.
toPgn : Game -> String
Converts a game to a string in PGN format.
position : Game -> Position
The current position in the game.
moves : Game -> List Move
List of all moves in the game.
previousMove : Game -> Maybe Move
The previous move in the game, i.e. the move that resulted in the
current game position. Returns Nothing
if we're at the beginning of the
game.
nextMove : Game -> Maybe Move
The next move in the game from the current position. Returns Nothing
if
we're at the end of the game.
goToMove : Basics.Int -> Game -> Game
Jump to the given game ply number. If the ply is less than 0, goes to the beginning of the game. If the ply is bigger than the length of the game, goes to the end of the game.
forward : Game -> Game
Step one move forward, unless we are already at the end of the game. If we are already at the end, do nothing.
back : Game -> Game
Step one move backward, unless we are already at the beginning of the game. If we are already at the beginning, do nothing.
toBeginning : Game -> Game
Go to the beginning of the game.
toEnd : Game -> Game
Go to the end of the game.
isAtBeginning : Game -> Basics.Bool
Are we at the beginning of the game?
isAtEnd : Game -> Basics.Bool
Are we at the beginning of the game?
addMove : Move -> Game -> Game
Add a move to the game at the current move index. Any previous game continuation will be overwritten.