function water = simulateFlood(terrain)
    % Computes a series of snapshots for water level
    % as it rises and falls accross a terrain.
    %
    % The water level will begin at height 1, and rise one
    % level at a time until the entire terrain is submerged,
    % after which it will drop one level at a time until the
    % exterior level goes back to zero.
    %
    % Result will be three-dimensional array where
    % water(:,:, k) depicts the water level after the
    % kth step of the process.
    high = max(max(terrain));
    water = zeros(size(terrain));
    for level = [1:(high+1)  high:-1:0]
        water(:,:,end+1) = recomputeWater(terrain, level, water(:,:,end));
    end
