-
Notifications
You must be signed in to change notification settings - Fork 0
/
guards.py
46 lines (34 loc) · 1.36 KB
/
guards.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
"""
===========================
Guards
===========================
Dr. Cai Wingfield
---------------------------
Embodied Cognition Lab
Department of Psychology
University of Lancaster
caiwingfield.net
---------------------------
2022
---------------------------
"""
from typing import Callable
from framework.cognitive_model.basic_types import ItemIdx, ActivationValue
# Maps an item and its activation to whether something is permitted to happen,
# i.e. whether the guard is passed
# (True => it is allowed to happen; False => it is not allowed to happen)
Guard = Callable[[ItemIdx, ActivationValue], bool]
# Actual guards
def just_no_guard(idx: ItemIdx, activation: ActivationValue) -> bool:
"""Slot this guard into place to deny whatever is being guarded against."""
return False
# Functions to create guards
def make_under_firing_threshold_guard_for(firing_threshold: ActivationValue) -> Guard:
def under_firing_threshold_guard(idx: ItemIdx, activation: ActivationValue) -> bool:
return activation < firing_threshold
return under_firing_threshold_guard
def make_exceeds_firing_threshold_guard_for(firing_threshold: ActivationValue) -> Guard:
def exceeds_firing_threshold_guard(idx: ItemIdx, activation: ActivationValue) -> bool:
return activation >= firing_threshold
return exceeds_firing_threshold_guard