Tic Tac Toe - Finding Empty Grid Tiles
This is a continuation of my previous question regarding the tic tac toe game. I am making a function that will collect all the empty grid tiles of a tic tac toe board, and return
Solution 1:
A recursive strategy might not be best in this scenario. Consider the example you yourself provided:
<------->
< X O - >
< - - X >
< O X - >
<------->
Suppose the next move was made in the middle tile. If the recursive function checks only the four tiles adjacent to it, then it would miss the tile that was "cut off" from the rest (the bottom right one). And if you were to write a function to check all 8 adjacent tiles (including diagonally adjacent) you might as well write it iteratively.
for i inrange(3):
for j inrange(3):
pass# Replace with code to add empty tile to list
Post a Comment for "Tic Tac Toe - Finding Empty Grid Tiles"