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

Function explain_trace

Core/SoarKernel/src/explain.cpp:406–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

404 **************************************************************************/
405
406void explain_trace(agent* thisAgent, char* chunk_name, backtrace_str* prod_list, condition* ground)
407{
408
409 int count;
410 condition* match, *target;
411 backtrace_str* prod;
412
413 /* Find which prod. inst. tested the ground originally to get
414 it included in the chunk.
415 Need to check potentials too, in case they got included
416 later on. */
417
418 prod = prod_list;
419 match = NULL;
420 while (prod != NULL && match == NULL)
421 {
422 match = explain_find_cond(ground, prod->potentials);
423 if (match == NULL)
424 {
425 match = explain_find_cond(ground, prod->grounds);
426 }
427 if (match == NULL)
428 {
429 match = explain_find_cond(ground, prod->negated);
430 }
431 if (match == NULL)
432 {
433 prod = prod->next_backtrace;
434 }
435 }
436
437 if (match == NULL)
438 {
439 print(thisAgent, "EXPLAIN: Error, couldn't find the ground condition\n");
440 return;
441 }
442
443 print(thisAgent, "Explanation of why condition ");
444 print_condition(thisAgent, ground);
445 print(thisAgent, " was included in %s\n\n", chunk_name);
446
447 print(thisAgent, "Production %s matched\n ", prod->prod_name);
448 print_condition(thisAgent, match);
449 print(thisAgent, " which caused\n");
450
451 /* Trace back the series of productions to find which one
452 caused the matched condition to be created.
453 Build in a safety limit of tracing 50 productions before cancelling.
454 This is in case there is a loop in the search procedure somehow or
455 a really long sequence of production firings. Either way you probably
456 don't want to see more than 50 lines of junk.... */
457
458 target = prod->trace_cond;
459 count = 0;
460
461 while (prod->result == false && count < 50 && match != NULL)
462 {
463 prod = prod_list;

Callers 2

ExplainChunksFunction · 0.85
explain_chunkFunction · 0.85

Calls 4

explain_find_condFunction · 0.85
printFunction · 0.85
print_conditionFunction · 0.85

Tested by

no test coverage detected