Ejemplo n.º 1
0
        public BoardPositions GetMovableBoardPositions(
            PlayerType player,
            BoardPosition position,
            Board board,
            BoardPositions turnPlayerKomaPositions,
            BoardPositions opponentKomaPositions)
        {
            var positions = new BoardPositions();

            // [後手なら移動可能位置は反転される]
            var toRelativePos = RelativeBoardPosition;

            if (player == PlayerType.SecondPlayer)
            {
                toRelativePos = toRelativePos.Reverse();
            }

            var toPos = position.Add(toRelativePos);

            if (board.Positions.Contains(toPos))
            {
                if (!turnPlayerKomaPositions.Contains(toPos))
                {
                    positions = positions.Add(toPos);
                }
            }

            return(positions);
        }
Ejemplo n.º 2
0
 public BoardPositions MovablePosition(List <Koma> komaList)
 {
     lock (thisLock)
     {
         var movablePositions = new BoardPositions();
         foreach (var koma in komaList)
         {
             movablePositions = movablePositions.Add(MovablePosition(koma));
         }
         return(movablePositions);
     }
 }
Ejemplo n.º 3
0
        public BoardPositions GetMovableBoardPositions(
            PlayerType player,
            BoardPosition position,
            Board board,
            BoardPositions turnPlayerKomaPositions,
            BoardPositions opponentKomaPositions)
        {
            var positions = new BoardPositions();

            // [後手なら移動可能位置は反転される]
            var toRelativePos = RelativeBoardPosition;

            if (player == PlayerType.SecondPlayer)
            {
                toRelativePos = toRelativePos.Reverse();
            }

            for (var toPos = position.Add(toRelativePos); ; toPos = toPos.Add(toRelativePos))
            {
                // [盤の範囲外に来たら移動不可]
                if (!board.Positions.Contains(toPos))
                {
                    break;
                }

                // [自分の駒に当たったら移動不可]]
                if (turnPlayerKomaPositions.Contains(toPos))
                {
                    break;
                }

                positions = positions.Add(toPos);

                // [相手の駒があったらその先は移動できない]
                if (opponentKomaPositions.Contains(toPos))
                {
                    break;
                }
            }

            return(positions);
        }
Ejemplo n.º 4
0
        public BoardPositions GetMovableBoardPositions(
            PlayerType player,
            BoardPosition position,
            Board board,
            BoardPositions turnPlayerKomaPositions,
            BoardPositions opponentKomaPositions)
        {
            BoardPositions positions = new BoardPositions();

            foreach (var move in Moves)
            {
                positions = positions.Add(
                    move.GetMovableBoardPositions(
                        player,
                        position as BoardPosition,
                        board,
                        turnPlayerKomaPositions,
                        opponentKomaPositions));
            }
            return(positions);
        }