WesleyyC / Tic-Tac-Toe

A perfect Tic Tac Toe player using the strategy in Newell and Simon's 1972 tic-tac-toe program

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Winning the Computer...

SerinaTan opened this issue · comments

Follow these coordinates and the user is able to win the computer...
0,2
2,1
1,0
0,0
2,0

I am suspecting something is messed up in fork... Still investigating.

My version, "the refactor" commit, works fine with the following coordinate.

Actually, @SerinaTan is right. Both of your files tic_tac_toe.py (the one inside folder pi and the one in front of your repository) have the same bug.

Look here is my screenshot:https://imgur.com/q9pcFw2

If you don't mind the give advicen , you should take a look at "Combinatorial Games :: Tic Tac Toe Theory" by Beck. I am also implementing a Tic-Tac-Toe game(mostly like an engine) and I spent some time researching the current AI implementations.

You should look into "hashing" your cells,moves,board etc. and use a transposition table. Also, you might want to look using a Alpha-beta prunning algorithm(its better than min max) for your AI. If you ever implement more than the basic 3x3 and more than 2 dimensionals. Look into the pairing strategy or stealing strategy in that book I showed you. It is a lot of math though!

Hey @SerinaTan , I think @IAlwaysBeCoding is right. I yield the same result and win the program.

I have also checkout a previous branch, before any of your commit and still report the same result, so there might be something with our computation component.

And, @IAlwaysBeCoding , thank you for the advice! The book looks quiet interesting and I have put it in the repo rsc folder!

No, problem my math is not as strong so I had problems understanding the math formula for the pairing strategy. The pairing strategy is basically a Hales-Jewett pairing where each cell has a pair that you can use to place a mark if the opponent player marks the other pair. This leads to a 100% draw scenario, but the pairing strategy is only applicable if the number of cells is more than the number of lines. In other words for 2-Dimensional 5x5 is the first game where you can use a pairing strategy. There are a few pictures online that show you a picture of that pairing for the game 5x5, but I couldn't find a code sample to use only math formulas. So, this leads me to hard coding the pair instead of making a function/class that can do the pairing. I can show you the page where it has the pairing strategy on the book and maybe you could figure a simple function that can do it. Also, I have more tic tac toe related papers lol I spent 2 weeks researching tic-tac-toe. I was going to make 3 and 4d tic-tac-toe modes too but I stuck with only 3x3,4x4,and 5x5 2-d for now.

Yea... I will spend more time on fully understanding the algorithm and fixing the bug over the weekend. As I mentioned before, I really think we need to create a suite of test cases, so that we don't have to be so scared of breaking stuff while making new changes. Plus, it would be beneficial if you guys want to try out completely different algorithms. But... I guess that also depends on how much time we have LOL

Anyways, I am hoping to fix the bugs I discovered this week and start working on the Raspberry Pi part haha.

That looks good! <3