Log In  

Cart #31451 | 2016-10-22 | Code ▽ | Embed ▽ | No License

P#31452 2016-10-22 10:19 ( Edited 2016-10-24 15:25)

Needs a bit of work.

You are welcome to use my formula for unbeatable TIC-TAC-TOE.

Computer always goes first, in center. Label boxes from the top-left:
1, 2, 3
4, X, 6
7, 8, 9

Then when computer moves have it follow this table:

2, 1, 6
7, X, 3
4, 9, 8

So - if the player goes to square 4, then computer goes to 7.

Plays an unbeatable game and no need to even check if squares are already filled when computer moves. Just look for valid win.

Hope This Helps !

P#31480 2016-10-22 17:11 ( Edited 2016-10-22 21:11)

"Unbeatable" isn't fun, though. The trick is to make it challenging and competent, but not totally unbeatable.

P#31651 2016-10-24 07:20 ( Edited 2016-10-24 11:20)

It's just a formula, Tony. Looking at the source - he (she?) might not know how to write one that schemes and plans moves ahead.

Still - that is definitely something to learn. Get that brain a-going ! :)

P#31661 2016-10-24 11:25 ( Edited 2016-10-24 15:25)

[Please log in to post a comment]