Multistep behavior learning successful
@@ -462,6 +462,49 @@ void ANSNA_Pong(bool useNumericEncoding)
}
}
+bool ANSNA_Lightswitch_GotoSwitch_executed = false;
+void ANSNA_Lightswitch_GotoSwitch()
+{
+ ANSNA_Lightswitch_GotoSwitch_executed = true;
+ puts("ANSNA invoked goto switch");
+}
+bool ANSNA_Lightswitch_ActivateSwitch_executed = false;
+void ANSNA_Lightswitch_ActivateSwitch()
+{
+ ANSNA_Lightswitch_ActivateSwitch_executed = true;
+ puts("ANSNA invoked activate switch");
+}
+void ANSNA_MultiStepBehavior()
+{
+ puts(">>ANSNA MultistepBehavior start");
+ OUTPUT = 0;
+ ANSNA_INIT();
+ ANSNA_AddOperation(Encode_Term("op_goto_switch"), ANSNA_Lightswitch_GotoSwitch);
+ ANSNA_AddOperation(Encode_Term("op_activate_switch"), ANSNA_Lightswitch_ActivateSwitch);
+ for(int i=0; i<5; i++)
+ {
+ ANSNA_AddInputBelief(Encode_Term("start_at"));
+ ANSNA_AddInputBelief(Encode_Term("op_goto_switch"));
+ ANSNA_Cycles(10);
+ ANSNA_AddInputBelief(Encode_Term("switch_at"));
+ ANSNA_AddInputBelief(Encode_Term("op_activate_switch"));
+ ANSNA_AddInputBelief(Encode_Term("switch_active"));
+ ANSNA_Cycles(5);
+ ANSNA_AddInputBelief(Encode_Term("light_active"));
+ ANSNA_Cycles(100);
+ }
+ ANSNA_AddInputBelief(Encode_Term("start_at"));
+ ANSNA_AddInputGoal(Encode_Term("light_active"));
+ ANSNA_Cycles(100);
+ assert(ANSNA_Lightswitch_GotoSwitch_executed && !ANSNA_Lightswitch_ActivateSwitch_executed, "ANSNA needs to go to the switch first");
+ ANSNA_Lightswitch_GotoSwitch_executed = false;
+ puts("ANSNA arrived at the switch");
+ ANSNA_AddInputBelief(Encode_Term("switch_at"));
+ ANSNA_AddInputGoal(Encode_Term("light_active"));
+ assert(!ANSNA_Lightswitch_GotoSwitch_executed && ANSNA_Lightswitch_ActivateSwitch_executed, "ANSNA needs to activate the switch");
+ puts("<<ANSNA MultistepBehavior successful");
+}
+
int main(int argc, char *argv[])
{
//printf("sizeof concept %d\n",(int) sizeof(Concept));
@@ -488,6 +531,7 @@ int main(int argc, char *argv[])
ANSNA_Procedure_Test();
Memory_Test();
ANSNA_Follow_Test();
+ ANSNA_MultiStepBehavior();
puts("\nAll tests ran successfully, if you wish to run examples now, just pass the corresponding parameter:");
puts("ANSNA pong (starts Pong example)");
puts("ANSNA numeric-pong (starts Pong example with numeric input)");
