Exemple #1
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);
                }
            }
        }
Exemple #2
0
        private static readonly short[] dy = { 0, 1, -1, 0, 1, -1, -1, 1 }; //directions in y

        #region Methods

        public void ConfigureNewGame(bool emptyBoard)
        {
            BlackPoints.Clear();
            WhitePoints.Clear();
            for (int i = 0; i < BoardSize; i++)
            {
                for (int j = 0; j < BoardSize; j++)
                {
                    Positions[i, j] = CellState.Empty;
                }
            }

            if (!emptyBoard)
            {
                WhitePoints.Add(new MyTuple <int, int>(3, 3));
                WhitePoints.Add(new MyTuple <int, int>(4, 4));
                BlackPoints.Add(new MyTuple <int, int>(3, 4));
                BlackPoints.Add(new MyTuple <int, int>(4, 3));
                foreach (var whitePoint in WhitePoints)
                {
                    Positions[whitePoint.Item1, whitePoint.Item2] = CellState.White;
                }
                foreach (var blackPoint in BlackPoints)
                {
                    Positions[blackPoint.Item1, blackPoint.Item2] = CellState.Black;
                }
            }
        }
Exemple #3
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
                }
            }
        }
Exemple #4
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;
            }
        }