+ 1
I need help solving my code problem
Hello there. I've recently written a program in which computer thinks and plays a game itself. When I run the code, it does a very good job, but after a few movements it stops working and python gives me an expression like"0x000078***" I've used recursive functions in my code.(I've maximized recursion depth) Could it be because of my old laptop system? Do you have any suggestions friends?
5 Réponses
+ 4
If you override the maximum recursion depth, and your function repeatedly calls itself, then it will keep consuming more and more memory until the system runs out of ram.
The best suggestion without seeing your code: try to rewrite it using an iterative method, ie. a while loop. Or make sure to contain your recursion within sane limits.
+ 3
Did you check if the function itself works correctly? Sometimes reaching the max. recursion depth is a sign that there is an issue with the function.
+ 2
Javad you can find a few ideas here
https://stackoverflow.com/questions/46552499/convert-recursive-function-into-a-for-loop-and-while-loop
But I can only really help you if I see the actual code.
+ 1
Lisa the thing is it works good for a few steps. So I don't think that there would be any problem with my function
0
Would you tell me how to apply a while loop to rewrite it?