  When the problem of boson sampling was first proposed, it was assumed that
little or no photon collisions occur. However, modern experimental realizations
rely on setups where collisions are quite common, i.e. the number of photons
$M$ injected into the circuit is close to the number of detectors $N$. Here we
present a classical algorithm that simulates a bosonic sampler: it calculates
the probability of a given photon distribution at the interferometer outputs
for a given distribution at the inputs. This algorithm is most effective in
cases with multiple photon collisions, and in those cases it outperforms known
algorithms.
