Simple model for vapor deposition

Vito R. Vanin, Instituto de Física, Universidade de São Paulo - 14/03/2016; revised 14/3/2017

Simulation of the model described in section 1.2, as pictured in figure 1.2: an atom sticks to any slot with equal probability.
You can change the number of slots and the number of atoms that stick to the backing.

randomDeposition[numberOfAtoms_,numberOfSlots_]:=
Module[{occupation,graphics,atoms,backingPosition,filament,backing,source,cloud},
backingPosition=28;
filament=Table[Line[{{2(i-1),Mod[i-1,2] },{2i,Mod[i,2]}}],{i,numberOfSlots}];
backing=Table[Disk[{2i-1,backingPosition}],{i,numberOfSlots}];
source=Table[Disk[{2i-1,3}],{i,numberOfSlots}];
graphics={Graphics[{Black,filament,backing,Blue,source}]};
atoms={Disk[{1,backingPosition}]};
occupation=ConstantArray[0,numberOfSlots];
Do[Module[{index},index=RandomInteger[{1,numberOfSlots}];
AppendTo[atoms,Disk[{2index-1,backingPosition-2( ++occupation[[index]])}]  ];
cloud=Table[Disk[{2RandomInteger[{1,numberOfSlots}]-1,RandomInteger[{6,backingPosition-2}]}],{3}]; 
AppendTo[graphics,Graphics[{Blue,atoms,cloud,source,Red,{Thick,filament},Black,backing}] ] ],{numberOfAtoms }];
AppendTo[graphics,Graphics[{Blue,atoms,source,Black,filament,backing}] ] 
]

Manipulate[ r;ListAnimate[randomDeposition[numberOfAtoms,numberOfSlots],AnimationRunning->False ,AnimationRepetitions->1],{{numberOfAtoms,28},1,60,1},{{numberOfSlots,15},6,20,1},Delimiter,Row[{Button["Sort again",{r=RandomReal[]},Appearance->"Palette",ImageSize->{250,28}]}],ControlPlacement->Bottom]