• Register
0 votes
49 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

Please log in or register to answer this question.

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 581 views
581 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 50 views
50 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, 2020 LizzyM 6.1k points
0 votes
1 answer 3 views
3 views
Problem: I'm new to programming and started with Python about two months ago and am going over Sweigart's Automate the Boring Stuff with Python text. I'm using IDLE and already installed the Selenium module and the Firefox browser. Whenever I tried to run the webdriver function, I get this: from selenium import webdriver browser = webdriver.Firefox()
asked Jan 6 Mashhoodch 6.7k points
0 votes
1 answer 1.9K views
1.9K 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, 2020 jwilliam 3.9k points
0 votes
1 answer 3 views
3 views
Problem Hey, I need help from you. Is there any way to call python from java. I mean how can we run a python program from java.
asked Jan 16 chris jordan 2.2k points
0 votes
1 answer 3.7K views
3.7K views
Problem : I am new to Python and Tensorflow so I just simply typed the following code : import tensorflow as tf print(tf.__version__) # Build a dataflow graph. c = tf.constant([[1.0, 2.0], [3.0, 4.0]]) d = tf.constant([[1.0, 1.0], [0.0, ... the ' RuntimeError: The Session graph is empty. Add operations to the graph before calling run(). Process finished with exit code 1 How can I fix this error?
asked Nov 21, 2019 peterlaw 6.9k points
0 votes
1 answer 5 views
5 views
Problem Hey, want to ask you how to resolve an error named Run Time Error ‘2501’. Can someone help me to fix this error. The Report is called through this code Private Sub Command92_Click()     DoCmd.SetWarnings Off     ''# get ... ", acNormal     DoCmd.GoToRecord acDataForm, "NewReqVersionForm", acLast End Sub Private Sub StatusID_Change()     Me.LastModifiedTimeStamp = Now() End Sub
asked Jan 13 chris jordan 2.2k points
0 votes
1 answer 5 views
5 views
Problem: What is the difference between compile time error and runtime error?
asked Dec 20, 2020 prog_learner 2.5k points
0 votes
1 answer 12 views
12 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, 2020 SapperIt 1.2k points
0 votes
1 answer 105 views
105 views
I have been stuck to sort out this issue for a long time and even after reading a number of posts. Can some one help to sort out this issue and give me the reason why this is happening in this case?
asked Sep 14, 2020 Daniel Anderson 4k points