Creating function that generates random positions.