Defining Agents and Games in a JSON file

Defining Agents and Games in a JSON file

Agents

Agents can be defined in a JSON file to make it easier to specify the precise details - for example when running tournaments between multiple agents.

A few examples of increasing complexity are shown below:

{
	"class" : "players.simple.RandomPlayer",
}

The first way is to simply specify any class that implements AbstractPlayer with a no-arguments constructor. The class field is mandatory, and any JSON file not containing this will be rejected.

{
	"class":"players.simple.OSLAHeuristic",
	"heuristic" : {
		"class" : "games.coltexpress.ColtExpressHeuristic",
		"maxLoot" : 500,
		"BULLET_CARDS" : -1.0,
    		"BULLETS_PLAYER" : 0.5,
		"BULLETS_ENEMY" : 0.0,
		"LOOT" : 0.5
	}	
}

The second example above now references OSLAHeuristic, which is not an AbstractPlayer, but sub-classes TunableParameters. In this case the remainder of the json will be used to create this parameterised object and then call the instantiate() method. See the separate documentation on TunableParameters for much more detail.

The third exmaple below then creates an MCTS agent using the same approach. For details on the contents, see the MCTS documentation.

{
        "class" : "players.mcts.MCTSParams",
        "selectionPolicy" : "SIMPLE",
        "rolloutLength" : 300,
        "information" : "Open_Loop",
        "opponentTreePolicy" : "SelfOnly",
        "K" : 1.0,
        "exploreEpsilon" : 0.10,
        "maxTreeDepth" : 30,
        "treePolicy" : "EXP3",
        "rolloutType" : "CLASS",
	"rolloutClass" : "games.dicemonastery.heuristics.Advantage003|YearModel_DPP_0718_05.csv",
	"opponentModelType" : "CLASS",
	"opponentModelClass" : "games.dicemonastery.heuristics.Advantage002|Adv002_0711.csv",
	"advantageFunction" : "games.dicemonastery.heuristics.Advantage003|YearModel_DPP_0718_05.csv",
	"progressiveWideningConstant" : 3.0,
	"progressiveWideningExponent" : 0.1,
	"expansionPolicy" : "RANDOM",
	"MAST" : "Tree",
	"boltzmannTemp" : "0.05",
        "budgetType" : "BUDGET_TIME",
        "budget" : 10000,
        "breakMS" : 0
}

Games

GameParameters that extend TunableParameters can also be specified in exactly the same way as agents.

A simple example is:

{
	"class" : "games.tictactoe.TicTacToeGameParameters",
	"gridSize" : 4
}