January 17, 2015

Week of 01/11/15 - Python Part 16: A New Year, an Old Project

     Now that we are in the new semester, I think it's time I began working on the tic tac toe game again. I want to finish it, without the time constraint of a midterm. I began by renaming a few variables, and reading through my code to figure out what I was doing two week ago. I began to write code to actually play the game in turns, when I realized I could save a lot of time by writing a function for taking turns. What it does is it increments the turn number, finds out which player should be playing, prints the board,. It then prints the board with the column numbers highlighted and prompts for input for the column number, and does the same for the row number. However, while writing and testing the turn function, I ran into an error where it said "int object not callable". I couldn't figure out what was causing this, but adding a few variables as arguments into some functions and renaming a few variables seems to have fixed the problem. Another thing I had to do was move some global variables into the functions file, because apparently I can't use the variables as arguments without them being in the same file. After I'm done, I'll probably re-merge the files just so the code is all in one place. Currently they're separated for organizational purposes.

     Next, what I did was put the inputs into loops, so that the game wouldn't keep playing if the player input the letter "a" instead of a coordinate. All of this took a while to do, but finally, the player can take turns and input coordinates.

No comments: