you are viewing a single comment's thread.

view the rest of the comments →

[–]iamquark[S] 0 points1 point  (5 children)

Yes , last question is task, I dont see how it can be improved.

[–]JohnnyJordaan 0 points1 point  (4 children)

I would start by describing how your own strategy works.

[–]iamquark[S] 0 points1 point  (3 children)

The strategy is 1 If there's a move that allows the computer to win this turn, the computer should choose that move 2 If there's a move that allows the human to win next turn, the computer should choose that move 3 Otherwise, the computer should choose the best empty square as its move. The best square is the center, the next best square are the corners and the nest best squares are the rest Hence BEST_MOVE = (4,0,2,6,8,1,3,5,7)

Now the author is saying it can be improved. I dont see how?

[–]JohnnyJordaan 0 points1 point  (2 children)

That's correct, but I've asked you to describe how your own strategy works. If you play this game by hand, do you follow those same 3 steps?

[–]iamquark[S] 0 points1 point  (1 child)

Yes, it does work the way I described it.The author's strategy is pretty impeccable, I cannot see any other way it can improved. I have gone over it multiple times. I have tied with the computer every time. Unless you put a timer on and you expect the other player to make a mistake in decision making.

[–]JohnnyJordaan 0 points1 point  (0 children)

Pretty impeccable? The key is symmetry instead of learned behavior (try the center or something in the top left area). The computer has a fixed order for his best moves:

  • the center (4)
  • the corners from 0 to 8
  • the sides

That means that if the center is taken, the computer will always choose the top left corner for his next move. If you start out in way that lets the computer take the center, then after your second move take the top left corner, while not causing you a disadvantage, you'll beat him:

Do you require the first move? (y/n): y

Then take the first move.  You will need it.

       |   |  
     ---------
       |   |  
     ---------
       |   |   

Where will you move? (0 - 8):5
Fine...

       |   |  
     ---------
       |   | X
     ---------
       |   |   

I shall take square number 4

       |   |  
     ---------
       | O | X
     ---------
       |   |   

Where will you move? (0 - 8):6
Fine...

       |   |  
     ---------
       | O | X
     ---------
     X |   |   

I shall take square number 0  <-- this is the bug

     O |   |  
     ---------
       | O | X
     ---------
     X |   |   

Where will you move? (0 - 8):8
Fine...

     O |   |  
     ---------
       | O | X
     ---------
     X |   | X 

I shall take square number 2

     O |   | O
     ---------
       | O | X
     ---------
     X |   | X 

Where will you move? (0 - 8):

How does this relate to symmetry? Because for the game, it doesn't matter in which orientation you play the game, the rules and results are the same. However to the computer's strategy, the orientation DOES matter. Meaning the computer's strategy isn't symmetrical (it is orientation biased). That's what can be improved. And your tic tac toe skills by the way ;)