subject

A two dimensional random walk simulates the behavior of a particle moving in agrid of points. At each step, the random walker moves north, south, east, or westwith probability14, independent of previous moves. Compose a program thattakes a command-line argumentnand estimates how long it will take a randomwalker to hit the boundary of a 2n-by-2nsquare centered at the starting point. How do I solve this?

So far i have the following:

import sys
import stdio
import random

# the size of the box, which should be 4
n = int(sys. argv[1])

# should be the amount of steps taken to reach the boundary/ end of the box.
c = int(sys. argv[2])

def random_walk_2D (n):
x, y = 0, 0
i = 4
North = 1; South = 2; West = 3; East = 4

for i in range(n):

people = random. randint(1,4)

while I < c:
stdio. write()

if people == 1:
y = y + 1
elif people == 2:
y = y - 1
elif people == 3:
x = x + 1
else :
x = x - 1
return (x, y)

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 17:30
Under which key category do the page up and page down keys fall? page up and page down keys fall under the keys category.
Answers: 1
question
Computers and Technology, 23.06.2019 00:00
What season was better from fortnite?
Answers: 2
question
Computers and Technology, 23.06.2019 06:00
When is a chart legend used a. all the time b. whenever you are comparing data that is the same c. whenever you are comparing multiple sets of data d. only for hand-drawn charts
Answers: 2
question
Computers and Technology, 23.06.2019 07:30
What is the original authority for copyright laws
Answers: 1
You know the right answer?
A two dimensional random walk simulates the behavior of a particle moving in agrid of points. At eac...
Questions
Questions on the website: 13722363