public Board Shift(int shiftR, int shiftC) { Board retBoard = new Board() { MoveNoMade = this.MoveNoMade, WhoHasMove = this.WhoHasMove }; // check if board can be shifted foreach (Position position in Positions) { if (position.Owner != Position.Player.None) { if (Board.IsCoordinateOK(position.R + shiftR) && Board.IsCoordinateOK(position.C + shiftC)) { // shift retBoard.Positions[position.R + shiftR, position.C + shiftC] = position.Clone(); } else // can't shift owned positions { return(null); } } } return(retBoard); }
public bool PredictShift(Board board, Move move) { // shift for (int shiftR = MIN_SHIFT; shiftR <= MAX_SHIFT; shiftR++) { for (int shiftC = MIN_SHIFT; shiftC <= MAX_SHIFT; shiftC++) { Board boardBeforeMoveAfterShift = move.BoardBeforeMove.Shift(shiftR, shiftC); if (boardBeforeMoveAfterShift != null) { if (boardBeforeMoveAfterShift.ToString().Equals(board.ToString())) { int destinyR = move.MoveMade.R + shiftR; int destinyC = move.MoveMade.C + shiftC; if (Board.IsCoordinateOK(destinyR) && Board.IsCoordinateOK(destinyC)) { PredictionsByKnownAfterShift[destinyR, destinyC] += PREDICTION_AFTER_SHIFT_WEIGHT; } } } } } return(false); }