@@ -6,6 +6,10 @@ using ..CatConfig: CatLoopConfig, CatRules
66using .. Responses: BareResponses, Response
77using .. NextItemRules: compute_criteria, best_item
88
9+ export StatefulCat, StatefulCatConfig, run_cat
10+ public next_item, ranked_items, item_criteria
11+ public add_response!, rollback!, reset!, get_responses, get_ability
12+
913# # StatefulCat interface
1014abstract type StatefulCat end
1115
5660# # TODO : Materialise the cat into a decsision tree
5761
5862# # Implementation for CatConfig
59- struct StatefulCatConfig{ItemBankT <: AbstractItemBank } <: StatefulCat
63+ struct StatefulCatConfig{TrackedResponsesT <: TrackedResponses } <: StatefulCat
6064 rules:: CatRules
61- tracked_responses:: TrackedResponses
62- item_bank:: Ref{ItemBankT}
65+ tracked_responses:: Ref{TrackedResponsesT}
6366end
6467
65- function StatefulCatConfig (rules, item_bank)
68+ function StatefulCatConfig (rules:: CatRules , item_bank:: AbstractItemBank )
6669 bare_responses = BareResponses (ResponseType (item_bank))
6770 tracked_responses = TrackedResponses (
6871 bare_responses,
6972 item_bank,
7073 rules. ability_tracker
7174 )
72- return StatefulCatConfig (rules, tracked_responses, Ref (item_bank ))
75+ return StatefulCatConfig (rules, Ref (tracked_responses ))
7376end
7477
7578function next_item (config:: StatefulCatConfig )
76- return best_item (config. rules. next_item, config. tracked_responses, config . item_bank [])
79+ return best_item (config. rules. next_item, config. tracked_responses[])
7780end
7881
7982function ranked_items (config:: StatefulCatConfig )
8083 return sortperm (compute_criteria (
81- config. rules. next_item, config. tracked_responses, config . item_bank []))
84+ config. rules. next_item, config. tracked_responses[]))
8285end
8386
8487function item_criteria (config:: StatefulCatConfig )
8588 return compute_criteria (
86- config. rules. next_item, config. tracked_responses, config . item_bank [])
89+ config. rules. next_item, config. tracked_responses[])
8790end
8891
8992function add_response! (config:: StatefulCatConfig , index, response)
93+ tracked_responses = config. tracked_responses[]
9094 Aggregators. add_response! (
91- config . tracked_responses, Response (
92- ResponseType (config . item_bank[] ), index, response))
95+ tracked_responses, Response (
96+ ResponseType (tracked_responses . item_bank), index, response))
9397end
9498
9599function rollback! (config:: StatefulCatConfig )
96- pop_response! (config. tracked_responses)
100+ pop_response! (config. tracked_responses[] )
97101end
98102
99103function reset! (config:: StatefulCatConfig )
100- empty! (config. tracked_responses)
104+ empty! (config. tracked_responses[] )
101105end
102106
103107function set_item_bank! (config:: StatefulCatConfig , item_bank)
104- reset! (config)
105- config. item_bank[] = item_bank
108+ bare_responses = BareResponses (ResponseType (item_bank))
109+ config. tracked_responses[] = TrackedResponses (
110+ bare_responses,
111+ item_bank,
112+ config. rules. ability_tracker
113+ )
106114end
107115
108116function get_responses (config:: StatefulCatConfig )
109- return config. tracked_responses. responses
117+ return config. tracked_responses[] . responses
110118end
111119
112120function get_ability (config:: StatefulCatConfig )
113- return (config. rules. ability_estimator (config. tracked_responses), nothing )
121+ return (config. rules. ability_estimator (config. tracked_responses[] ), nothing )
114122end
115123
116124# # TODO : Implementation for MaterializedDecisionTree
0 commit comments