Is there a way to check where my code stops? (Output not printing)

I made a code for an AI and sometimes it stops working, but no error is displayed on Output window, so I think it’s yielding or looping somewhere. I usually type print(“Line x”) every line to check where the problem is but It would take too much time to type that 700 times. Is there a faster way to do something like this?

You can use breakpoints to identify code snippets that are and aren’t being run.

Try tracing your algorthims, from the start (not every line, but whenever a snippet of code is run such as an if statement or a for loop) and progressing through where you think the code should be going at each stage. When you stop getting prints or breakpoints, you know the program either isn’t getting there or is being diverted somewhere else (potentially by a logic error in an if-statement or something).

Hope this helps,
-Tom :slight_smile:

2 Likes

Thanks, I think I found the problem using this method. I am not sure it’s fixed as it happens rarely but I’ll try spamming the script to see if it happens again.

1 Like