Agents – sc2qsr.agents

class sc2qsr.agents.PySC2Agent(map_size: tuple, m: int = 4, n: int = 4, alpha=0.1, gamma=0.6, epsilon=0.1, policy='egreedy')[source]

An agent that uses qualitative spatial reasoning to discretize states received by the pysc2 environment, select actions that are spatially qualitative and convert them back to pysc2 actions.

  • map_size (tuple) – tuple containing the (x,y) dimensions of the map

  • m (int, optional) – granularity for qualitative spatial angular regions, defaults to 4

  • n (int, optional) – granularity for qualitative spatial distance regions, defaults to 4

  • alpha (float, optional) – learning rate, defaults to .1

  • gamma (float, optional) – discount factor, defaults to .6

  • epsilon (float, optional) – value for epsilon-greedy policy, defaults to .1

  • policy (str, optional) – what type of policy to use from ['egreedy', 'boltzmann'], defaults to ‘egreedy’

static array2oneliner(a: numpy.ndarray) → str[source]

Converts a numpy.ndarray into a one-line string containing all its information


a (numpy.ndarray) – A 1D or 2D numpy.ndarray


a one-line string representation of the array

Return type


static oneliner2array(s: str, dtype)[source]

Converts a one-line string representation (see array2oneliner()) of one or more numpy arrays back into their string representations

  • s (str) – one-line string representation of the arrays

  • dtype (function) – a function which is called to convert the value of each element in the arrays


a tuple of arrays if s contains more than one array. Otherwise, a single array.