Please see my comment to the question. This is already a solution, but I'm not sure you can understand it, taking into account your very confused design attempt.
You never need need a sequence of 0.. 1 numbers at all. You need either 1, for one player, or 0, for another one, never a sequence, without any randomization. Who supplies the data for next move, depends on your mode: human against human, machine against machine and human against machine.
What can be random is the coordinate of next move: x: 0.. 2 and y: 0.. 2, for classical 3x3 configuration. You should generate (in certain mode) this number as random, in this range, but then you should checkup if the cell is already busy and try again if it is.
However, all this random play is boring and makes no sense. Your machine player can play purely rationally, using the best algorithm, which is trivial and is always winning for the first-move player. This algorithm is easily figured out by any adult player having brains. You can do it, too.
There is another approach: self-learning algorithm. The machine is player randomly at first, and then, taking into account the level of each failure/success, gives "bad" path low priority, finally deriving perfect algorithm. The solution for such self-learning was described by American popular science writer
Martin Gardner, many, many years ago; I learned when I was a school child.
—SA