BG light TCL interface

Provide a Tcl interface for the Match object, to be used in a Tk interface.

Provides the bglight command, which creates a match command via create or load.

bglight command

bglight create bg-command match-length ?opponent-name?
Creates a new Match(match-length) object and associates it with a new Tcl command whose name is bg-command.

bglight load bg-command channelId
Loads a saved match from channelId and associates the new command bg-command with it (just like create above).

bglight set automove val
Set automoves to val (1/0).

bglight set seed value
Set random number generator seed to value.

bglight set level value
Set play level to value (beginner/intermediate/expert).

match command

Computer side is O, opponent is X.

All options may be shortened as long as they remain unambiguous. `bg a' is fine as a shorthand for `bg action', but `bg s' is not. (however `bg sa' and `bg st' will work).

bg action
Return the next event as a list. List has the form {type side ?info?}, where type is one of (rolls,moves,doubles,takes,drops,rejects,resigns,wins,Crawford), side is either `X' or `O' and param depends on type.
type info
rolls [list dice0 dice1]
moves [list ?from-1 to-1? ... ?from-4 to-4?]
doubles value of cube if double is taken.
resigns 1/2/3 for resigns normal, gammon or backgammon.
wins number of points won
bg opplays move
Report opponent move, which is a list of 0 to 8 from-to elements.

bg oprolls
bg opdoubles
bg optakes
bg oprejects
bg opanswers 1/0
Report opponent action

bg state ?-extended?
Return match status, a list {match-length score-X score-O cube cube-owner-side Crawford}. If -extended, board and opponent-turn are appended as well.

bg save channelId
Save match to channelId.