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); }
public BoardPositions MovablePosition(List <Koma> komaList) { lock (thisLock) { var movablePositions = new BoardPositions(); foreach (var koma in komaList) { movablePositions = movablePositions.Add(MovablePosition(koma)); } return(movablePositions); } }
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); }
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); }