function SmoothMap = smooth(Map,degree)
%function SmoothMap = smooth(Map,degree)
%Does some crude smoothing for a 2D map
%Degree is half the width of a moving average
%
%Writen by Daniel Fraser 2000

SmoothMap=zeros(size(Map,1),size(Map,2));
Map = [zeros(size(Map,1),degree),Map,zeros(size(Map,1),degree)];
Map = [zeros(degree,size(Map,2));Map;zeros(degree,size(Map,2))];

for i = 1:size(SmoothMap,1)
   for j = 1:size(SmoothMap,2)
      Total = sum(sum(Map(i-degree+degree:i+degree+degree,j-degree+degree:j+degree+degree)));
      SmoothMap(i,j) = Total/((2*degree)+1)^2;
   end
end
