flutter: 添加 Position() 构造函数

This commit is contained in:
Calcitem 2020-11-15 17:36:36 +08:00
parent ac7f2a565f
commit 2f7af08608
1 changed files with 30 additions and 21 deletions

View File

@ -79,27 +79,6 @@ class Position {
Move move; Move move;
Position.init() {
for (var i = 0; i < _grid.length; i++) {
_grid[i] ??= Piece.noPiece;
}
for (var i = 0; i < board.length; i++) {
board[i] ??= Piece.noPiece;
}
phase = Phase.placing;
// Example
//_board[sqToLoc[8]] = Piece.blackStone;
_recorder = MillRecorder(lastCapturedPosition: fen());
}
init() {
Position.init();
}
Position.boardToGrid() { Position.boardToGrid() {
_grid = List<String>(); _grid = List<String>();
for (int sq = 0; sq < board.length; sq++) { for (int sq = 0; sq < board.length; sq++) {
@ -218,6 +197,36 @@ class Position {
return false; return false;
} }
Position.init() {
for (var i = 0; i < _grid.length; i++) {
_grid[i] ??= Piece.noPiece;
}
for (var i = 0; i < board.length; i++) {
board[i] ??= Piece.noPiece;
}
phase = Phase.placing;
// Example
//_board[sqToLoc[8]] = Piece.blackStone;
_recorder = MillRecorder(lastCapturedPosition: fen());
}
init() {
Position.init();
}
Position() {
//const DEFAULT_RULE_NUMBER = 1;
//setPosition(rules[DEFAULT_RULE_NUMBER]);
setPosition(rule); // TODO
score[Color.black] = score[Color.white] = score[Color.draw] = nPlayed = 0;
}
void set(String fenStr) { void set(String fenStr) {
/* /*
A FEN string defines a particular position using only the ASCII character set. A FEN string defines a particular position using only the ASCII character set.