Psor[u_,f_,n_,omega_,eps_]:=Module[{error,y,ni},
ni=0;
erroro=1.0;
While[error>eps*eps,
ni++;
error=0.0;
u[-n]=u[n]=0.0;
For[i=-n+1,i<n,i++,
y=(u[i-1]+u[i+1])/2.0;
y=Max[f[i],u[i]+omega*(y-u[i])];
error+=(u[i]-y)*(u[i]-y);
u[i]=y;
];
];
Print["error: ",error];
Print["ni: ",ni];
]

n=20;
h=2.0/(2n);
obstacle[x_]=Max[0,0.5-x^4];
Do[x[i]=i*h,{i,-n,n}];
Do[f[i]=obstacle[i*h],{i,-n,n}];
Do[u[i]=f[i],{i,-n,n}];

g1=Plot[obstacle[x],{x,-1,1},PlotStyle->{RGBColor[1,0,0],Thickness[0.005]}];
g2=ListPlot[Table[{x[i],u[i]},{i,-n,n}],PlotStyle->RGBColor[0,0,1]];
gi=Show[g1,g2,PlotRange->All]

omega=1.0;
eps=0.000001;
Psor[u,f,n,omega,eps]