There are several possible causes for arbitrary numbers in a Python game where values are added and subtracted. Here are a few things to check:
Make sure that you are using consistent data types when doing calculations. For example, if you are adding an integer and a float, Python will convert both values to floats, which could lead to unexpected results.
Check that you are initializing variables correctly. If you don't initialize a variable before using it, it will have an arbitrary value that could affect your calculations.
Make sure that you are not modifying variables outside of the scope where they are defined. This can happen if you accidentally reuse variable names or forget to pass variables as arguments to functions.
Check that you are not accidentally modifying immutable objects. For example, if you try to modify a string or a tuple, Python will create a new object rather than modifying the existing one.
Consider adding print statements to your code to help you debug. Print out the values of variables at different points in the code to see if there are any unexpected changes or inconsistencies.
By following these steps and carefully examining your code, you should be able to track down the source of the arbitrary numbers in your game.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-10-11 11:00:00 +0000
Seen: 8 times
Last updated: May 20 '21
How can I set up Gunicorn with a Django Project?
Looking for a Python Module that finds Tags for a Text describing its Content
Need a Function in Python to remove entries less than 2 digits from an Array
How can I convert a Document in Python?
How can I program a Loop in Python?
How can I enable Python Code Highlighting in Askbot?