I'm trying to implement a random walker in python.But I want to set a random starting point instead of initialize the first position.how can i set a random starting point?
Asked
Active
Viewed 116 times
2 Answers
1
I don't know how you structured the code but generally it does this:
import random
x = random.randint(Min_x,Max_x)
y = random.randint(Min_y,Max_y)
[your loop code...]

Ro0t
- 179
- 8
1
Stackoverflow is not here to solve your homework, I do however hope you're trying to achieve this in your free time, so here is the answer:
Use the random
module like that to generate a random point as your starting point:
import random
x_start = random.randint(0,width)
y_start = random.randint(0,height)
Based on the poor details you provided, I can not give a more in-depth answer to your question. You might need to adjust the code, so that it fits your screen's coordinate system.

frankenapps
- 5,800
- 6
- 28
- 69