public void TestBoard(Board originalBoard, Move move) { if (this.foundTarget != null) return; TestBoard(originalBoard.BoardForMove(move)); }
bool IsOccupied(Move move) { Position startPos = move.NewStartPos(); Vehicle v = this.board[startPos.X, startPos.Y]; if (v != null && v != move.movingVehicle) return true; Position endPos = move.NewEndPos(); v = this.board[endPos.X, endPos.Y]; if (v != null && v != move.movingVehicle) return true; return false; }
bool IsInBounds(Move move) { Position startPos = move.NewStartPos(); if (startPos.X < 0 || startPos.Y < 0) return false; Position endPos = move.NewEndPos(); if (endPos.X >= this.board.GetLength(0) || endPos.Y >= this.board.GetLength(1)) return false; return true; }
List<Move> getMovesForVehicle(Vehicle v) { List<Move> moves = new List<Move>(); // Check left/up int delta = -1; Move move = new Move(v, delta); while(this.IsInBounds(move) && !this.IsOccupied(move)) { moves.Add(move); delta--; move = new Move(v, delta); } // Check right/down delta = 1; move = new Move(v, delta); while (this.IsInBounds(move) && !this.IsOccupied(move)) { moves.Add(move); delta++; move = new Move(v, delta); } return moves; }
public Board BoardForMove(Move move) { Board newBoard = this.Copy(); newBoard.ApplyMove(move); return newBoard; }
public void ApplyMove(Move move) { Vehicle v = this.vehicles[move.movingVehicle.identity]; Position start = v.startPos, end = v.endPos; // loop over ons board, zet alle plaatsen van v op null for (int x = start.X; x <= end.X; x++) { for (int y = start.Y; y <= end.Y; y++) { this.board[x, y] = null; } } v.startPos = move.NewStartPos(); start = v.startPos; end = v.endPos; // loop over ons board, zet alle nieuwe plaaysen van v op v for (int x = start.X; x <= end.X; x++) { for (int y = start.Y; y <= end.Y; y++) { this.board[x, y] = v; } } if(this.game.outputMode == Game.OutputMode.Solve) this.appliedMoves.Add(move); }