Login
Forgot Password?

OR

Login with Google Login with Twitter Login with Facebook
  • Join
  • Profiles
  • Groups
  • SuicideGirls
  • Photos
  • Videos
  • Shop
Vital Stats

grayness

Member Since 2006

Followers 97 Following 199

  • Everything
  • Photos
  • Video
  • Blogs
  • Groups
  • From Others

Saturday Nov 07, 2009

Nov 7, 2009
0
  • Facebook
  • Tweet
  • Email
Algorithm for playing Tic-Tac-Toe

Take a tic-tac-toe square, and value the squares as follows:


2|1|2
_____
1|3|1
_____
2|1|2


For each possible square you can pick in a move, add the values for each full row, column, or diagonal that it is on (a "full" row or diagonal means having 3 squares, occupied or not), adding 2 for each marker of your own on that row, column, or diagonal, and 1 for each marker of your opponent on that row, column, or diagonal. Then multiply by -1 for each opponent's marker on that row, column, or diagonal [*]. Take the square with the highest value; choose randomly among squares when there are ties for highest value.

So, initially, before any markers are placed, the cells will have the values:


17|10|17
________
10|24|10
________
17|10|17



The center, having a value of 24, will always be taken first.

| |
_____
|X|
_____
| |


The proper response for O, looking at the values:
Upper Left Square:
Add left column: 2+1+2 = 5
Add top row: 2+1+2 = 5
Add diagonal: (2+3(for square)+1(for opponent marker on square)+2) x -1 = -8
5+5-8 = 2

Upper Middle Square:
Add top row: 2+1+2 = 5
Add center column: (1+3(for square)+1(for opponent marker on square)+1)x-1= -6
5-6 = -1

Upper Right Square:
Add right column: 2+1+2 = 5
Add top row: 2+1+2 = 5
Add diagonal: (2+3(for square)+1(for opponent marker on square)+2) x -1 = -8
5+5-8 = 2

Middle Left Square:
Add left column: 2+1+2 = 5
Add middle row: (1+3(for square)+1(for opponent marker on square)+1)x-1= -6
5-6 = -1

Middle Right Square:
Add right column: 2+1+2 = 5
Add middle row: (1+3(for square)+1(for opponent marker on square)+1)x-1= -6
5-6 = -1

Lower Left Square:
Add left column: 2+1+2 = 5
Add bottom row: 2+1+2 = 5
Add diagonal: (2+3(for square)+1(for opponent marker on square)+2) x -1 = -8
5+5-8 = 2

Lower Middle Square:
Add bottom row: 2+1+2 = 5
Add center column: (1+3(for square)+1(for opponent marker on square)+1)x-1= -6
5-6 = -1

Upper Right Square:
Add right column: 2+1+2 = 5
Add bottom row: 2+1+2 = 5
Add diagonal: (2+3(for square)+1(for opponent marker on square)+2) x -1 = -8
5+5-8 = 2

So, since any of the corners have a value of 2, which is the highest value, randomly pick one.


And so on.




Yeah, the things I do for fun on Saturday... wild, huh? wink

If you see a hole in my algorithm, point it out, I just did it while sitting here, but it looks good to me...




[*] you'll note that means that two markers of the opponent cancel out each other's multiplication effect. smile
VIEW 5 of 5 COMMENTS
tiger_fodder:
Ah the 50s...before Civil Rights and Macs. No...I prefer it now.
Nov 8, 2009
tiger_fodder:
I'm glad that I wasn't drafted for the Battle of Hastings. I was busy smoking hash with all the hippies in York. We fled to Ireland for a bit, until we could come back. The worst part was that we had to learn that damned French language to keep up with the Norman chicks.
Nov 8, 2009

More Blogs

  • 04.04.16
    4

    Back?

    At least enough to stick my head in, and take a look around.
  • 11.28.13
    5

    Not much of a century, apparently...

    Farewell, ISON: we barely knew ye.
  • 11.17.13
    3

    It ain't necessarily so...

    The tongue of an ungrateful child may be sharper than a serpent's t…
  • 10.14.13
    3

    When In Rome

    It's not quite home, but it will do And if you ask I'd say i…
  • 10.01.13
    1

    Wednesday Oct 02, 2013

    Down, down, o form of gray- For Etrigan has come to stay! SPOILERS…
  • 09.25.13
    1

    Thursday Sep 26, 2013

    Sick Day Sniffling, sneezing, snuffling snot- All these SN's a misera…
  • 08.04.13
    5

    Sunday Aug 04, 2013

    Asked or not, it's much the same- No, I will not give my name. Al…
  • 07.10.13
    7

    Thursday Jul 11, 2013

    Nothing points out the folly of men like giant radioactive lizards.
  • 06.27.13
    9

    Thursday Jun 27, 2013

    I have a firm belief that one should always forgive one's enemies... …
  • 05.12.13
    10

    Monday May 13, 2013

    Nutshell Theatre ...presents... The Adventures of Huckleberry Finn SP…

We at SuicideGirls have been celebrating alternative pin-up girls for:

23
years
11
months
18
days
  • 5,509,826 fans
  • 41,393 fans
  • 10,327,617 followers
  • 4,608 SuicideGirls
  • 0 followers
  • 14,962,722 photos
  • 321,315 followers
  • 61,498,201 comments
  • Join
  • Profiles
  • Groups
  • Photos
  • Videos
  • Shop
  • Help
  • About
  • Press
  • LIVE

Legal/Tos | DMCA | Privacy Policy | 18 U.S.C. 2257 Record-Keeping Requirements Compliance Statement | Contact Us | Vendo Payment Support
©SuicideGirls 2001-2025

Press enter to search
Fast Hi-res

Click here to join & see it all...

Crop your photo