<> <> <> 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; <> 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, <> from: Position, <> to: Position, <> alias: Piece _ p0, <> note: SpecialEffects _ [none[]], <> wasCheck: ARRAY WhiteBlack OF BOOL _ [FALSE, FALSE], <> material: INTEGER _ 0 <> ]; 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], <> coverage: ARRAY WhiteBlack OF Coverage _ [NIL, NIL], <> inCheck: ARRAY WhiteBlack OF BOOL _ [FALSE, FALSE], <> 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; <> Positions: TYPE = REF PositionsRep; PositionsRep: TYPE = ARRAY Piece OF FullPosition; <> FullPosition: TYPE = RECORD [onOff: {on, off}, position: Position]; Coverage: TYPE = REF CoverageRep; CoverageRep: TYPE = ARRAY BoardIndex OF SquareCoverage; <> SquareCoverage: TYPE = PACKED ARRAY Piece OF BOOL; LookaheadStack: TYPE = REF LookaheadStackRep; LookaheadStackRep: TYPE = RECORD [ levels: SEQUENCE max: NAT OF GameState ]; }.