ChessDefs.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Russ Atkinson (RRA) November 8, 1985 2:32:46 pm PST
ChessDefs: CEDAR DEFINITIONS = {
Piece: TYPE = {
p0, p1, p2, p3, p4, p5, p6, p7,
br, wn, bb, q, k, wb, bn, wr
};
Pawn: TYPE = Piece[p0..p7];
NonPawn: TYPE = Piece[br..wr];
PieceColor: TYPE = {white, black, none};
WhiteBlack: TYPE = PieceColor[white..black];
ColoredPiece: TYPE = RECORD [color: PieceColor, piece: Piece];
noPiece: ColoredPiece = [none, p0];
Board: TYPE = ARRAY BoardIndex OF ColoredPiece;
If the board configuration or initial setup needs changing, please inform the International Chess Federation, who will be happy to oblige, I'm sure.
initialBoard: Board = [
[white, br], [white, wn], [white, bb], [white, q],
[white, k], [white, wb], [white, bn], [white, wr],
[white, p0], [white, p1], [white, p2], [white, p3],
[white, p4], [white, p5], [white, p6], [white, p7],
noPiece, noPiece, noPiece, noPiece, noPiece, noPiece, noPiece, noPiece,
noPiece, noPiece, noPiece, noPiece, noPiece, noPiece, noPiece, noPiece,
noPiece, noPiece, noPiece, noPiece, noPiece, noPiece, noPiece, noPiece,
noPiece, noPiece, noPiece, noPiece, noPiece, noPiece, noPiece, noPiece,
[black, p0], [black, p1], [black, p2], [black, p3],
[black, p4], [black, p5], [black, p6], [black, p7],
[black, wr], [black, bn], [black, wb], [black, q],
[black, k], [black, bb], [black, wn], [black, br]
];
BoardIndex: TYPE = [0..64);
Position: TYPE = RECORD [
SELECT OVERLAID * FROM
rowCol => [row: [0..8), col: [0..8)],
index => [index: BoardIndex],
ENDCASE
];
Side: TYPE = {queen, king};
MoveList: TYPE = LIST OF Move;
Move: TYPE = RECORD [
piece: ColoredPiece,
Denotes piece being moved (the king for castling)
from: Position,
Denotes source square of this move
to: Position,
Denotes destination square of this move
alias: Piece ← p0,
Denotes alias (pawns only) added in this move
note: SpecialEffects ← [none[]],
Special effects (like capture & castle)
wasCheck: ARRAY WhiteBlack OF BOOL ← [FALSE, FALSE],
Used to save value of inCheck before the move
material: INTEGER ← 0
Used to save value of material before the move
];
SpecialEffects: TYPE = RECORD [
SELECT kind: * FROM
none => NULL,
castle => [side: Side],
remove => [victim: ColoredPiece, from: Position]
ENDCASE
];
GameState: TYPE = REF GameStateRep;
GameStateRep: TYPE = RECORD [
toMove: WhiteBlack ← white,
history: MoveHistory ← NIL,
future: MoveList ← NIL,
board: Board ← initialBoard,
material: ARRAY WhiteBlack OF INTEGER ← [0, 0],
Keeps track of the material weights for each side
coverage: ARRAY WhiteBlack OF Coverage ← [NIL, NIL],
Keeps track of the squares covered by white/black
inCheck: ARRAY WhiteBlack OF BOOL ← [FALSE, FALSE],
Keeps track of moves by king/rook
positions: ARRAY WhiteBlack OF Positions ← [NIL, NIL],
aliases: ARRAY WhiteBlack OF Aliases ← [NIL, NIL]
];
MoveHistory: TYPE = REF MoveHistoryRep;
MoveHistoryRep: TYPE = RECORD [
current: NAT,
last: NAT,
elems: SEQUENCE max: NAT OF Move];
Aliases: TYPE = REF AliasesRep;
AliasesRep: TYPE = ARRAY Pawn OF Piece;
When a pawn has turned into another piece it has an alias. Normally it has itself as an alias.
Positions: TYPE = REF PositionsRep;
PositionsRep: TYPE = ARRAY Piece OF FullPosition;
When a pawn has turned into another piece it has an alias. Normally it has itself as an alias.
FullPosition: TYPE = RECORD [onOff: {on, off}, position: Position];
Coverage: TYPE = REF CoverageRep;
CoverageRep: TYPE = ARRAY BoardIndex OF SquareCoverage;
Coverage describes which squares on the board are covered by various pieces.
SquareCoverage: TYPE = PACKED ARRAY Piece OF BOOL;
LookaheadStack: TYPE = REF LookaheadStackRep;
LookaheadStackRep: TYPE = RECORD [
levels: SEQUENCE max: NAT OF GameState
];
}.