Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 64 lines (53 sloc) 2.808 kb
f6de70a François Cardinaux Initial commit: a chess move generator
authored
1 %% @doc Chess Move Generator: Header file
2 %% @end
3 %%
4 %% Author François Cardinaux, CH 1207 Genève
5 %% Copyright 2011 François Cardinaux
6
64cea53 François Cardinaux Improved the record definition, enhanced it with type definition and ref...
authored
7 % Noticeable values in 0x88 representation:
8 -define(ROW_SPAN, 16).
9 -define(MOVE_UP, 16).
10 -define(MOVE_UP_LEFT, 15).
11 -define(MOVE_UP_RIGHT, 17).
12 -define(MOVE_UP_2, 32).
13 -define(MOVE_DOWN, -16).
14 -define(MOVE_DOWN_LEFT, -17).
15 -define(MOVE_DOWN_RIGHT, -15).
16 -define(MOVE_DOWN_2, -32).
17 -define(BOTTOM_LEFT_CORNER, 0).
18 -define(BOTTOM_RIGHT_CORNER, 7).
19 -define(TOP_LEFT_CORNER, 112).
20 -define(TOP_RIGHT_CORNER, 119).
21
22 -define(CASTLING_ALL, 15).
23 -define(CASTLING_WHITE_KING, 8).
24 -define(CASTLING_WHITE_QUEEN, 4).
25 -define(CASTLING_BLACK_KING, 2).
26 -define(CASTLING_BLACK_QUEEN, 1).
27
28 % Positions of the elements inside the ntc_chess_piece record
29 -define(PIECE_RECORD_COLOR, 2).
30 -define(PIECE_RECORD_TYPE, 3).
31 -define(PIECE_RECORD_SQUARE, 4).
32
33 -type chess_piece_color() :: 'black' | 'white'.
34 -type chess_piece_type() :: 'pawn' | 'knight' | 'bishop' | 'rook' | 'queen' | 'king'.
35 -type chess_piece_square() :: ?BOTTOM_LEFT_CORNER..?TOP_RIGHT_CORNER. % In 0x88 representation
36 -type castling() :: 'false' | 'queen' | 'king'.
37
f6de70a François Cardinaux Initial commit: a chess move generator
authored
38 -record(ntc_chess_piece, {
64cea53 François Cardinaux Improved the record definition, enhanced it with type definition and ref...
authored
39 color :: chess_piece_color(),
40 type :: chess_piece_type(),
41 square = false :: 'false' | chess_piece_square()}).
42
43 -record(ntc_chess_position, {
44 pieces :: [#ntc_chess_piece{}],
45 turn :: 'false' | chess_piece_color(),
46 allowedCastling = 0 :: 0..?CASTLING_ALL,
47 enPassantSquare = false :: 'false' | chess_piece_square(),
48 halfMoveClock = 0 :: integer(),
49 moveNumber = 0 :: integer()}).
f6de70a François Cardinaux Initial commit: a chess move generator
authored
50
51 -record(ntc_chess_move, {
64cea53 François Cardinaux Improved the record definition, enhanced it with type definition and ref...
authored
52 from :: #ntc_chess_piece{},
53 to :: #ntc_chess_piece{}, % May be a different piece, in case of promotion
54 newPosition :: #ntc_chess_position{},
55 castling = false :: castling(),
56 taken = false :: 'false' | #ntc_chess_piece{}}). % Not necessarily the same square as 'to' (en passant)
57
58 % Source: Programming Erlang, p 424
59 -define(NYI(X), (begin
60 io:format("*** NYI ~p ~p ~p~n", [?MODULE, ?LINE, X])
61 end)).
62
f6de70a François Cardinaux Initial commit: a chess move generator
authored
63
Something went wrong with that request. Please try again.