コード例 #1
0
        public void MakeMove(IMove move)
        {
            if (move.IsPassMove)
            {
                return;
            }
            if (move.Player.PlayerKind == PlayerKind.Black)
            {
                Positions[move.MovePosition.Item1, move.MovePosition.Item2] = CellState.Black;
                BlackPoints.Add(move.MovePosition);

                foreach (var convertedPoint in move.ConvertedPoints)
                {
                    Positions[convertedPoint.Item1, convertedPoint.Item2] = CellState.Black;
                    BlackPoints.Add(convertedPoint);    //add to black
                    WhitePoints.Remove(convertedPoint); //remove from white
                }
            }
            else
            {
                Positions[move.MovePosition.Item1, move.MovePosition.Item2] = CellState.White;
                WhitePoints.Add(move.MovePosition);

                foreach (var convertedPoint in move.ConvertedPoints)
                {
                    Positions[convertedPoint.Item1, convertedPoint.Item2] = CellState.White;
                    WhitePoints.Add(convertedPoint);    //add to black
                    BlackPoints.Remove(convertedPoint); //remove to black
                }
            }
        }
コード例 #2
0
        public void UnDoMove(IMove move)
        {
            if (move == null || move.IsPassMove)
            {
                return;
            }
            Positions[move.MovePosition.Item1, move.MovePosition.Item2] = CellState.Empty;
            if (move.Player.PlayerKind == PlayerKind.Black)
            {
                BlackPoints.Remove(move.MovePosition);

                foreach (var convertedPoint in move.ConvertedPoints)
                {
                    Positions[convertedPoint.Item1, convertedPoint.Item2] = CellState.White;    //swap back the points
                    BlackPoints.Remove(convertedPoint);
                    WhitePoints.Add(convertedPoint);
                }
            }
            else
            {
                WhitePoints.Remove(move.MovePosition);

                foreach (var convertedPoint in move.ConvertedPoints)
                {
                    Positions[convertedPoint.Item1, convertedPoint.Item2] = CellState.Black;    //swap back the points
                    WhitePoints.Remove(convertedPoint);
                    BlackPoints.Add(convertedPoint);
                }
            }
        }
コード例 #3
0
        public void FlipCellManually(int cellX, int cellY)
        {
            CellState cellState = Positions[cellX, cellY];

            if (cellState == CellState.Empty)
            {
                return;
            }
            if (cellState == CellState.White)
            {
                WhitePoints.Remove(new MyTuple <int, int>(cellX, cellY));
                BlackPoints.Add(new MyTuple <int, int>(cellX, cellY));
                Positions[cellX, cellY] = CellState.Black;
            }
            else
            {
                BlackPoints.Remove(new MyTuple <int, int>(cellX, cellY));
                WhitePoints.Add(new MyTuple <int, int>(cellX, cellY));
                Positions[cellX, cellY] = CellState.White;
            }
        }