Mine Hunter

Mine Hunter pits the AI against a minefield! A known quantity of mines has been distributed across a grid of squares and the AI agent must work out where they are. To help, each uncovered square will show how many mines are in the surrounding squares.

The grid is represented as an array of characters:

CharacterDescription
FA flagged mine
fAn incorrectly flagged empty space (game over)
#A convered square
XAn exploded mine (game over)
.An uncovered square with no neighbouring mines
1-8An uncovered square with n neighbouring mines

and organised in a two dimentional array (with 0,0 at the top left).

Example board

JSON Representation

"board": [
    "#1",
    "#1",
    "11"
  ]

XML Representaion

<board>#1</board>
<board>#1</board>
<board>11</board>

Note: in this example the correct response would be to place a flag at 0,1.

Goal

Write an AI agent that can solve as many boards as possible, this can be measured by a moving average which is shown on the output.

Algorithms and Hints

There are quite a few algorithms that can be used to solve this scenario:

API Interface

The Swagger specification for this API can be downloaded here.

In each step, the Sandbox Client will send the following information to the AI server:

The AI agent should respond with one or more moves, each move consists of:

Note: there is no limit to the number of moves that can be included in each response. However if a move results in the game ending, subsequent guesses will be ignored rather than carried over to the next game.

JSON Example Request

{
  "lastMove": {
    "boardID": "1233-5678-90abc-2435",
    "result": "LOST"
  },
  "boardID": "1234-1234-1234-1234",
  "board": [
    "##1..",
    "##1..",
    "221..",
    "#1..."
  ],
  "flagsRemaining": 3
}

JSON Example Response

{
  "moves": [
    {
      "x": 1,
      "y": 1,
      "flag": true
    }
  ]
}

XML Example Request

<?xml version="1.0" encoding="UTF-8"?>
<MineRequest>
   <lastMove>
      <boardID>1233-5678-90abc</boardID>
      <result>LOST</result>
   </lastMove>
   <boardID>1234-1234-1234-1234</boardID>
   <board>##1..</board>
   <board>##1..</board>
   <board>221..</board>
   <board>#1...</board>
   <flagsRemaining>3</flagsRemaining>
</MineRequest>

XML Example Response

<?xml version="1.0" encoding="UTF-8"?>
<MineResponse>
    <moves>
        <x>1</x>
        <y>1</y>
        <flag>true</flag>
    </moves>
</MineResponse>