From 2f7af0860845a5d7973c3b82f6a29f4339b65584 Mon Sep 17 00:00:00 2001 From: Calcitem Date: Sun, 15 Nov 2020 17:36:36 +0800 Subject: [PATCH] =?UTF-8?q?flutter:=20=E6=B7=BB=E5=8A=A0=20Position()=20?= =?UTF-8?q?=E6=9E=84=E9=80=A0=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ui/flutter/lib/mill/position.dart | 51 ++++++++++++++++----------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/src/ui/flutter/lib/mill/position.dart b/src/ui/flutter/lib/mill/position.dart index 2f5b9359..442877a8 100644 --- a/src/ui/flutter/lib/mill/position.dart +++ b/src/ui/flutter/lib/mill/position.dart @@ -79,27 +79,6 @@ class Position { 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() { _grid = List(); for (int sq = 0; sq < board.length; sq++) { @@ -218,6 +197,36 @@ class Position { 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) { /* A FEN string defines a particular position using only the ASCII character set.