• Register
0 votes
44 views

Problem :

I am trying to write my first program in Vpython and I have to make the simulation of mixing two gases. First I had the problem with borders, but now when my balls(that represents a gas particles) stay within a border there is the sth different wrong. After the few seconds I get the error, which is shown as below

return MovingTheBall(listOfBalls,(position[0]+choice([-1,0,1]),position[1]+choice([-1,0,1]),0),numCell,1)File "gaz.txt", line 138, in MovingTheBall
return MovingTheBall(listOfBalls,(position[0]+choice([-1,0,1]),position[1]+choice([-1,0,1]),0),numCell,1)File "gaz.txt", line 138, in MovingTheBall
return MovingTheBall(listOfBalls,(position[0]+choice([-1,0,1]),position[1]+choice([-1,0,1]),0),numCell,1) File "gaz.txt", line 130, in MovingTheBall
if positionTmp==listOfBalls[i].pos:
RuntimeError: maximum recursion depth exceeded while calling a Python object

Can somebody think of the way to simplify the function?

I run my function it while loop:

while 1:
rate(20)
for j in range(0,len(self.listOfBalls)):
self.listOfBalls[j].pos=poruszanie(self.listOfBalls,self.listOfBalls[j].pos,self.numCell,0)

 

7 5 2
3,870 points

1 Answer

0 votes

Solution :

It occurs because the call to poruszanie results in to another call to poruszanie, incrementing a recursion depth by 1. A second call results in another call to a same function. That keeps happening over and over again, each time incrementing a recursion depth.

Now, a usable resources of the program are limited. Each function call takes the certain amount of space on a top of what is called a stack. If a maximum stack height is reached, you get the stack overflow error.

9 7 4
38,600 points

Related questions

0 votes
3 answers 480 views
480 views
Problem : I am getting below error maximum recursion depth exceeded while calling a python object
asked Oct 21, 2019 peterlaw 6.9k points
0 votes
1 answer 37 views
37 views
Problem: I am new to python programming and I am little bit bit confused about some things like I wrote a code: def random(): a = random.randint (0, x+1) b = random.randint (0, y+1) c = random.randint (0, z+1) outer_function(a,b,c ... recursion depth exceeded while calling a Python object IndentationError: expected an indented block I am confused about those things, why is this error shown to me ?
asked Mar 22 LizzyM 6.1k points
0 votes
1 answer 1.1K views
1.1K views
Problem : I had to remove a +CompatEnvVars from following : SSLOptions +FakeBasicAuth +ExportCertData +CompatEnvVars +StrictRequire As it said it was an invalid command or something. So having removed that and following a instructions to a nail it get below error: ... maximum permissible length. (Error code: ssl_error_rx_record_too_long) I am very new to SSL, any advice on what is going wrong?
asked Jan 17 jwilliam 3.9k points
0 votes
2 answers 925 views
925 views
Problem : I am new to Py 3.5. This code was working properly in Python 2.7: with open(fname, 'rb') as f: lines = [x.strip() for x in f.readlines()] for line in lines: tmp = line.strip().lower() if 'some-pattern' in tmp: continue # ... code After upgrading to 3.5, I'm getting the: TypeError: a bytes-like object is required, not 'str'
asked Oct 22, 2019 peterlaw 6.9k points
0 votes
1 answer 4 views
4 views
Problem: hello Everyone, We are working on the firebase based real-time messaging application and we are encountering this error whenever we try to run our application. The compiler we are using is Xode11 and the language version is swift 5. Your valuable response is welcomed. Thanks
asked Oct 12 SapperIt 810 points