예제 #1
0
        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;
        }
예제 #2
0
        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;
        }
예제 #3
0
        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);
        }