Off[General::spell1];
xmin=-20;
xmax=10;
delta=0.1;
fcekhledani[x_]=(Table[{x,0.1(((x+.5Random[]))^4)+(((x+5Random[]))^3)-10(((x+5Random[]))^2)+100(x+5Random[])+20Random[]},{x,xmin,xmax,delta}]//Interpolation)[x];
(*fcekhledani[x_]=(((x-5))^2);*)
Plot[fcekhledani[x],{x,xmin,xmax},PlotPoints->1000,PlotRange->All,AxesLabel->{"x","f[x]"}]

k=5000;deltax=1;T0=100;pocetiteraci=15000;
T[i_]=((T0*k)/(i+k));
Plot[T[i],{i,1,pocetiteraci},AxesLabel->{"i","T[i]"}];
p[i_,deltaW_]=Exp[((-deltaW)/(T[i]))];
xdal[listik_]:=Module[{xtry,dW,xminule,i},xminule=listik[[2]];i=listik[[1]];xtry=Random[Real,{xminule-deltax,xminule+deltax}];dW=fcekhledani[xtry]-fcekhledani[xminule];pravd=p[i,dW];{i+1,If[dW<0,xtry,If[pravd>Random[],xtry,xminule]]}];
vyslednylist=NestList[xdal,{0,1},pocetiteraci];
ListPlot[%/.{a_,b_}->{a,fcekhledani[b]},PlotRange->All]
(vyslednylist//Last)/.{a_,b_}->{a,fcekhledani[b]}
FindMinimum[fcekhledani[x],{x,xmin/2,xmax/2}]