Skip to content

Prismata AI Executable

David Churchill edited this page Mar 20, 2020 · 14 revisions

Replacing the Prismata AI Executable

The Prismata AI system operates completely separately from the rest of the retail game, with each copy of the game coming with a separate AI executable that is called from within the client to perform AI decision making. With the release of this project, it is possible for you to create your own AI system, make a new AI executable, and distribute this to others to play against within the official Prismata game client.

How the Current Prismata AI Works

As the Prismata AI is a standalone executable, it must communicate somehow with the Prismata game client, and this is currently done via standard IO channels. Here is what happens whenever the AI system is called:

  1. The AI executable is run and fed a single string in JSON format via std::cin. This string is in JSON format, and contains the following:
    • The CardLibrary data, describing all of the CardType types in the current game
    • The AIParameters configuration file, describing the custom AI parameters used by the client
    • The GameState description, detailing the current game state that the AI must decide a move for
  2. The AI executable calls AITools::InitializeAIAndGetAIMove(str) which reads the input string, and
    1. Calls AITools::InitializeAI(str) to initialize the CardType data library so the engine can function
    2. Calls Prismata::InitFromMergedDeckJSON(json) to initialize CardType data values
    3. Calls AIParameters::Instance().parseJSONValue(json) to initialize the AI parameters
    4. Calls AITools::GetAIMove(str) which constructs the game state and returns the AI move
  3. The AI converts the decided move into JSON format, and prints it to std::cout, which is then captured by the Prismata game client, converted into a sequence of actions, and carried out within the game

AI Parameters

The above system uses the AI Parameters configuration file to specify which type of Player should be run to perform the decision making logic. When you choose an AI difficulty in the official Prismata client, this player name is stored. When the AI is called, the AI executable parses that player name and does the appropriate logic. Unfortunately since the Prismata client sends the configuration file to the executable, you are not able to simply modify that file, you can only read it. You can however make whatever changes you want to the parameters manually after reading the configuration into your AI system.

This all sounds quite complicated, and it is, but it was necessary in order to give designers the ability to modify the modular AI system as they see fit, without exposing those modifications to the general public, and possibly wreaking havoc on early versions of the AI system.

Clone this wiki locally