Manipulate[Block[{a,$RecursionLimit=25000,w=h},per[{i_,j_},col_]:=If[1≤i≤w&&1≤j≤h&&a[[i,j]]==1,a[[i,j]]=col;
per[{i,j}+#,col]&/@{{1,0},{0,1},{-1,0},{0,-1}}];SeedRandom[seed];a=Map[Boole[#<p]&,RandomReal[{0,1},{w,h}],{2}];
a[[All,1]]=a[[All,h]]=1;Do[per[{i,1},2],{i,w}];b=0;Do[If[a[[i,h-1]]==2,b=1],{i,w}];Do[per[{i,h},3],{i,w}];
ArrayPlot[Transpose[a],ImageSize->450,Mesh->True,ColorRules->{0->White,1->Darker[Blue],2->If[b==0,Red,Yellow],3->If[b==0,Green,Yellow]}]],{{p,.2,"probability"},0,1,0.01,Appearance->{"Labeled","Open"}},{{h,40,"size"},5,100,1,Appearance->"Labeled"},{{seed,40,"seed"},1,100,1,Appearance->"Labeled"},AutorunSequencing->{{1,30},{2,10}},TrackedSymbols:>Manipulate]