ConnectNAI

The ConnectN AI service allows you to create games like Connect-4 or Tic-Tac-Toe and play against an AI that improves over time.

RPCS

ConnectNAI.getAIMoves(player: Enum<Player1, Player2>)

Gets the AI to suggest the next best move for the specified player.

Arguments:

  • player: Enum<Player1, Player2> (Enum) - The player to make the recommendation for.

Returns: List<Tuple<Number, Integer, Integer>> (List | Tuple | Number | Integer) - A list of recommended moves, each being [value, row, column]. These are already sorted in descending value, so the recommended move is the first one.

ConnectNAI.makeMove(row: Integer, col: Integer, player: Enum<Player1, Player2>)

Makes a move for the specified player.

Arguments:

  • row: Integer (Integer) - The row to play at.

  • col: Integer (Integer) - The column to play at.

  • player: Enum<Player1, Player2> (Enum) - The player to make the move for.

Returns: Tuple<Integer, Integer, Enum<ok, win, tie>> (Tuple | Integer | Enum) - Location (row/column) and result of the move. The location may not be the same as the input if gravity is enabled (see newGame).

ConnectNAI.newGame(rows: BoundedInteger<3, 10>, cols: BoundedInteger<3, 10>, n: BoundedInteger<3>, gravity: Boolean)

Starts a new game with the existing AI session.

Arguments:

  • rows: BoundedInteger<3, 10> (BoundedInteger) - The number of rows in the game

  • cols: BoundedInteger<3, 10> (BoundedInteger) - The number of columns in the game

  • n: BoundedInteger<3> (BoundedInteger) - The number of consecutive pieces needed to win

  • gravity: Boolean (Boolean) - Whether or not to use gravity when placing pieces, which makes them fall down to the lowest unoccupied row in the column

ConnectNAI.newSession()

Creates a new AI session. This has the effect of resetting the AI to the point of knowing nothing about the game.

ConnectNAI.useMaxDifficulty()

Sets the current session’s AI to the maximum difficulty.