Agent base
Module containing the base class for matbii guidance agents, see GuidanceAgent
documentation for details.
GuidanceAgent
¶
Bases: GuidanceAgent
Base class for matbii guidance agents.
This class adds some useful fields to the the beliefs
dict.
- is_guidance
: whether guidance is currently being shown for the task.
- failure_start
: the time since the last failure started on the task.
- guidance_start
: the time since the last guidance started to be shown on the task.
Other fields are inherited:
- is_acceptable
: whether the task is currently acceptable.
- is_active
: whether the task is currently active.
All of these fields are accessible via the corresponding task keys, e.g. self.beliefs[task]["is_guidance"]
.
They are updated internally as new observations are received (or actions are taken), it is best not to assign to these fields directly.
Source code in matbii\guidance\agent_base.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
|
fixation_target: str | None
property
¶
Get the task that the user is currently fixating on. Eyetracking events arrive quickly, this will check events that have been generated since the last cycle of this agent.
Returns:
Type | Description |
---|---|
str | None
|
str | None: the task that the user is currently fixating on, or None if the user is not currently fixating on any task. |
gaze_target: str | None
property
¶
Get the task that the gaze is currently over.
guidance_on_tasks: set[str]
property
¶
Get the set of tasks that guidance is currently being shown on.
Returns:
Type | Description |
---|---|
set[str]
|
set[str]: set of tasks that guidance is currently being shown on. |
mouse_target: str | None
property
¶
Get the task that the mouse is currently over.
decide()
¶
Decide method for this agent. This method is intended to determine the guidance actions the agent will take in each cycle. Make use of the show_guidance
and hide_guidance
methods to control guidance rather than using raw actions or attempt methods. This will ensure consistent behaviour and handle possible counter-factual guidance.
Source code in matbii\guidance\agent_base.py
149 150 151 152 153 |
|
get_cycle_start(index=0)
¶
Get the time since the previous cycle started.
An index of 0 indicates the start of the current cycle. If the index is greater than the current history size N (which may happen in the first N - 1 cycles) the oldest cycle time will be returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index |
int
|
the index of the cycle to get the start time for. |
0
|
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
the time since the given cycle started. |
Source code in matbii\guidance\agent_base.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
hide_guidance(task)
¶
Hide guidance for a given task.
If overriding you must call super() to ensure consistent behaviour.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task |
str
|
the task(s) to hide guidance for. |
required |
Source code in matbii\guidance\agent_base.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
log_belief(belief)
¶
Method that is intended for logging the beliefs of this agent to a file. This can be very useful for keeping track of the state of the simulation, user input, task acceptability and guidance for post analysis purposes.
Requires icua.extras.logging.LogActuator
be attached to this agent and will otherwise have no effect. Logging can be configured in the LogActuator
, including the way that beliefs are formatted in the file.
Note that the belief wont be logged immediately, but will be buffered as an action and logged as part of usual action execution cycle (on execute).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
belief |
dict[str, Any]
|
belief to log |
required |
Source code in matbii\guidance\agent_base.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
show_guidance(task)
¶
Show guidance for a given task.
If overriding you must call super() to ensure consistent behaviour.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task |
str
|
the task to show guidance for. |
required |
Source code in matbii\guidance\agent_base.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
time_since_failure_start(task=None)
¶
Get the time since the last failure started on the task (or any task if task
is None).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task |
str | None
|
the task. If None, use any task. |
None
|
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
the time since the last failure started on the task (or any task if |
Source code in matbii\guidance\agent_base.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
|
time_since_guidance_start(task=None)
¶
Get the time since the last guidance started to be shown on the task (or any task if task
is None).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task |
str | None
|
the task. If None, use any task. |
None
|
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
the time since the last guidance started to be shown on the task (or any task if |
Source code in matbii\guidance\agent_base.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|