The objective module
Overview
API: objective
Manage all objective
Objective
Bases: Agent
done
property
Is the objective completed? Returns: bool: True if the objective is complete.
result
property
writable
Get the result of the objective. Returns: PollResults: The result.
__init__(agent, label, data, client_id)
Create an Objective. Args: agent (Agent | int): The agent or id for this objective label (str | Label): The objective label to run data (dict): Data to associate with this objective. May not be used. client_id (int): The client ID for this objective. May not be used.
force_clear()
Clear this objective from its agent and undesignates it as an objective.
run()
Run the objective label.
run_sub_label(loc)
Run the sublabel with the specified index. Args: loc (int): The index of the sublabel. Returns: PollResults: The result of the sublabel task.
stop_and_leave(result=PollResults.FAIL_END)
Stop the label run with a result. Args: result (PollResults): The result of the objective label.
game_end_condition_add(promise, message, is_win, music=None, signal=None)
Add a game end condition. Args: promise (Promise): The promise that must be completed for the game to end. message (str): The message to display on game end. is_win (bool): Does the game end with a win or loss? music (str, optional): The music to play on game end. Default is None. signal (str, optional): The signal to emit when the game ends. Returns: int: The id of the game end promise. Used to remove the game end condition after adding it.
game_end_condition_remove(id)
Remove a game end condition. Args: id (int): The id of the game end condition.
game_end_run_all(tt)
Check if any of the game end conditions have been met. Args: tt (Task): The tick task. Not used yet.
objective_add(agent_id_or_set, label, data=None, client_id=0)
Add an objective to the agent or agents Args: agent_id_or_set (Agent | int | set[Agent | int]): The agent or id or set of agents or ids. label (str | Label): The objective label to add. data (dict, optional): The data associated with the objective. client_id (int, optional): The client id for this objective (may not be used?) Returns: list[Objective | int]: The list of objectives added. Objectives for multiple agents count as separate objectives.
objective_clear(agent_id_or_set)
Clear all objectives from the agent or agents. Args: agent_id_or_set (Agent | int | set[Agent | int]): The agent or id or set of agents or ids.
objective_extends(label, data=None)
Add an objective to the current task as a subtask. Args: label (str | Label): The label to add. data (dict, optional): The data to associate with the objective. Default is None. Returns: MastAsyncTask: The task
objective_schedule()
Schedule a simple task tick that runs all objective tasks.
objectives_run_all(tick_task)
Run all objective labels. Args: tick_task (Task): The task. (Not used)
objectives_run_everything(tick_task)
Check objectives, brains, scan sources, and game end conditions. Which promises are checked is depenent on the value of tick_task.state.
This spreads out the calculation times across multiple runs instead of everything happening at the same time. The tick_task's state is updated.
Args:
tick_task (Task): The current task.