Back to top

Minesweeper

This is a description of the “Minesweeper Clone” API.

Game API

Resource

POST/games

Create a new game

Parameters
HideShow
difficulty
number (required) Example: 1

Permitted values are:

  • 0 (Easy - 8x8, 10 mines)

  • 1 (Intermediate - 16x16, 40 mines)

  • 2 (Expert - 24x24, 99 mines)

Response  201
HideShow
Headers
Content-Type: application/json
Body
{
  "id": 1,
  "board": [
    [
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " "
    ],
    [
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " "
    ],
    [
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " "
    ],
    [
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " "
    ],
    [
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " "
    ],
    [
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " "
    ],
    [
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " "
    ],
    [
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " "
    ]
  ],
  "state": "new",
  "mines": 10
}

Resource

GET/games/{id}

Retrieve an already created game.

The state will be one of "new", "playing", "won", or "lost".

Cell values:

  • (empty space) An unrevealed cell

  • _ An empty revealed cell

  • F An unrevealed flagged cell

  • * A cell with a bomb in it (only show after a game is won or lost)

  • @ A flagged cell with a bomb in it (only show after a game is won or lost)

  • 1-8 The number of neighboring cells that contain a mine.

Parameters
HideShow
id
number (required) Example: 1

The unique ID for the game

Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "id": 1,
  "board": [
    [
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " "
    ],
    [
      " ",
      " ",
      "1",
      "2",
      "1",
      "F",
      " ",
      " "
    ],
    [
      " ",
      "1",
      "_",
      "_",
      "_",
      "2",
      " ",
      " "
    ],
    [
      " ",
      "1",
      "_",
      "_",
      "_",
      "1",
      " ",
      " "
    ],
    [
      " ",
      " ",
      "1",
      "_",
      "_",
      "2",
      " ",
      " "
    ],
    [
      " ",
      " ",
      " ",
      "1",
      "1",
      " ",
      " ",
      " "
    ],
    [
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " "
    ],
    [
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " "
    ]
  ],
  "state": "new",
  "mines": 9
}

Resource

POST/games/{id}/check

Parameters
HideShow
id
number (required) Example: 1

The unique ID for the game

row
number (required) Example: 5

The horizontal row the player is checking (zero based index).

col
number (required) Example: 7

The vertical column the player is checking (zero based index).

Request
HideShow
Headers
Content-Type: application/json
Body
{
  "row": 4,
  "col": 3
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "id": 1,
  "board": [
    [
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " "
    ],
    [
      " ",
      " ",
      "1",
      "2",
      "1",
      "F",
      " ",
      " "
    ],
    [
      " ",
      "1",
      "_",
      "_",
      "_",
      "2",
      " ",
      " "
    ],
    [
      " ",
      "1",
      "_",
      "_",
      "_",
      "1",
      " ",
      " "
    ],
    [
      " ",
      " ",
      "1",
      "_",
      "_",
      "2",
      " ",
      " "
    ],
    [
      " ",
      " ",
      " ",
      "1",
      "1",
      " ",
      " ",
      " "
    ],
    [
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " "
    ],
    [
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " "
    ]
  ],
  "state": "playing",
  "mines": 9
}

Resource

POST/games/{id}/flag

Parameters
HideShow
id
number (required) Example: 1

The unique ID for the game

row
number (required) Example: 5

The horizontal row the player is flagging (zero based index).

col
number (required) Example: 5

The vertical column the player is flagging (zero based index).

Request
HideShow
Headers
Content-Type: application/json
Body
{
  "row": 5,
  "col": 5
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "id": 1,
  "board": [
    [
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " "
    ],
    [
      " ",
      " ",
      "1",
      "2",
      "1",
      "F",
      " ",
      " "
    ],
    [
      " ",
      "1",
      "_",
      "_",
      "_",
      "2",
      " ",
      " "
    ],
    [
      " ",
      "1",
      "_",
      "_",
      "_",
      "1",
      " ",
      " "
    ],
    [
      " ",
      " ",
      "1",
      "_",
      "_",
      "2",
      " ",
      " "
    ],
    [
      " ",
      " ",
      " ",
      "1",
      "1",
      "F",
      " ",
      " "
    ],
    [
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " "
    ],
    [
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " ",
      " "
    ]
  ],
  "state": "playing",
  "mines": 8
}

Generated by aglio on 07 Oct 2015