I'm not new to programming, however I am new to Python.
To learn python, I've decided to make an AI for tic tac toe (or knots and crosses).
I've come pretty far, using different techniques of programming. I'm currently a bit stuck.
I have the following variables:
To reduce size, instead of setting them individually, I want to itterate through the variables and setting to a certain value, like the following:
Result:
However this does not work because "I can't assign eval to function call."
I've tried to Google the answer, but it only showed how I can use the eval function on the other side of the equal sign.
Please help,
W.
To learn python, I've decided to make an AI for tic tac toe (or knots and crosses).
I've come pretty far, using different techniques of programming. I'm currently a bit stuck.
I have the following variables:
1 |
(pos1, pos2, pos3 ... pos7, pos8 ,pos9): |
1 2 |
for i in range ( 1 : 9 ): eval ( "pos" + str (i) = i |
1 2 3 4 5 6 7 8 9 |
pos1 = 1 pos2 = 2 pos3 = 3 . . . pos7 = 7 pos8 = 8 pos9 = 9 |
I've tried to Google the answer, but it only showed how I can use the eval function on the other side of the equal sign.
Please help,
W.