-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoardPreset.m
112 lines (99 loc) · 5.66 KB
/
BoardPreset.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
classdef BoardPreset
enumeration
Standard
Chaos
Duel
CheckTest
CastleTest
PromoTest
end
methods (Static)
function preset = apply(obj)
global WhitePawn WhiteRook WhiteKnight WhiteBishop WhiteQueen WhiteKing BlackPawn BlackRook BlackKnight BlackBishop BlackQueen BlackKing;
% This is defining the chess pieces we'll need to first set up
% the board. You can see how to create a ChessPiece (just pass
% it a PieceType and 1 for white or 2 for black).
% HANDLE WITH CAUTION! Please only use these for equality checking! Use BoardPreset
% and ChessBoard.bset instead of manually making a board
% matrix with these handles!
WhitePawn = ChessPiece(PieceType.Pawn, 1);
WhiteRook = ChessPiece(PieceType.Rook, 1);
WhiteKnight = ChessPiece(PieceType.Knight, 1);
WhiteBishop = ChessPiece(PieceType.Bishop, 1);
WhiteQueen = ChessPiece(PieceType.Queen, 1);
WhiteKing = ChessPiece(PieceType.King, 1);
BlackPawn = ChessPiece(PieceType.Pawn, 2);
BlackRook = ChessPiece(PieceType.Rook, 2);
BlackKnight = ChessPiece(PieceType.Knight, 2);
BlackBishop = ChessPiece(PieceType.Bishop, 2);
BlackQueen = ChessPiece(PieceType.Queen, 2);
BlackKing = ChessPiece(PieceType.King, 2);
switch obj
case BoardPreset.Standard
preset = { BlackRook, BlackKnight, BlackBishop, BlackQueen, BlackKing, BlackBishop, BlackKnight, BlackRook;
BlackPawn, BlackPawn, BlackPawn, BlackPawn, BlackPawn, BlackPawn, BlackPawn, BlackPawn;
0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0;
WhitePawn, WhitePawn, WhitePawn, WhitePawn, WhitePawn, WhitePawn, WhitePawn, WhitePawn;
WhiteRook, WhiteKnight, WhiteBishop, WhiteQueen, WhiteKing, WhiteBishop, WhiteKnight, WhiteRook };
case BoardPreset.Chaos
preset = { BlackRook, BlackKnight, BlackBishop, BlackRook, BlackKing, BlackBishop, BlackKnight, BlackRook;
BlackQueen, BlackQueen, BlackQueen, BlackQueen, BlackQueen, BlackQueen, BlackQueen, BlackQueen;
0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0;
WhiteQueen, WhiteQueen, WhiteQueen, WhiteQueen, WhiteQueen, WhiteQueen, WhiteQueen, WhiteQueen;
WhiteRook, WhiteKnight, WhiteBishop, WhiteKing, WhiteRook, WhiteBishop, WhiteKnight, WhiteRook };
case BoardPreset.Duel
preset = { BlackRook, BlackKnight, BlackBishop, 0, BlackKing, BlackBishop, BlackKnight, BlackRook;
BlackKnight, 0, 0, BlackQueen, BlackQueen, 0, 0, BlackKnight;
0, 0, 0, 0, 0, 0, 0, 0;
BlackPawn, BlackPawn, BlackPawn, BlackPawn, BlackPawn, BlackPawn, BlackPawn, BlackPawn;
WhitePawn, WhitePawn, WhitePawn, WhitePawn, WhitePawn, WhitePawn, WhitePawn, WhitePawn;
0, 0, 0, 0, 0, 0, 0, 0;
WhiteKnight, 0, 0, WhiteQueen, WhiteQueen, 0, 0, WhiteKnight;
WhiteRook, WhiteKnight, WhiteBishop, WhiteKing, 0, WhiteBishop, WhiteKnight, WhiteRook };
case BoardPreset.CheckTest
% Since this emulates end-game state, unflag both
% kings' castles.
bk_emu = BlackKing.cpy();
wk_emu = WhiteKing.cpy();
bk_emu.FlagPure = 0;
wk_emu.FlagPure = 0;
preset = { 0, 0, 0, 0, 0, 0, 0, bk_emu;
WhiteRook, 0, 0, 0, 0, 0, 0, 0;
0, WhiteRook, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, wk_emu;
0, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0; };
case BoardPreset.CastleTest
preset = { BlackRook, 0, 0, 0, BlackKing, 0, 0, BlackRook;
BlackPawn, BlackPawn, BlackPawn, BlackPawn, BlackPawn, BlackPawn, BlackPawn, BlackPawn;
0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0;
WhitePawn, WhitePawn, WhitePawn, WhitePawn, WhitePawn, WhitePawn, WhitePawn, WhitePawn;
WhiteRook, 0, 0, 0, WhiteKing, 0, 0, WhiteRook };
case BoardPreset.PromoTest
% Since this emulates end-game state, unflag both
% kings' castles.
bk_emu = BlackKing.cpy();
bk_emu.FlagPure = 0;
preset = { 0, 0, 0, 0, bk_emu, 0, 0, 0;
WhitePawn, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, WhiteKnight;
WhiteRook, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, WhiteBishop, 0, 0;
0, 0, WhitePawn, 0, WhitePawn, WhitePawn, 0, WhitePawn;
0, 0, 0, 0, WhiteKing, 0, 0, WhiteRook };
end
end
end
end