flutter: 增加 sqToLoc/locToSq 转换函数

This commit is contained in:
Calcitem 2020-11-08 10:28:19 +08:00
parent fe8be55163
commit 800ded708a
1 changed files with 35 additions and 5 deletions

View File

@ -13,19 +13,49 @@ class Position {
initDefaultPosition(); initDefaultPosition();
} }
Map<int, int> sqToLoc = {
8: 17,
9: 18,
10: 25,
11: 32,
12: 31,
13: 30,
14: 23,
15: 16,
16: 10,
17: 12,
18: 26,
19: 40,
20: 38,
21: 36,
22: 22,
23: 8,
24: 3,
25: 6,
26: 27,
27: 48,
28: 45,
29: 42,
30: 21,
31: 0
};
Map<int, int> locToSq;
void initDefaultPosition() { void initDefaultPosition() {
// //
locToSq = sqToLoc.map((k, v) => MapEntry(v, k));
_sideToMove = Side.black; _sideToMove = Side.black;
_board = List<String>(64); // 7 * 7 _board = List<String>(64); // 7 * 7
for (var i = 0; i < 64; i++) { for (var i = 0; i < 64; i++) {
_board[i] ??= Piece.noPiece; _board[i] ??= Piece.noPiece;
} }
// Debugging // sq board // Debugging
_board[4] = Piece.blackStone; //_board[sqToLoc[8]] = Piece.blackStone;
_board[7] = Piece.ban; //_board[7] = Piece.ban;
_board[8] = Piece.whiteStone; //_board[8] = Piece.whiteStone;
_recorder = MillRecorder(lastCapturedPosition: toFen()); _recorder = MillRecorder(lastCapturedPosition: toFen());
} }