diff --git a/apprentice/agents/ModularAgent.py b/apprentice/agents/ModularAgent.py index 9e50b0de..95908bd8 100644 --- a/apprentice/agents/ModularAgent.py +++ b/apprentice/agents/ModularAgent.py @@ -677,13 +677,13 @@ def check(self, state, selection, action, inputs): def get_skills(self, states=None): out = [] - print("GET_SKILLS") - print(states) + # print("GET_SKILLS") + # print(states) for state in states: req = self.request(state, add_skill_info=True) - pprint(req) + # pprint(req) if(len(req) != 0): req["when"] = json.dumps(req["when"]) req["where"] = json.dumps(req["where"])#tuple(len(list(req["where"].keys())) * ["?"]) diff --git a/apprentice/learners/WhenLearner.py b/apprentice/learners/WhenLearner.py index 02b88e8e..a77f3865 100644 --- a/apprentice/learners/WhenLearner.py +++ b/apprentice/learners/WhenLearner.py @@ -94,7 +94,7 @@ def ifit(self, rhs, state, mapping, reward): if(self.cross_rhs_inference == "implicit_negatives"): this_state = state.get_view(("variablize",rhs,tuple(mapping))) - pprint(this_state) + # pprint(this_state) if(self.type == "one_learner_per_label"): key = rhs.label elif(self.type == "one_learner_per_rhs"): diff --git a/apprentice/learners/WhereLearner.py b/apprentice/learners/WhereLearner.py index abe59b3b..90da7e2a 100644 --- a/apprentice/learners/WhereLearner.py +++ b/apprentice/learners/WhereLearner.py @@ -687,7 +687,7 @@ def ifit(self, t, x, y): sm = StructureMapper(self.concept) x = sm.transform(ns.transform(x)) - pprint(x) + # pprint(x) # pprint(x) self.concept.increment_counts(x) @@ -696,7 +696,7 @@ def ifit(self, t, x, y): else: self.neg_concept.increment_counts(x) - print(self.pos_concept) + # print(self.pos_concept) # print() # print('POSITIVE') @@ -723,10 +723,10 @@ def ifit(self, t, x, y): args.append(val_gensym) pos_instance[attr] = val_gensym - pprint(pos_instance) - pprint(pos_args) - print("av_counts") - pprint(self.pos_concept.av_counts) + # pprint(pos_instance) + # pprint(pos_args) + # print("av_counts") + # pprint(self.pos_concept.av_counts) # if len(self.pos_concept.av_counts[attr]) == 1: # for val in self.pos_concept.av_counts[attr]: @@ -758,7 +758,7 @@ def ifit(self, t, x, y): conditions = ([(a, pos_instance[a]) for a in pos_instance] + [('not', (a, neg_instance[a])) for a in neg_instance]) - print(conditions) + # print(conditions) # print("========CONDITIONS======") # pprint(conditions) @@ -767,7 +767,7 @@ def ifit(self, t, x, y): self.target_types = ['?foa%s' % i for i in range(len(t))] self.operator = Operator(tuple(['Rule'] + self.target_types), conditions, []) - print("_-----------------------------------") + # print("_-----------------------------------") def fit(self, T, X, y): self.count = len(X) diff --git a/apprentice/planners/NumbaPlanner.py b/apprentice/planners/NumbaPlanner.py index 56af3c32..625b224f 100644 --- a/apprentice/planners/NumbaPlanner.py +++ b/apprentice/planners/NumbaPlanner.py @@ -15,6 +15,8 @@ import numpy as np +logger = logging.getLogger(__name__) + def toFloatIfFloat(x): try: x = float(x) @@ -166,7 +168,7 @@ def how_search(self,state, if(not at_least_one and allow_bottomout and (foci_of_attention == None or len(foci_of_attention) == 0)): - print("Bottomout:", goal) + logger.info("Bottomout: {}".format(goal)) yield goal, {} diff --git a/django/apprentice_learner/views.py b/django/apprentice_learner/views.py index 657cdaf8..097f9d0a 100644 --- a/django/apprentice_learner/views.py +++ b/django/apprentice_learner/views.py @@ -34,9 +34,13 @@ log = logging.getLogger('al-django') performance_logger = logging.getLogger('al-performance') +DEFAULT_SAVE_AGENT = False +DEFAULT_STAY_ACTIVE = True + + active_agent = None active_agent_id = None -dont_save = True +save_agent = None AGENTS = { @@ -52,7 +56,7 @@ def get_agent_by_id(id): - global active_agent, active_agent_id, dont_save + global active_agent, active_agent_id if id == active_agent_id: agent = active_agent else: @@ -126,30 +130,36 @@ def create(http_request): traceback.print_exc() print("Failed to create agent", exp) return HttpResponseServerError( - "Failed to create agent, " "ensure provided args are " "correct." + "Failed to create agent, ensure provided args are correct." ) - global active_agent, active_agent_id, dont_save + global active_agent, active_agent_id, save_agent if active_agent is not None: active_agent = None active_agent_id = None - dont_save = False - if str(data.get("stay_active", True)).lower() == "true": + + if str(data.get("stay_active", DEFAULT_STAY_ACTIVE)).lower() == "true": active_agent = agent active_agent_id = str(agent.id) - dont_save = str(data.get("dont_save", True)).lower() == "true" else: - warns.append( - "Stability Warning: stay_active is set to false. Serialization and" - " deserialization of agents is currently not working for most" - " agent types. Expect Errors.") + # warns.append( + # "Stability Warning: stay_active is set to false. Serialization and" + # " deserialization of agents is currently not working for most" + # " agent types. Expect Errors.") + pass + + if "save_agent" in data: + save_agent = str(data["save_agent"]).lower() == "true" + elif "dont_save" in data: + save_agent = not str(data["dont_save"]).lower() == "true" + else: + save_agent = DEFAULT_SAVE_AGENT if len(warns) > 0: for warn in warns: log.warning(warn) ret_data["warnings"] = warns - last_call_time = time.time_ns() return HttpResponse(json.dumps(ret_data)) @@ -180,17 +190,17 @@ def request(http_request, agent_id): agent.inc_request() start_t = time.time_ns() - response = agent.instance.request(data["state"],**data.get('kwargs',{})) + response = agent.instance.request(data["state"], **data.get('kwargs', {})) performance_logger.info("Request Elapse Time: {} ms".format((time.time_ns()-start_t)/(1e6))) - global dont_save - if not dont_save: - log.warning('Agent is being saved! This is probably not working.') + global save_agent + if save_agent: + # log.warning('Agent is being saved! This is probably not working.') agent.save() # pr.disable() # pr.dump_stats("al.cprof") - last_call_time = time.time_ns() + last_call_time = time.time_ns() if isinstance(response, Sai): temp = {'selection': response.selection, @@ -199,15 +209,14 @@ def request(http_request, agent_id): 'mapping': {"?sel": response.selection}, 'how': "n/a", 'skill_label': 'n/a'} - + return HttpResponse( json.dumps({'selection': response.selection, - 'action': response.action, - 'inputs': response.inputs, - 'mapping': {"?sel": response.selection}, - 'responses': [temp] - } - )) + 'action': response.action, + 'inputs': response.inputs, + 'mapping': {"?sel": response.selection}, + 'responses': [temp] + })) return HttpResponse(json.dumps(response)) @@ -240,9 +249,9 @@ def get_skills(http_request, agent_id): agent.inc_request() response = agent.instance.get_skills(data["states"]) - global dont_save - if not dont_save: - log.warning('Agent is being saved! This is probably not working.') + global save_agent + if save_agent: + # log.warning('Agent is being saved! This is probably not working.') agent.save() # pr.disable() @@ -331,17 +340,17 @@ def train(http_request, agent_id): response = agent.instance.train(**data) performance_logger.info("Train Elapse Time: {} ms".format((time.time_ns()-start_t)/(1e6))) - global dont_save - if not dont_save: - log.warning('Agent is being saved! This is probably not working.') + global save_agent + if save_agent: + # log.warning('Agent is being saved! This is probably not working.') agent.save() # pr.disable() # pr.dump_stats("al.cprof") - last_call_time = time.time_ns() + last_call_time = time.time_ns() if(response is not None): - return HttpResponse(json.dumps(response)) + return HttpResponse(json.dumps(response)) else: return HttpResponse("OK") diff --git a/tests/data_for_test.json b/tests/data_for_test.json new file mode 100644 index 00000000..18cc24c1 --- /dev/null +++ b/tests/data_for_test.json @@ -0,0 +1,328 @@ +{"addition":[ + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "2"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "1"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "1"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "1"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "1"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "2"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}} + }, + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "5"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "2"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "3"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "2"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "3"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "5"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}} + }, + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "14"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "8"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "6"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "8"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "6"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "14"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}} + }, + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "7"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "2"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "5"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "2"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "5"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "7"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}} + }, + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "23"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "17"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "6"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "17"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "6"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "23"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}} + }, + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "15"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "8"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "7"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "8"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "7"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "15"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}} + }, + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "8"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "4"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "4"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "4"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "4"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "8"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}} + }, + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "8"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "2"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "6"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "2"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "6"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "8"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}} + }, + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "19"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "9"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "10"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "9"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "10"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "19"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}} + }, + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "3"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "1"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "2"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "1"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "2"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "3"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}} + }], + +"subtraction":[ + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "1"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "2"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "1"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "2"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "1"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "1"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}} + }, + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "2"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "5"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "3"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "5"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "3"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "2"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}} + }, + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "8"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "14"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "6"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "14"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "6"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "8"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}} + }, + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "2"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "7"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "5"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "7"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "5"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "2"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}} + }, + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "17"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "23"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "6"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "23"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "6"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "17"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}} + }, + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "8"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "15"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "7"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "15"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "7"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "8"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}} + }, + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "4"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "8"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "4"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "8"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "4"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "4"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}} + }, + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "2"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "8"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "6"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "8"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "6"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "2"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}} + }, + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "9"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "19"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "10"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "19"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "10"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "9"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}} + }, + {"reward": 1, "selection": "answer", "action": "UpdateTextField", "inputs": {"value": "1"}, + "state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "3"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "2"}, + "answer": {"above": "", "below": "hint", "contentEditable": true, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}}, + "next_state": {"arg1": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "3"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "2"}, + "answer": {"above": "", "below": "hint", "contentEditable": false, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": "1"}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": false, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "-"}} + }] +} + + + + diff --git a/tests/test_modularagent_foplanner_configs.py b/tests/test_modularagent_foplanner_configs.py new file mode 100644 index 00000000..fddae23d --- /dev/null +++ b/tests/test_modularagent_foplanner_configs.py @@ -0,0 +1,68 @@ +""" +This module will test initial creation and do simple train/request tests on +all possible configurations of agent and learner types. The goal is mainly to +be a break glass sanity check, note to test behavior. +""" +import json +import logging +import pytest +from os.path import dirname +from os.path import join +from apprentice.agents.ModularAgent import ModularAgent +from apprentice.working_memory.representation import Sai +from apprentice.working_memory.fo_planner_operators import add_rule, sub_rule, mult_rule, div_rule, equal_rule + +logging.disable() +module_path = dirname(__file__) + + +def train_A_req_A(agent): + add_set = json.load(open(join(module_path, 'data_for_test.json'), 'r'))['addition'] + + for data in add_set[:-1]: + sai = Sai( + selection=data["selection"], + action=data["action"], + inputs=data["inputs"], + ) + + data['sai'] = sai + del data['selection'] + del data['action'] + del data['inputs'] + + agent.train(**data) + + return agent.request(add_set[-1]['state']), add_set[-1] + + +def req_A(agent): + add_set = json.load(open(join(module_path, 'data_for_test.json'), 'r'))['addition'] + return agent.request(add_set[-1]['state']) + + +@pytest.mark.parametrize("when", ['decision_tree', 'cobweb', 'trestle']) +@pytest.mark.parametrize("where", ['version_space', + 'fastmostspecific', + 'mostspecific',]) + # 'stateresponselearner', + # 'relationallearner', + # 'specifictogeneral']) +@pytest.mark.parametrize("which", ['proportioncorrect', 'totalcorrect']) +@pytest.mark.parametrize("choice", ['first', 'mostparsimonious', 'all', 'random']) +def test_fo_planner_configs(when, where, which, choice): + function_set = [add_rule, sub_rule, mult_rule, div_rule] + feature_set = [equal_rule] + agent = ModularAgent(feature_set, function_set, + when_learner=when, + where_learner=where, + planner='fo_planner', + heuristic_learner=which, + explanation_choice=choice) + resp = req_A(agent) + assert resp == {} + + resp, ans = train_A_req_A(agent) + assert resp['selection'] == ans['selection'] + assert resp['action'] == ans['action'] + assert resp['inputs']['value'] == ans['inputs']['value'] diff --git a/tests/test_modularagent_numbert_configs.py b/tests/test_modularagent_numbert_configs.py new file mode 100644 index 00000000..19451653 --- /dev/null +++ b/tests/test_modularagent_numbert_configs.py @@ -0,0 +1,68 @@ +""" +This module will test initial creation and do simple train/request tests on +all possible configurations of agent and learner types. The goal is mainly to +be a break glass sanity check, note to test behavior. +""" +import json +import logging +import pytest +from os.path import dirname +from os.path import join +from apprentice.agents.ModularAgent import ModularAgent +from apprentice.working_memory.representation import Sai + +logging.disable() +module_path = dirname(__file__) + + +def train_A_req_A(agent): + add_set = json.load(open(join(module_path, 'data_for_test.json'), 'r'))['addition'] + + for data in add_set[:-1]: + sai = Sai( + selection=data["selection"], + action=data["action"], + inputs=data["inputs"], + ) + + data['sai'] = sai + del data['selection'] + del data['action'] + del data['inputs'] + + agent.train(**data) + + return agent.request(add_set[-1]['state']), add_set[-1] + + +def req_A(agent): + add_set = json.load(open(join(module_path, 'data_for_test.json'), 'r'))['addition'] + return agent.request(add_set[-1]['state']) + + +@pytest.mark.parametrize("when", ['decision_tree', 'cobweb', 'trestle']) +@pytest.mark.parametrize("where", ['version_space', + 'fastmostspecific', + 'mostspecific', + # 'stateresponselearner', + # 'relationallearner', + 'specifictogeneral']) +@pytest.mark.parametrize("which", ['proportioncorrect', 'totalcorrect']) +@pytest.mark.parametrize("choice", ['first', 'mostparsimonious', 'all', 'random']) +def test_numbert_configs(when, where, which, choice): + function_set = ["RipFloatValue", "Add", "Subtract", "Multiply", "Divide"] + feature_set = ["Equals"] + agent = ModularAgent(feature_set, function_set, + when_learner=when, + where_learner=where, + planner='numbert', + heuristic_learner=which, + explanation_choice=choice, + search_depth=2) + resp = req_A(agent) + assert resp == {} + + resp, ans = train_A_req_A(agent) + assert resp['selection'] == ans['selection'] + assert resp['action'] == ans['action'] + assert str(int(resp['inputs']['value'])) == ans['inputs']['value'] diff --git a/tests/test_save.py b/tests/test_save.py new file mode 100644 index 00000000..3976246b --- /dev/null +++ b/tests/test_save.py @@ -0,0 +1,152 @@ +""" +This module tests dill based serialization and deserialization of all common +agent configurations. It tries to confirm that a deserialized agent will +exhibit equivalent behavior to its origin. +""" + +import dill +import copy +import json +import logging +import pytest +from os.path import dirname +from os.path import join +from pprint import pprint + +from apprentice.agents.ModularAgent import ModularAgent +from apprentice.agents.WhereWhenHowNoFoa import WhereWhenHowNoFoa +from apprentice.working_memory.representation import Sai +from apprentice.working_memory.fo_planner_operators import add_rule, sub_rule, mult_rule, div_rule, equal_rule + +logging.disable() +module_path = dirname(__file__) + + +def areAgentsSame(agent1, agent2): + """Check that agents' underlying structures are the same""" + agent1dict = agent1.__dict__ + agent2dict = agent2.__dict__ + + to_find_common = {'constraint_generator', 'epsilon', 'feature_set', 'function_set', 'last_state', + 'ret_train_expl', 'rhs_by_label', 'rhs_counter', 'search_depth', 'rhs_list'} + for common in to_find_common: + assert agent1dict[common] == agent2dict[common], "Structural equivalence failed on: {}".format(common) + + # planner is not equal ,'planner' + assert(agent1dict['state_variablizer'].__dict__ == + agent2dict['state_variablizer'].__dict__) + + # which learner + which_learner = agent1dict['which_learner'] + for key in which_learner.__dict__: + assert(True) + + # when learner: + when_learner = agent1dict['when_learner'] + for key in when_learner.__dict__: + assert(True) + + # where learner + where_learner = agent1dict['where_learner'] + for key in where_learner.__dict__: + assert(True) + + return True + + +def train_A_req_A(agent): + add_set = json.load(open(join(module_path, 'data_for_test.json'), 'r'))[ + 'addition'] + + for data in add_set[:-1]: + sai = Sai( + selection=data["selection"], + action=data["action"], + inputs=data["inputs"], + ) + + data['sai'] = sai + del data['selection'] + del data['action'] + del data['inputs'] + + agent.train(**data) + + return agent.request(add_set[-1]['state']), add_set[-1] + + +def req_A(agent): + add_set = json.load(open(join(module_path, 'data_for_test.json'), 'r'))[ + 'addition'] + return agent.request(add_set[-1]['state']) + + +def run_save_test(agent, verify_structure=True): + resp, ans = train_A_req_A(agent) + + # check that deserialized version is the same + agent_stream = dill.dumps(agent) + agent_deserialized = dill.loads(agent_stream) + + if verify_structure: + assert(areAgentsSame(agent, agent_deserialized)) + + # make another request + resp = req_A(agent) + resp2 = req_A(agent_deserialized) + assert(resp == resp2) + + # train the agents again + resp, ans = train_A_req_A(agent) + resp2, ans2 = train_A_req_A(agent_deserialized) + + # where the state would be wrong + wrongAnswerState = {"arg1": {"above": "", "below": "hintWindow", "contentEditable": False, "dom_class": "CTATTextInput", "id": "arg1", "to_left": "", "to_right": "operator", "type": "TextField", "value": "2"}, + "arg2": {"above": "", "below": "hintWindow", "contentEditable": False, "dom_class": "CTATTextInput", "id": "arg2", "to_left": "operator", "to_right": "answer", "type": "TextField", "value": "3"}, + "answer": {"above": "", "below": "hint", "contentEditable": True, "dom_class": "CTATTextInput", "id": "answer", "to_left": "arg2", "to_right": "", "type": "TextField", "value": ""}, + "hintWindow": {"above": "operator", "below": "", "dom_class": "CTATHintWindow", "id": "hintWindow", "to_left": "", "to_right": "hint", "type": "Component"}, + "done": {"above": "hint", "below": "", "dom_class": "CTATDoneButton", "id": "done", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "hint": {"above": "answer", "below": "done", "dom_class": "CTATHintButton", "id": "hint", "to_left": "hintWindow", "to_right": "", "type": "Component"}, + "operator": {"above": "", "below": "hintWindow", "contentEditable": False, "dom_class": "CTATTextInput", "id": "operator", "to_left": "arg1", "to_right": "arg2", "type": "TextField", "value": "+"}} + + # request with the wrongAnswerState and check sai + resp = agent.request(wrongAnswerState) + resp2 = agent_deserialized.request(wrongAnswerState) + assert(resp == resp2) + + +@pytest.mark.parametrize("when", ['decision_tree', 'cobweb', 'trestle']) +@pytest.mark.parametrize("where", ['version_space', + 'fastmostspecific', + 'mostspecific', ]) +@pytest.mark.parametrize("which", ['proportioncorrect', 'totalcorrect']) +@pytest.mark.parametrize("choice", ['first', 'mostparsimonious', 'all', 'random']) +def test_fo_planner_saves(when, where, which, choice): + function_set = [add_rule, sub_rule, mult_rule, div_rule] + feature_set = [equal_rule] + agent = ModularAgent(feature_set, function_set, + when_learner=when, + where_learner=where, + planner='fo_planner', + heuristic_learner=which, + explanation_choice=choice) + run_save_test(agent, verify_structure=False) + + +@pytest.mark.parametrize("when", ['decision_tree', 'cobweb', 'trestle']) +@pytest.mark.parametrize("where", ['version_space', + 'fastmostspecific', + 'mostspecific']) +@pytest.mark.parametrize("which", ['proportioncorrect', 'totalcorrect']) +@pytest.mark.parametrize("choice", ['first', 'mostparsimonious', 'all', 'random']) +def test_numbert_saves(when, where, which, choice): + function_set = ["RipFloatValue", "Add", "Subtract", "Multiply", "Divide"] + feature_set = ["Equals"] + agent = ModularAgent(feature_set, function_set, + when_learner=when, + where_learner=where, + planner='numbert', + heuristic_learner=which, + explanation_choice=choice, + search_depth=2) + run_save_test(agent)