Code for stocastic search, solving z = x^2 + y^2