-
Notifications
You must be signed in to change notification settings - Fork 10
AI Config File
The Prismata AI system has a configuration file in which the parameters of most AI-related classes are defined. This file is written in JSON format, with major JSON objects denoting parameters of specific classes. The config file is parsed by the AIParameters
singleton class, which stores all parameters for easy retrieval in the AI system. Here is a brief overview of the config file.
Note: The AI config file is not required for you to write your own AI system, but it is required if you want to use the existing AI system code / GUI.
"Opening Books"
This section defines some hard-coded build orders that the bot uses in various situations. Instead of being defined as a sequence of actions, which may or may not be legal due to factors such as being attacked, they are instead defined as a set of units to purchase when a specific condition is met on the state. These conditions are which units you must currently own, and which units the enemy must own, followed by which unit to purchase.
Parameter Specification:
-
self
- the counts of units you must own -
enemy
- the counts of units the enemy must own -
buyable
- the list of units that must be purchasable -
buy
- the sequence of units to buy when this condition is met
"Buy Limits"
Here we can define sets of hard-coded unit counts that will never be exceeded by purchasing algorithms in the AI. The variable name of each object can be used within a PartialPlayer
so that it never exceeds these counts. For example, by default, the BuyEcon
PartialPlayer uses the EconLimits
Buy Limit, which ensures it will not buy more than 2 Engineer units.
"Partial Players"
Taking up the bulk of the config file, these are all of the PartialPlayer parameters, with each one taking actions during one specific phase of the game. Each specific Partial Player has its own set of parameters and variables which can be seen in the AIParameters
class parsing functions. If you write a new PartialPlayer class, you must include parsing code for it in the AIParameters
class - it is not added automatically.
"Move Iterators"
This section defines the parameters for various MoveIterator
derived classes that can be found in the project. For the most part, these are of the type PPPortfolio
(Partial Player Portfolio) and the MoveIterator handles generating and returning the permutations of the PartialPlayers listed in the config file.
"Players"
This section defines the parameters for the top level Player
classes. Each Player class has its own individual parameters, which are fairly intuitive from inspecting the variables names in the config file.
"States"
This section defines various GameState
objects which can be loaded to play games from various predefined states. There are two different types of state you can define.
-
Dominion
states used the base set + N random cards, where N is defined by theDominionCards
variable. Each time you refer to this state, it will return a new randomized state. -
JSON
states read in a state from a JSON file with a specific format which will be obious once you look at it. You can see a sample JSON state here
"Benchmarks"
These settings are used by the Prismata_Testing
project. I could have made them a separate file, but it was convenient to put them all in the same file. There are two main types of tests you can run:
-
PlayerBenchmark
- Used to run many games of one player vs another player, with player names reading from the previous section of the config file'sPlayers
section. This will produce an html file in thebin/tests
directory so you can visualize the results. Useful for running many games to make sure your code isn't crashing, or timing to see if changes made any difference in the speed of your code. -
Tournament
- Used to run round robin tournaments between many players. You can use thegroup
variable to assign an integer to each player. The round robin tournament will be run such that only players within different groups will play against each other. To run a true round robin tournament, give each player a unique integer. The results of the tournament will print in real time to the console everyUpdateIntervalSec
seconds, with detailed results being output to an html file in thebin/tests
directory.