Variables mysteriously changing
in
Programming Questions
•
2 years ago
Hi folks,
I've got a problem with some code I can't seem to solve. I've narrowed it down to about one line of code, but don't know how to proceed.
Within a couple nested "for" loops within my "draw" function, I have the following code:
I've added in the "print" functions for diagnostic purposes. As you can probably tell "topshapes" and "nextshapes" are 2D arrays, and "shapes" is a 3D array. "i", "j", and "k" are variables that increment up by one in each of the "for" statements that the above code is contained within, and "u" is a random bit, and "v" is NOT(b), althought that might not be important.
Now, because nothing happens to change the value of any of the entries in the "topshapes" array between the two sets of "print" functions, you'd expect the output of the program to be something like this:
... 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 ...
A list of identical number with colons between them, which, most of the time it is. Sometimes, however, the output will look like this:
... 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 ...
The bolded part above implies to me that something has been done to change the value of an entry in the array "topshapes" between the two sets of print statements. Since there's no function that affects the value of "topshapes," though, I don't know how this can be.
Anyone have any thoughts? Any help would be much appreciated. I'm happy to provide more information if need be.
Thanks.
I've got a problem with some code I can't seem to solve. I've narrowed it down to about one line of code, but don't know how to proceed.
Within a couple nested "for" loops within my "draw" function, I have the following code:
- print(topshapes[1][1]);
- print(":");
- shapes[i][j][k] = topshapes[j][k]*u + v*nextshapes[j][k];
- print(topshapes[1][1]);
- print(" ");
I've added in the "print" functions for diagnostic purposes. As you can probably tell "topshapes" and "nextshapes" are 2D arrays, and "shapes" is a 3D array. "i", "j", and "k" are variables that increment up by one in each of the "for" statements that the above code is contained within, and "u" is a random bit, and "v" is NOT(b), althought that might not be important.
Now, because nothing happens to change the value of any of the entries in the "topshapes" array between the two sets of "print" functions, you'd expect the output of the program to be something like this:
... 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 79:79 ...
A list of identical number with colons between them, which, most of the time it is. Sometimes, however, the output will look like this:
... 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:152 152:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 148:148 ...
The bolded part above implies to me that something has been done to change the value of an entry in the array "topshapes" between the two sets of print statements. Since there's no function that affects the value of "topshapes," though, I don't know how this can be.
Anyone have any thoughts? Any help would be much appreciated. I'm happy to provide more information if need be.
Thanks.
1