-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeclaration.d.ts
166 lines (157 loc) · 5.69 KB
/
declaration.d.ts
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
declare module 'js-chess-engine' {
type LetterFen =
| 'R'
| 'P'
| 'N'
| 'B'
| 'K'
| 'Q'
| 'r'
| 'p'
| 'n'
| 'b'
| 'k'
| 'q';
type configObj = {
/**
* Player which plays next. Values white (default) or black.
*/
turn: 'black' | 'white';
/**
* Pieces on your chessboard. Syntax is same as FEN notation.
*/
pieces: { [key: string]: LetterFen };
/**
* Is added to server response when moves() or move() was called. It indicates possible moves for playing player (turn).
* @example
* {
* "A7": ["A6", "A5"],
* "B7": ["B6", "B5"]
* }
* Means A7 can move to A6 and A5. B7 can move to B6 and B5.
*
*/
moves: { [key: string]: string[] };
/**
* true when playing player cannot move (checkmate or draw). Default false.
*/
isFinished: boolean;
/**
* true when playing player is in check. Default false.
*/
check: boolean;
/**
* true when playing player has checkmate. Default false.
*/
checkMate: boolean;
/**
* Indicators if castling is still possible. true means yes. Default true.
*/
castling: {
/**
* (queenside) - White king moves from E1 to C1.
*/
whiteLong: boolean;
/**
* (kingside) - White king moves from E1 to G1.
*/
whiteShort: boolean;
/**
* (queenside) - Black king moves from E8 to C8
*/
blackLong: boolean;
/**
* (kingside) - Black king moves from E8 to C8.
*/
blackShort: boolean;
};
/**
* If a pawn has just made a two-square move, this is the position "behind" the pawn. This is an indicator for enPassant special pawn move. Default null.
*/
enPassant: string;
/**
* This is the number of halfmoves since the last capture or pawn advance. This is used to determine if a draw can be claimed under the fifty-move rule. Default 0.
*/
halfMove: number;
/**
* The number of the full move. It starts at 1, and is incremented after Black's move. Default 1.
*/
fullMove: number;
};
type levelType = 0 | 1 | 2 | 3 | 4;
class Game {
/**
* @param configuration
*/
constructor(configuration?: configObj);
/**
* Perform a move on a chessboard and recalculates in-game situation.
* @param from (mandatory) - Location on a chessboard where move starts (like A1,B3,...)
* @param to (mandatory) - Location on a chessboard where move starts (like A1,B3,...)
* @returns Returns played move {"H7":"H5"}
*/
move(from: string, to: string): { [key: string]: string };
/**
* Return possible moves for playing player.
* @param from (optional) - Location on a chessboard (like A1,B3,...). When not provided, returns all possible moves.
* @returns Returns an Object with possible moves for playing player {"B1":["A3","C3"],"G1":["F3","H3"]}
*/
moves(from?: string): { [key: string]: string[] };
/**
* New chess piece is added to provided location. Piece on provided location is replaced.
* @param location (mandatory) - Location on a chessboard (like A1,B3,...).
* @param piece (mandatory) - A chess piece you need add (pieces syntax is same as FEN notation).
* @returns void
*/
setPiece(location: string, piece: string): void;
/**
* Remove piece on provided location.
* @param location (mandatory) - Location on a chessboard (like A1,B3,...).
* @returns void
*/
removePiece(location: string): void;
/**
* Calculates and perform next move by computer player.
* N.B.: game.move(from, to) is called internally. Returns played move {"H7":"H5"}
* @param level (optional) - Computer player skill from 0 to 4. Read more about computer AI. Default 2.
* @returns void
*
* @example
*
* Computer AI
* This engine includes configurable AI computer logic based on Minimax algorithm. There are five possible levels at this time.
*
* Level Alias Moves to the future HW requirements Approx. time to move (s)*
* 0 Well-trained monkey 1-2 None <0.01
* 1 Beginner 2-4 Very Low <0.1
* 2 Intermediate 2-4 Low 0.7
* 3 Advanced 3-5 Medium 4.6
* 4 Experienced 4-5 High 9.5
*
* *Approx. time to move (s) - This number represent the average amount of seconds needed for one move during a chess game on t3.nano AWS instance. T3.nano is a low-cost machine with 0.5 GiB RAM and basic CPU performance. Please note, amount of time needed for calculations heavily depends on in-game situation (number of chess pieces still on a chessboard).
*/
aiMove(level: levelType): { [key: string]: string };
/**
* Returns all played moves in array with chess board configuration like [{from:'A2',to:'A3',configuration:{...}},{from:'A7',to:'A6',configuration:{...}}].
* @param reversed (optional) - When false, last move is the last element in returned array. When true, last move is first. Default false.
*/
getHistory(reversed: boolean = false): {
from: string;
to: string;
configuration: configObj;
}[];
/**
* Print a chessboard to console standard output.
*/
printToConsole(): void;
/**
* Return in-game situation represented by JSON configuration.
*/
exportJson(): configObj;
/**
* Return in-game situation represented by FEN.
*/
exportFEN(): string;
}
export { Game, configObj, levelType, LetterFen };
}