ok, let's bite the bullet, an example OpenNARS can do due to the flexible higher order reasoning, goal spikes to rescue!
@@ -191,7 +191,6 @@ void Memory_Test()
puts("<<Memory test successful");
}
-
void ANSNA_Alphabet_Test()
{
ANSNA_INIT();
@@ -329,7 +328,6 @@ void ANSNA_Pong_Right()
{
ANSNA_Pong_Right_executed = true;
}
-
void ANSNA_Pong(bool useNumericEncoding)
{
OUTPUT = 0;
@@ -504,6 +502,42 @@ void ANSNA_Multistep_Test()
assert(!ANSNA_Lightswitch_GotoSwitch_executed && ANSNA_Lightswitch_ActivateSwitch_executed, "ANSNA needs to activate the switch");
puts("<<ANSNA Multistep test successful");
}
+void ANSNA_Multistep2_Test()
+{
+ puts(">>ANSNA Multistep2 test 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_Cycles(100);
+ }
+ ANSNA_Cycles(1000);
+ for(int i=0; i<5; i++)
+ {
+ 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 Multistep2 test successful");
+}
int main(int argc, char *argv[])
{
@@ -532,6 +566,7 @@ int main(int argc, char *argv[])
Memory_Test();
ANSNA_Follow_Test();
ANSNA_Multistep_Test();
+ ANSNA_Multistep2_Test();
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)");
