Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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:

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.