Utility Functions#
These include convenience function for getting started using tomsup.
tomsup.utils#
This script contains utility functions used in the tomsup package
- tomsup.utils.create_agents(agents: Union[str, list], start_params: Optional[List[dict]] = None, **kwargs) Union[AgentGroup, Agent] [source]#
- Parameters:
agents (Union[str, list]) – A str denoting an agent or a list of agents. To see option use valid_agents().
start_params (Optional[List[dict]], optional) – The starting parameters of the agent. Defaults to None, indicating the default starting parameters.
- Returns:
If only one agent is specified returns an Agent otherwise returns an AgentGroup.
- Return type:
Union[AgentGroup, Agent]
Examples
>>> group = create_agents(agents = ['RB']*3) >>> isinstance(group, AgentGroup) True >>> group.get_names() ['RB_0', 'RB_1', 'RB_2'] >>> RB_agent = group.get_agent('RB_0') >>> RB_agent.get_strategy() 'RB'
- tomsup.utils.valid_agents() dict [source]#
- Returns:
- A dictionary of valid agent, where each key is an valid agent shorthand.
Each dictionary key (e.g. shorthand) refers to a new dictionary containing, additional information, such as a short description of the strategy, and a reference. See examples for more.
- Return type:
dict
Examples
>>> output = valid_agents() >>> isinstance(output, dict) True >>> output.keys() dict_keys(['RB', 'WSLS']) >>> output['RB'] {'name': 'Random Bias', 'shorthand': 'RB', 'example': 'RB(bias = 0.5)', 'reference': 'Devaine, et al. (2017)', 'strategy': 'Chooses 1 randomly based on a probability or bias'}