Skip to content

Commit

Permalink
change all_match
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdfish committed Sep 6, 2021
1 parent 785c150 commit ca3bed8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ACTRModels"
uuid = "c095b0ea-a6ca-5cbd-afed-dbab2e976880"
authors = ["itsdfish"]
version = "0.8.4"
version = "0.9.0"

[deps]
ConcreteStructs = "2569d6c7-a4a2-43d3-a901-331e8e4be471"
Expand Down
2 changes: 1 addition & 1 deletion src/ACTRModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module ACTRModels
export retrieval_prob, retrieval_probs, retrieve, compute_activation!, get_parm
export spreading_activation!, match, compute_RT, retrieval_request, get_subset
export first_chunk, posterior_predictive, find_index, find_indices, get_mean_activations
export get_visicon, get_iconic_memory
export get_visicon, get_iconic_memory, get_rules
export get_time, set_time!, add_time!, reset_time!, rnd_time, get_name
export blend_chunks, blended_activation

Expand Down
23 changes: 19 additions & 4 deletions src/Structs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ A production rule object.
end

function Rule(;utility=0.0, conditions, name="", actr, task, action, args=(), kwargs...)
Rule(utility, ()->conditions(actr, args...; kwargs...),
Rule(utility, conditions(actr, args...; kwargs...),
()->action(actr, task; kwargs...), name)
end

Expand Down Expand Up @@ -514,7 +514,7 @@ function Procedural(T::DataType, state, id)
end

function get_matching_rules(actr)
return filter(r->match(r), get_rules(actr))
return filter(r->match(actr, r), get_rules(actr))
end

get_rules(actr) = actr.procedural.rules
Expand All @@ -525,8 +525,23 @@ function exact_match(actr)
return rules
end

function match(rule)
return rule.conditions()
function match(actr, rule)
return all_match(actr, rule.conditions)
end

"""
all_match(actr, conditions)
Checks whether all conditions of a production rule are satisfied.
- `actr`: an ACT-R model object
- `conditions`: a tuple of functions representing production rule conditions.
"""
function all_match(actr, conditions)
for c in conditions
!c(actr) ? (return false) : nothing
end
return true
end

"""
Expand Down

0 comments on commit ca3bed8

Please sign in to comment.