Skip to content

Instantly share code, notes, and snippets.

@abunsen
Last active August 29, 2015 14:21
Show Gist options
  • Save abunsen/71b89ab8d8ea9889d593 to your computer and use it in GitHub Desktop.
Save abunsen/71b89ab8d8ea9889d593 to your computer and use it in GitHub Desktop.
TicTacToe spec

So I built an algorithm that tries to lose tictactoe no matter what. If you'd like to battle your algorithm against mine, I think it would be fun. This is the spec of what your server should accept & return. If you built an algorithm that can beat it, please tweet me @bunsen.

Your server should accept GET requests with the following parameters:

  • row
  • col
  • mark
  • grid - will be a url encoded array, like this: [["x",%20"x",%20nil],%20[nil,%20nil,%20"o"],%20[nil,%20"o",%20nil]]

It should return JSON that looks like this:

{
    "row": 1,
    "col": 0,
    "grid": [
        ["x", "x", null],
        ["o", "x", "o"],
        [null, "o", null]
    ]
}

Where row & col are your response moves & grid is how the game looks to you after your move.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment