Git Tac Toe - TheEvergreenStateCollege/upper-division-cs-23-24 GitHub Wiki
X makes the first move
I created two separate code spaces to simulate two computers. Then O makes their first move:
since I haven't pushed the changes, the code space for X doesn't automatically recieve the changes:
So back in the O code space: I add the changes using git add, commit the changes using git commit, and push them using git push
--I forgot to push the changes, so it didn't work right away.
Back in the main repo the changes have been added:
now, back in the second other repo, I want to pull the changes:
I continue this cycle till the game is complete...
Tie game.
Finally, I want to go back to replay the game from a different point.
Now I've checked out the commit, so I'm working on an older version. I'm going to create a new branch from this point:
When I go to push my new (redo) move I get this error:
Can I create separate branches on github? Or do I need to push this back to the original branch?
Yes. I created a separate branch called redo using the command: git push --set-upstream origin redo
- I don't believe there is a winning strategy to tic tac toe. The only ways I can see someone winning is if their opponent is bad, or if they convince their opponent to lose on purpose.
I believe that the best move is to take the center square because it runs through all but 4 lines. I.e. you have more options and your opponent has less. However, even if you get the center square your opponent can prevent a win.
- I looked it up and apparently if you start in a corner AND your opponent doesn't go in the center, then you can win every time. This seems to have the same problem as the solution I proposed because you rely on your opponent not knowing they need to take the center square. This may increase the chance to win early, but after a game or two your opponent will see through it every time.
pseudo code: if (first) { pick a random number 1-4. Each number is a signed a switch case assigned to a corner (optional) --alternatively you could always pick the same corner, or cycle through an array or list
else { if (opponent takes corner) { take center square }