Ejemplo n.º 1
0
        //パスする。パスできない場合=false
        public bool pass()
        {
            // 打つ手があればパスできない
            if (_movablePos[_turns].Count() != 0)
            {
                return(false);
            }

            // ゲームが終了しているなら、パスできない
            if (isGameOver())
            {
                return(false);
            }

            //色を反転する
            _currentColor = -_currentColor;

            // 空のupdateを挿入しておく
            var nullupdate = new DisctList();

            UpdateLog.Push(nullupdate);

            //MovableDirと_movablePosを再計算する
            initMovable();

            return(true);
        }
Ejemplo n.º 2
0
        //パスする。パスできない場合=false
        public bool pass()
        {
	        // 打つ手があればパスできない
	        if(_movablePos[_turns].Count() != 0) return false;
	
	        // ゲームが終了しているなら、パスできない
	        if(isGameOver()) return false;
	
	        //色を反転する
	        _currentColor = -_currentColor;
	
	        // 空のupdateを挿入しておく
	        var nullupdate = new DisctList();
            UpdateLog.Push(nullupdate);
	
	        //MovableDirと_movablePosを再計算する
	        initMovable();
	
	        return true;
        }
Ejemplo n.º 3
0
        //石を打つ、変更点追跡、石裏返す、石数カウント、UpdateLog記録
        private void flipDiscs(Point point)
        {
	        int x, y;

	        //pointから見て、石が反転する方向をビットで取得
	        uint dir = MovableDir[_turns,point.x,point.y];

	        //今オペレーションの操作ログ記録用
	        var update = new DisctList();

	        //置いた場所=pointを置いた色にする
	        _rawBoard[point.x,point.y] = _currentColor;
	
	        //最初に置いた石をログ記録
            update.Add(new Disc(point.x, point.y, _currentColor));

	        // 上
	        if ((dir & Direction.UPPER) != 0)
	        {
		        y = point.y;
		        while(_rawBoard[point.x,--y] == -_currentColor)
		        {
			        _rawBoard[point.x,y] = _currentColor;
                    update.Add(new Disc(point.x, y, _currentColor));
                }
	        }

            // 下
            if ((dir & Direction.LOWER) != Direction.NONE)
            {
                y = point.y;
                while (_rawBoard[point.x, ++y] != _currentColor)
                {
                    _rawBoard[point.x, y] = _currentColor;
                    update.Add(new Disc(point.x, y, _currentColor));
                }
            }

            // 左
            if ((dir & Direction.LEFT) != Direction.NONE)
            {
                x = point.x;
                while (_rawBoard[--x, point.y] != _currentColor)
                {
                    _rawBoard[x, point.y] = _currentColor;
                    update.Add(new Disc(x, point.y, _currentColor));
                }
            }

            // 右
            if ((dir & Direction.RIGHT) != Direction.NONE)
            {
                x = point.x;
                while (_rawBoard[++x, point.y] != _currentColor)
                {
                    _rawBoard[x, point.y] = _currentColor;
                    update.Add(new Disc(x, point.y, _currentColor));
                }
            }

            // 右上
            if ((dir & Direction.UPPER_RIGHT) != Direction.NONE)
            {
                x = point.x;
                y = point.y;
                while (_rawBoard[++x, --y] != _currentColor)
                {
                    _rawBoard[x, y] = _currentColor;
                    update.Add(new Disc(x, y, _currentColor));
                }
            }

            // 左上
            if ((dir & Direction.UPPER_LEFT) != Direction.NONE)
            {
                x = point.x;
                y = point.y;
                while (_rawBoard[--x, --y] != _currentColor)
                {
                    _rawBoard[x, y] = _currentColor;
                    update.Add(new Disc(x, y, _currentColor));
                }
            }

            // 左下
            if ((dir & Direction.LOWER_LEFT) != Direction.NONE)
            {
                x = point.x;
                y = point.y;
                while (_rawBoard[--x, ++y] != _currentColor)
                {
                    _rawBoard[x, y] = _currentColor;
                    update.Add(new Disc(x, y, _currentColor));
                }
            }

            // 右下
            if ((dir & Direction.LOWER_RIGHT) != Direction.NONE)
            {
                x = point.x;
                y = point.y;
                while (_rawBoard[++x, ++y] != _currentColor)
                {
                    _rawBoard[x, y] = _currentColor;
                    update.Add(new Disc(x, y, _currentColor));
                }
            }


	        // 石の数を更新
	        int discdiff = update.Count();

	        this._discs[_currentColor]  += discdiff;
            this._discs[-_currentColor] -= discdiff - 1;
            this._discs[Disc.EMPTY]--;
	
	        //今回の 行った操作ログに追加
            this.UpdateLog.Push(update);

        }
Ejemplo n.º 4
0
        //石を打つ、変更点追跡、石裏返す、石数カウント、UpdateLog記録
        private void flipDiscs(Point point)
        {
            int x, y;

            //pointから見て、石が反転する方向をビットで取得
            uint dir = MovableDir[_turns, point.x, point.y];

            //今オペレーションの操作ログ記録用
            var update = new DisctList();

            //置いた場所=pointを置いた色にする
            _rawBoard[point.x, point.y] = _currentColor;

            //最初に置いた石をログ記録
            update.Add(new Disc(point.x, point.y, _currentColor));

            // 上
            if ((dir & Direction.UPPER) != 0)
            {
                y = point.y;
                while (_rawBoard[point.x, --y] == -_currentColor)
                {
                    _rawBoard[point.x, y] = _currentColor;
                    update.Add(new Disc(point.x, y, _currentColor));
                }
            }

            // 下
            if ((dir & Direction.LOWER) != Direction.NONE)
            {
                y = point.y;
                while (_rawBoard[point.x, ++y] != _currentColor)
                {
                    _rawBoard[point.x, y] = _currentColor;
                    update.Add(new Disc(point.x, y, _currentColor));
                }
            }

            // 左
            if ((dir & Direction.LEFT) != Direction.NONE)
            {
                x = point.x;
                while (_rawBoard[--x, point.y] != _currentColor)
                {
                    _rawBoard[x, point.y] = _currentColor;
                    update.Add(new Disc(x, point.y, _currentColor));
                }
            }

            // 右
            if ((dir & Direction.RIGHT) != Direction.NONE)
            {
                x = point.x;
                while (_rawBoard[++x, point.y] != _currentColor)
                {
                    _rawBoard[x, point.y] = _currentColor;
                    update.Add(new Disc(x, point.y, _currentColor));
                }
            }

            // 右上
            if ((dir & Direction.UPPER_RIGHT) != Direction.NONE)
            {
                x = point.x;
                y = point.y;
                while (_rawBoard[++x, --y] != _currentColor)
                {
                    _rawBoard[x, y] = _currentColor;
                    update.Add(new Disc(x, y, _currentColor));
                }
            }

            // 左上
            if ((dir & Direction.UPPER_LEFT) != Direction.NONE)
            {
                x = point.x;
                y = point.y;
                while (_rawBoard[--x, --y] != _currentColor)
                {
                    _rawBoard[x, y] = _currentColor;
                    update.Add(new Disc(x, y, _currentColor));
                }
            }

            // 左下
            if ((dir & Direction.LOWER_LEFT) != Direction.NONE)
            {
                x = point.x;
                y = point.y;
                while (_rawBoard[--x, ++y] != _currentColor)
                {
                    _rawBoard[x, y] = _currentColor;
                    update.Add(new Disc(x, y, _currentColor));
                }
            }

            // 右下
            if ((dir & Direction.LOWER_RIGHT) != Direction.NONE)
            {
                x = point.x;
                y = point.y;
                while (_rawBoard[++x, ++y] != _currentColor)
                {
                    _rawBoard[x, y] = _currentColor;
                    update.Add(new Disc(x, y, _currentColor));
                }
            }


            // 石の数を更新
            int discdiff = update.Count();

            this._discs[_currentColor]  += discdiff;
            this._discs[-_currentColor] -= discdiff - 1;
            this._discs[Disc.EMPTY]--;

            //今回の 行った操作ログに追加
            this.UpdateLog.Push(update);
        }