MCPcopy Create free account
hub / github.com/SoarGroup/Soar / create_new_context

Function create_new_context

Core/SoarKernel/src/decide.cpp:2881–2977  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2879------------------------------------------------------------------ */
2880
2881void create_new_context(agent* thisAgent, Symbol* attr_of_impasse, byte impasse_type)
2882{
2883 Symbol* id;
2884
2885 if (thisAgent->bottom_goal)
2886 {
2887 /* Creating a sub-goal (or substate) */
2888 id = create_new_impasse(thisAgent, true, thisAgent->bottom_goal,
2889 attr_of_impasse, impasse_type,
2890 static_cast<goal_stack_level>(thisAgent->bottom_goal->id->level + 1));
2891 id->id->higher_goal = thisAgent->bottom_goal;
2892 thisAgent->bottom_goal->id->lower_goal = id;
2893 thisAgent->bottom_goal = id;
2894 add_impasse_wme(thisAgent, id, thisAgent->quiescence_symbol,
2895 thisAgent->t_symbol, NIL);
2896 if ((NO_CHANGE_IMPASSE_TYPE == impasse_type) &&
2897 (thisAgent->sysparams[MAX_GOAL_DEPTH] < thisAgent->bottom_goal->id->level))
2898 {
2899 // appear to be SNC'ing deep in goalstack, so interrupt and warn user
2900 // KJC note: we actually halt, because there is no interrupt function in SoarKernel
2901 // in the gSKI Agent code, if system_halted, MAX_GOAL_DEPTH is checked and if exceeded
2902 // then the interrupt is generated and system_halted is set to false so the user can recover.
2903 print(thisAgent, "\nGoal stack depth exceeded %d on a no-change impasse.\n", thisAgent->sysparams[MAX_GOAL_DEPTH]);
2904 print(thisAgent, "Soar appears to be in an infinite loop. \nContinuing to subgoal may cause Soar to \nexceed the program stack of your system.\n");
2905 xml_generate_warning(thisAgent, "\nGoal stack depth exceeded on a no-change impasse.\n");
2906 xml_generate_warning(thisAgent, "Soar appears to be in an infinite loop. \nContinuing to subgoal may cause Soar to \nexceed the program stack of your system.\n");
2907 thisAgent->stop_soar = true;
2908 thisAgent->system_halted = true;
2909 thisAgent->reason_for_stopping = "Max Goal Depth exceeded.";
2910 }
2911 }
2912 else
2913 {
2914 /* Creating the top state */
2915 id = create_new_impasse(thisAgent, true, thisAgent->nil_symbol,
2916 NIL, NONE_IMPASSE_TYPE,
2917 TOP_GOAL_LEVEL);
2918 thisAgent->top_goal = id;
2919 thisAgent->bottom_goal = id;
2920 thisAgent->top_state = thisAgent->top_goal;
2921 id->id->higher_goal = NIL;
2922 id->id->lower_goal = NIL;
2923 }
2924
2925 id->id->isa_goal = true;
2926 id->id->operator_slot = make_slot(thisAgent, id, thisAgent->operator_symbol);
2927 id->id->allow_bottom_up_chunks = true;
2928
2929 allocate_with_pool(thisAgent, &(thisAgent->rl_info_pool), &(id->id->rl_info));
2930 id->id->rl_info->previous_q = 0;
2931 id->id->rl_info->reward = 0;
2932 id->id->rl_info->gap_age = 0;
2933 id->id->rl_info->hrl_age = 0;
2934 allocate_with_pool(thisAgent, &(thisAgent->rl_et_pool), &(id->id->rl_info->eligibility_traces));
2935#ifdef USE_MEM_POOL_ALLOCATORS
2936 id->id->rl_info->eligibility_traces = new(id->id->rl_info->eligibility_traces) rl_et_map(std::less< production* >(), soar_module::soar_memory_pool_allocator< std::pair< production*, double > >(thisAgent));
2937#else
2938 id->id->rl_info->eligibility_traces = new(id->id->rl_info->eligibility_traces) rl_et_map();

Callers 2

decide_context_slotFunction · 0.85
create_top_goalFunction · 0.85

Calls 8

create_new_impasseFunction · 0.85
add_impasse_wmeFunction · 0.85
printFunction · 0.85
xml_generate_warningFunction · 0.85
make_slotFunction · 0.85
allocate_with_poolFunction · 0.85
soar_invoke_callbacksFunction · 0.85

Tested by

no test coverage detected