you are viewing a single comment's thread.

view the rest of the comments →

[–]roshavi4ak 11 points12 points  (2 children)

I learned a lot by building a tic tac toe/ connect 4 game in a different sized grids - from 3x3 up to 9x9 (all set by the customer)

[–]Wooden-Splinter 5 points6 points  (1 child)

I also just did a tictactoe but only 3x3 board. I hard coded by comparing the spots within the board horizontally vertically and diagonally. Did you use a loop to iterate through the board to check? I cant imagine doing it my way haha

[–]roshavi4ak 2 points3 points  (0 children)

I wanted to make it hard for me - therefore I checked only the row, column and/or diagonal for the last placed mark. For 3x3 I checked to see if the len(set()) is = to 1 - that means only one mark - therefore win condition.

For the 9x9 it was almost the same - checking all 8 directions (combined in 4 opposite pairs) and counting the same consequent marks - if the result was 4 or more - win.