I am creating a Tic-Tac-Toe game and was wondering how many combinations there are. I am an amateur coder and was going to code all the combinations by hand. Also if I do not do then what am I supposed to do? code in c# (using console)
Asked
Active
Viewed 293 times
-1
-
related https://math.stackexchange.com/questions/269066/game-combinations-of-tic-tac-toe – Henry Feb 08 '21 at 01:37
-
What exactly are you counting as a "combination"? Do you mean a pattern of X's and O's at the end of a move? If so, then there are $9$ possibilities at the end of the first move and $9\cdot8=72$ at the end of the second. After that it gets a little more complicated to count. (You might expect it to be $9\cdot8\cdot7=504$ at the end of the third, but it's really only $252$.) – Barry Cipra Feb 08 '21 at 01:39
-
There are only three types of squares (center, corner, and side) and eight possible sets of three-in-a-rows. At the start of the game the center square is a part of four of these, the corner squares are a part of three, and the side squares are a part of two. With each move, the remaining possible winning sets for each player change. At any decision point, you want to prevent opponent wins and maximize your opportunities for wins. I suspect (and am curious if) this is enough to code a game that plays perfectly. – David Diaz Feb 08 '21 at 01:53