A Networked Lines Of Action Referee: Specification

Bart Massey

November 23, 2000

Lines Of Action (LOA) is a fairly obscure but fascinating game of skill. It is played on an ordinary checkerboard, and has something of the feel of Othello or Go. In this document, we will describe a networked server to which human and computer LOA players can connect to play the game in a refereed fashion.

1 The Game Of Lines Of Action

The rules of LOA are complicated and have many variants. This discussion is based partly on Dyer’s account on his excellent LOA webpage [1], and partly on the Fifth Computer Olympiad (2000) [2] rules [3], the latter being normative in the case of conflicts.

LOA is a two player game, played by players conventionally designated as white and black.

PLAYER ::= black | white

opponent : PLAYER \underrightarrow{↣} PLAYER

opponent white = black opponent black = white

The board, shown in figure 1, is an ordinary checkerboard (whose squares are conventionally designated using standard algebraic notation).

DIGIT == 1 . . 8 SQUARE == DIGIT × DIGIT

At any given point in the game, the board position can be given by noting whether each square is blank or contains a colored checker.

SQUAREVAL ::= checker⟨⟨PLAYER⟩⟩ | blank BOARD == SQUARE → SQUAREVAL

LOAPosition board : BOARD to move : PLAYER

As shown in Figure 1, each player starts with 12 checkers, placed on the six central edge squares of opposing sides of the board.

CDIGIT == 2 . . 7

a  c d e f g h b 1 4 5 6 7 8 2 3

Figure 1: LOA Board In Initial Configuration

InitLOAPosition LOAPosition′

board′ = (SQUARE × {blank})⊕ ((({1} × CDIGIT ) × {checker white})∪ (({8} × CDIGIT ) × {checker white})∪ ((CDIGIT × {1}) × {checker black})∪ ((CDIGIT × {8}) × {checker black}))

to move′ = black

The players alternate in moving one of their own checkers a certain distance along its row, column, or diagonal axis (“line of action”).

DIST == −8 . . 8 UNIT == −1 . . 1 UVEC == (UNIT × UNIT ) \ {(0, 0)} AXIS == SQUARE → DIST \underrightarrow{}SQUARE

line : UVEC → AXIS lines : ℙ AXIS

∀ ux, uy : UNIT | (ux, uy) ∈ UVEC •

∀ x, y : DIGIT ; •

∀ d : DIST | (x + d ∗ ux, y + d ∗ uy) ∈ SQUARE •

line (ux, uy) (x, y) d = (x + d, y)

lines = line(|UVEC |)

A move is illegal unless the number of pieces (including the moving piece) lying along the move axis is equal to the distance moved by the piece. It is also illegal if there is an intervening piece of the other color in a square between the source and destination of the move, or the destination square contains a piece of the same color. (If the destination square contains a piece of opposite color it is captured and removed from the game.)

MOVE == SQUARE × SQUARE

LOAAction LOAPosition naxis : AXIS → SQUARE → DIST target : AXIS → MOVE moves : ℙ MOVE make move : MOVE → BOARD

∀ f : AXIS •

naxis f = (λ x : SQUARE •

#(dom(board − ▷ {blank}) ∩ ((f x)(|DIST |))))

∀ f : AXIS; x : SQUARE; d : DIST | d = naxis f x ∧ board x = checker to move ∧ board (f x d) ≠ checker to move ∧ checker (opponent to move) ∉ board(|(f x)(|1 . . (d − 1)|)|) • target f = (x, f x d)

moves = target(|lines|) ∀ s, d : SQUARE •

make move (s, d) = board ⊕ {s ↦ blank} ⊕ {d ↦ checker(to move)}

The goal of the game is to make a move that connects all of one’s pieces. A player’s pieces are connected if there is a path from any piece to any other piece via adjacent horizontal, vertical, or diagonal squares.

adjacent : SQUARE ↔ SQUARE connections : ℙ ℙ SQUARE connected : PLAYER ↔ BOARD

adjacent = { x1, y1, x2, y2 : DIGIT | abs(x2 − x1) ≤ 1 ∧ abs(y2 − y1) ≤ 1 •

(x1, y1) ↦ (x2, y2) }

connections = { p : ℙ SQUARE |

∀ p′ : ℙ p \ {∅} \ {p} • (p′ ◁ adjacent ▷ (p \ p′)) ≠ ∅ } ∀ p : PLAYER; b : BOARD •

(p, b) ∈ connected ⇔ dom(b ▷ {checker(p)}) ∈ connections

The Computer Olympiad rules list a number of conditions which can terminate the game. Most of these have other variants which are commonly played, but which will not be considered here. Specifically, the Computer Olympiad rules state that:

1. The game ends when one player (or both) is connected, and

(a) If just one player is connected, that player is the winner.

(b) If both players are connected, the player who moved last wins.

Rules 1a and 1b can be understood together in this context as “The winner is the first player to be connected at either the start or end of their turn.”

2. Repeated positions with the same player to move are drawn. While the language is somewhat ambiguous, it is assumed that this means any repetition, not just immediate repetition.

3. If a player has no move, that player loses. It is also noted that this exception was added after the fact, which suggests an advantage of formal characterization and analysis of tournament game rules.

There are a number of possible outcomes of a player’s turn.

RESULT ::= win⟨⟨PLAYER⟩⟩ | draw | not done | illegal move

Because of rule 2, it is necessary to keep track of all the positions seen in the game. A move in the game consists of altering the board and recording the resulting board position.

LOAHistory positions : ℙ LOAPosition

LOARecordHistory LOAPosition ΔLOAHistory

positions′ = positions ∪ {θLOAPosition}

Conditions are checked for the player on move at the start of the turn.

1. If the player is connected, they win.

2. If the current position is a repeat of a previously seen position, they draw.

3. If there is no move available, they lose.

(Note that condition 2 is mutually exclusive with conditions 1 and 3, and the wording of the Computer Olympiad rules implies that condition 1 is supposed to take precedence over condition 3. So all of the special cases are disjoint.)

LOAPrecheck LOAAction LOAHistory precheck : RESULT

precheck = if (to move, board) ∈ connected then win(to move) else if θLOAPosition ∈ positions then draw else if moves = ∅ then win(opponent to move) else not done

Otherwise, some normal move must be made. In this case, the result of making the move is a win when the position is now connected for the player to move. Otherwise, the game continues.

LOATurn LOAPrecheck ΔLOAPosition LOARecordHistory move? : MOVE result! : RESULT

to move′ = opponent to move precheck ≠ not done ⇒

result! = precheck precheck = not done ∧ move? ∈ moves ⇒

board′ = make move move? ∧ result! =

if (to move, board′) ∈ connected then win(to move) else not done

precheck = not done ∧ move? ∉ moves ⇒ result! = illegal move

InitLOATurn InitLOAPosition LOAHistory′

positions′ = { θLOAPosition′ }

Table 1: Greeting

name  response  meaning ; greeting 000 LOA ⟨version-number⟩ Greeting message

Table 2: Initial Requests

name request meaning
want white ⟨version⟩ player white ⟨optional-name⟩ Will play white
want black ⟨version⟩ player black ⟨optional-name⟩ Will play black
want side ⟨version⟩ player ? ⟨optional-name⟩  Will play either
want observe ⟨version⟩ observer ⟨optional-name⟩  Will observe

2 Server

The Lines Of Action server listens on a port in the range 29057 … 29067 for a connection.^{1} All input to the server will be in the form of ASCII text lines, terminated with a CR character (ASCII code 13). All server responses will be in the form of ASCII text lines, terminated with a CR and then an LF character (ASCII code 10). Responses will begin with a 3-digit numerical code, and be followed by whitespace and a (non-standard) explanatory text message. Requests and responses not currently implemented by the server will have their identifier in italics: those implemented will have boldface identifiers.

Any number of observers may connect to the server, as well as the two players. The server will always be in a state determined by the input it has seen. This state will determine which messages it will accept, and which responses it will return. The server may be in different states for different connections: it must synchronize the connections at key points.

STATE ::= initial | seated | playing | done

ENTITY ::= player⟨⟨PLAYER⟩⟩ | observer⟨⟨ℕ_{1}⟩⟩

observer ∈ seq ENTITY

cstate : ENTITY \underrightarrow{}STATE

Upon connection to the server, an entity will receive a greeting in the form indicated by Table 1. The version number is a pair of integers separated by a decimal point. This document describes version 0.9.

The initial message sent to the server must be as shown in Table 2. Responses are shown in Table 3. The ⟨optional-name⟩ is an optional double-quoted string (with the convention that two consecutive double-quotes ”” inside the string escape to a single double-quote ”) of up to 31 characters used to identify the entity. The version number is as above, and is used to identify the client version. The client version must be no greater (under the usual ordering) than the server version. If both players indicate “player ?”, the server will randomly select a white and black player.

Once both a white player and a black player have connected, the setup phase will be over. The server may indicate to each entity the other entities involved, by sending messages as shown in Table 4. ⟨name⟩ and ⟨optional-name⟩ are double-quoted strings as described below. ⟨number⟩ is a decimal number. (All entities should be prepared to deal with numbers up to 3 decimal digits, and to discard an arbitrary number).

The server will then signal the start of game by sending a message to each connected entity, as shown in Table 5.

After this, the server will accept moves from players in alternation, of the form shown in Table 6, where the ⟨move number⟩ is a standard decimal number indicating the ply of the move, the ⟨ellipses-if-white⟩ will

1All numbers in this section will be base 10 (decimal) unless otherwise stated.

Table 3: Initial Responses

name response meaning
seat granted 100  Request accepted
seat granted tc 101 ⟨secs⟩ ⟨opp-secs⟩ Request accepted with time controls
19x  Request not accepted
seat taken 191  Other player holds requested side
seat full 192  There are already two players
seat private 193  Cannot observe
seat illegal 198  Illegal version number
seat garbled 199  Request not understood

Table 4: Configuration Messages

name response meaning
config white 341 ⟨name⟩  White player is ⟨name⟩
config black 342 ⟨name⟩  Black player is ⟨name⟩
config observer 343 ⟨number⟩ ⟨name⟩ Observer ⟨number⟩ is ⟨name⟩
config nobserver 344 ⟨number⟩  There are ⟨number⟩ observers

be the string ... for a move by white and the empty string for a move by black, and ⟨move⟩ will be a move in the notation described above.

Instead of a move, the following inputs may also be accepted as shown in Table 7. Responses to actions are shown in Table 8.

After each accepted action, a message will be sent to each connected entity, as shown in Table 9. Upon termination of the game, the server will close all connections.

If the participant is an observer, every status message will be followed by two state display messages showing the current state of the game, as in Table 10. The times will be in seconds, and the ⟨to-move⟩ value will be either “b”, “w”, or “.” indicating Black, White, or the game is over. The sdisp board message will be immediately followed by 8 lines of 8 printable characters indicating the board state. Each character will be as above: “b”, “w”, or “.” indicating a blank square.

The draw protocol is as one would expect: a draw may be offered by a player whose turn it is to move. If it is rejected by the other player, it may not be offered again until the next move.

References

[1] Dave Dyer. Lines Of Action Home Page. Web document, 2000. URL http://www.andromeda.com/

   people/ddyer/loa/loa.html.

[2] Fifth Computer Olympiad. Web document, 2000. URL http://www.dcs.qmw.ac.uk/~olympiad/.

[3] Lines Of Action Rules. Web document, 2000. URL http://www.dcs.qmw.ac.uk/~olympiad/LOA.htm. See [2].

Table 5: Starting Messages

name response meaning
role white 351  You will play white
role black 352  You will play black
role observer 353  You will observe

Table 6: Move Syntax

name  request  meaning ; action move ⟨move number⟩ ⟨ellipses-if-white⟩ ⟨move⟩ Make a move

Table 7: Alternatives To Moving

name request meaning
action resign resign  Player resigns
action draw req draw?  Player offers a draw
action draw ack draw  Player accepts a draw
action draw nak nodraw Player refuses a draw

Table 8: Responses To Actions

name response meaning
20x  Action accepted
result continue 200  Continue playing
result continue 207 ⟨secs⟩ Continue with time left
result win 201  You win
result lost 202  You lose
result drawn 203  You draw
result resigned 204  Resignation accepted
result drawreq 205  Received draw request
result drawnak 206  Received draw refusal
29x  Action not accepted
result illegal 291  Illegal request
result garbled 299  Request not understood

Table 9: Status Messages

name response meaning
31x  Game continues
status moves black 311 ⟨move-number⟩ ⟨move⟩  Black move
status moves white 312 ⟨move-number⟩ ... ⟨move⟩  White move
status moves black tc 313 ⟨move-number⟩ ⟨move⟩ ⟨secs⟩  Black move and time
status moves white tc 314 ⟨move-number⟩ ... ⟨move⟩ ⟨secs⟩ White move and time
32x, 36x  Game over
status winsmove black 321 ⟨move-number⟩ ⟨move⟩  Black wins by move
status losesmove black 322 ⟨move-number⟩ ⟨move⟩  Black loses by move
status winsmove white 323 ⟨move-number⟩ ... ⟨move⟩  White wins by move
status losesmove white 324 ⟨move-number⟩ ... ⟨move⟩  White loses by move
status drawsmove black 325 ⟨move-number⟩ ⟨move⟩  Drawn by Black move
status drawsmove white 326 ⟨move-number⟩ ... ⟨move⟩  Drawn by White move
status resigns white 327  Black wins by resignation
status resigns black 328  White wins by resignation
status draw agreed 329  Draw accepted
status flagfell white 361  Black wins by White time expiring
status flagfell black 362  White wins by Black time expiring
33x  Draw protocol
status reqsdraw black 331  Draw requested by Black
status reqsdraw white 332  Draw requested by White
status refsdraw black 333  Draw refused by Black
status refsdraw white 334  Draw refused by White
34x  (see above)
35x  (see above)
39x  Bad status
status disconnect black 391  Black disconnected
status disconnect white 392  White disconnected
status garble 399  Unknown problem

Table 10: State Display Messages

name response meaning
38x  state display
sdisp status 380 ⟨move-number⟩ ⟨to-move⟩  state
sdisp status tc 381 ⟨move-number⟩ ⟨time-b⟩ ⟨time-w⟩ ⟨to-move⟩ state and time
sdisp board 382  board