Monte Carlo simulator for a percolating medium