Soar Kernel  9.3.2 08-06-12
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
agent.h
Go to the documentation of this file.
1 /*************************************************************************
2  * PLEASE SEE THE FILE "license.txt" (INCLUDED WITH THIS SOFTWARE PACKAGE)
3  * FOR LICENSE AND COPYRIGHT INFORMATION.
4  *************************************************************************/
5 
6 /*************************************************************************
7  *
8  * file: agent.h
9  *
10  * =======================================================================
11  * Initialization for the agent structure. Also the cleanup routine
12  * when an agent is destroyed. These routines are usually replaced
13  * by the same-named routines in the Tcl interface file soarAgent.c
14  * The versions in this file are used only when not linking in Tcl.
15  * HOWEVER, this code should be maintained, and the agent structure
16  * must be kept up to date.
17  * =======================================================================
18  */
19 
20 #ifndef AGENT_H
21 #define AGENT_H
22 
23 #ifndef GSYSPARAMS_H
24 #include"gsysparam.h"
25 #endif
26 
27 #include "kernel.h"
28 #include "init_soar.h"
29 #include "mem.h"
30 #include "lexer.h"
31 #include "chunk.h"
32 #include "callback.h"
33 #include <map>
34 
35 #include "soar_module.h"
36 #include "exploration.h"
37 #include "reinforcement_learning.h"
38 #include "wma.h"
39 #include "episodic_memory.h"
40 #include "semantic_memory.h"
41 
42 #include <string>
43 #include <map>
44 
45 // JRV: Added to support XML management inside Soar
46 // These handles should not be used directly, see xml.h
47 typedef void* xml_handle;
48 
49 /* JC ADDED: Included so we can put the RHS functions in here */
51 
52 // select types
54 
55 #ifdef __cplusplus
56 //extern "C"
57 //{
58 #endif
59 
60 /* RBD Need more comments here, or should this stuff be here at all? */
61 
62 #define UPDATE_LINKS_NORMALLY 0
63 #define UPDATE_DISCONNECTED_IDS_LIST 1
64 #define JUST_UPDATE_COUNT 2
65 
66 typedef char Bool;
67 typedef union symbol_union Symbol;
69 typedef struct wme_struct wme;
74 typedef struct pi_struct parent_inst;
75 typedef struct preference_struct preference;
78 typedef struct io_wme_struct io_wme;
80 
81 // following def's moved here from old interface.h file KJC nov 05
82 /* AGR 568 begin */
83 typedef struct expansion_node {
87 
88 typedef struct alias_struct {
89  char *alias;
91  struct alias_struct *next;
92 } alias_struct;
93 
94 typedef struct dir_stack_struct {
95  char *directory;
98 /* AGR 568 end */
99 
100 
101 /* This typedef makes soar_callback_array equivalent to an array of list
102  pointers. Since it was used only one time, it has been commented out
103  here and spelled out completely in that particular instance -ajc
104  (5/3/02)
105 */
106 //typedef list * soar_callback_array[NUMBER_OF_CALLBACKS];
107 
108 typedef signed short goal_stack_level;
109 
110 /* AGR 564 begins */
111 
112 /* !!!!!!!!!!!!!!!! here's the agent structure !!!!!!!!!!!!!!!!!!!!!!!!*/
113 /*----------------------------------------------------------------------*/
114 /* */
115 /* Agent structure used to hold what were previously global variables */
116 /* in the single-agent Soar. */
117 /* */
118 /*----------------------------------------------------------------------*/
119 
120 /* WARNING!! If you add a new global into the Soar C code, be
121  sure to use the current_agent macro to ensure compatibility
122  with the multi-agent code! E.g. if your new global is "foo"
123  then do NOT refer to it in the code as "foo" but instead as
124  "current_agent(foo)".
125 
126  As of version 8.6, the current_agent macro was deprecated
127  when gSKI was added as a wrapper. Use ptr directly, thisAgent->foo. */
128 
129 
130 /* If you define a new global, initialize it in the create_soar_agent
131  routine. AGR 527c 3-May-94 */
132 
134 typedef struct token_struct token;
135 typedef char * test;
136 
138 
139 typedef struct agent_struct {
140  /* After v8.6.1, all conditional compilations were removed
141  * from struct definitions, including the agent struct below
142  */
143 
144  /* ----------------------- Rete stuff -------------------------- */
145  /*
146  * These are used for statistics in rete.cpp. They were originally
147  * global variables, but in the deglobalization effort, they were moved
148  * to the (this) agent structure.
149  */
150  uint64_t actual[256], if_no_merging[256], if_no_sharing[256];
151 
155 
159 
161 
163 
164  //
165  // Moved here from parser.cpp. This is used to create temporary unique
166  // identifiers for parsing. This should probably be localized to the
167  // production, but for now, this is much better than having it as a
168  // global.
169  //
170  uint64_t placeholder_counter[26];
171 
172  //
173  // Used to be a global, this has been moved here from recmem.cpp
174  //
176 
177  //
178  // This was taked from reorder.cpp, but it is also used in production.cpp
179  //
181 
182  //
183  // These was taked from print.
186 
187  //
188  // This was taken from production.h
189  //
191 
194 
195  /* Hash tables for alpha memories, and for entries in left & right memories */
196  void * left_ht;
197  void * right_ht;
199 
200  /* Number of WMEs, and list of WMEs, the Rete has been told about */
203 
204  /* Memory pools */
212 
214 
218 
223 
228 
233 
234  /* Dummy nodes and tokens */
237 
238  /* Various Rete statistics counters */
239  uint64_t rete_node_counts[256];
241  uint64_t token_additions;
247 
248 
249  /* Miscellaneous other stuff */
250  uint32_t alpha_mem_id_counter; /* node id's for hashing */
252  struct ms_change_struct * ms_assertions; /* changes to match set */
254 
255  /* ----------------------- Lexer stuff -------------------------- */
256 
257  lexer_source_file * current_file; /* file we're currently reading */
258  int current_char; /* holds current input character */
259  struct lexeme_info lexeme; /* holds current lexeme */
261 
262  /* ---------------- Predefined Symbols -------------------------
263  Certain symbols are used so frequently that we create them at
264  system startup time and never deallocate them.
265  ------------------------------------------------------------- */
266 
298  Symbol * wait_symbol; /* REW: 10.24.97 */
299 
300  Symbol * item_count_symbol; // SBW 5/07
302 
303 
304  /* RPM 9/06 begin */
307  /* RPM 9/06 end */
308 
312 
316 
333 
345 
349 
355 
361 
362 
363  /* ----------------------- Symbol table stuff -------------------------- */
364 
366  uint64_t id_counter[26];
367 
373 
379 
380  /* ----------------------- Top-level stuff -------------------------- */
381 
382  /* --- headers of dll's of all productions of each type --- */
384  /* --- counts of how many productions there are of each type --- */
386 
387  /* --- lists of symbols (PS names) declared chunk-free and chunky --- */
389  ::list * chunky_problem_spaces; /* AGR MVL1 */
390 
391  /* --- default depth for "print" command --- */
392  int default_wme_depth; /* AGR 646 */
393 
394  /* --- stuff for "input-period" command --- */
395  /* --- in Soar8, input runs once at beginning of D cycle, no matter what */
396  int input_period; /* AGR REW1 */
397  Bool input_cycle_flag; /* AGR REW1 */
398 
399  /* --- current top level phase --- */
401 
402  /* --- to interrupt at the end of the current phase, set stop_soar to TRUE
403  and reason_for_stopping to some appropriate string --- */
405  const char * reason_for_stopping;
406 
407  /* --- the RHS action (halt) sets this TRUE --- */
409 
410  /* --- stuff for max-chunks (which is a sysparam) --- */
411  uint64_t chunks_this_d_cycle; /* # chunks built this DC */
413 
414  /* --- list of productions whose firings are being traced --- */
416 
417  /* --- various user-settable system parameters --- */
419 
420  /* --- parameters for running Soar --- */
421  /* --- the code loops go_number times over the go_type phases --- */
422  int64_t go_number; /* How many times to "go" */
423  Symbol * go_slot_attr; /* The context slot checked */
424  goal_stack_level go_slot_level; /* The goal stack level checked */
425  enum go_type_enum go_type; /* The phase type used */
426 
427  /* --- Top-level Statistics --- */
428 
429  /* running total of WM sizes at end of phases */
431  /* number of items included in "cumulative_wm_size" sum */
433 
434  uint64_t max_wm_size; /* maximum size of WM so far */
435  uint64_t wme_addition_count; /* # of wmes added to WM */
436  uint64_t wme_removal_count; /* # of wmes removed from WM */
437 
438  uint64_t start_dc_wme_addition_count; /* for calculating max_dc_wm_changes */
439  uint64_t start_dc_wme_removal_count; /* for calculating max_dc_wm_changes */
440  uint64_t max_dc_wm_changes_value; /* # of wmes added + removed in a single dc */
441  uint64_t max_dc_wm_changes_cycle; /* # cycle of max_dc_wm_changes */
442 
443  uint64_t d_cycle_count; /* # of DC's run so far */
444  uint64_t e_cycle_count; /* # of EC's run so far */
445  /* in Soar 8, e_cycles_this_d_cycle is reset to zero for every
446  propose and apply phase */
447  uint64_t e_cycles_this_d_cycle; /* # of EC's run this DC */
448  uint64_t num_existing_wmes; /* current WM size */
449  uint64_t production_firing_count; /* # of prod. firings */
450  uint64_t start_dc_production_firing_count; /* # of prod. firings this decision cycle */
451  uint64_t max_dc_production_firing_count_value; /* max # of prod. firings per dc */
452  uint64_t max_dc_production_firing_count_cycle; /* cycle of max_dc_production_firing_count_value */
453  uint64_t d_cycle_last_output; /* last time agent produced output */ //KJC 11.17.05
454  uint64_t decision_phases_count; /* can differ from d_cycle_count. want for stats */
455  //?? uint64_t out_cycle_count; /* # of output phases have gen'd output */
456  //?? uint64_t phase_count; /* # of phases run so far */
457  /* DJP 2/22/07: These counts are based around the counts that the run command understands and are intended to capture the same semantics as run expects.
458  That may differ from some of the other counters above which historically may track slightly different values */
459  uint64_t run_phase_count ; /* # of phases run since last init-soar */
460  uint64_t run_elaboration_count ; /* # of elaboration cycles run since last init-soar. A phase where nothing happens counts as an elaboration cycle */
461  uint64_t run_last_output_count ; /* # of output phases since this agent last generated output */
462  uint64_t run_generated_output_count ; /* # of output phases when this agent either generated output or reached "max-nil-output" cycles since last init-soar */
463 
464  /* REW: begin 09.15.96 */
465 /* in Soar 8, PE's are done only during the APPLY phase */
466  uint64_t pe_cycle_count; /* # of PE's run so far */
467  uint64_t pe_cycles_this_d_cycle; /* # of PE's run this DC */
468 
470 /* REW: end 09.15.96 */
471 
472  /* State for new waterfall model */
473  uint64_t inner_e_cycle_count; /* # of inner elaboration cycles run so far */
474 
475  /* ----------------------- Timing statistics -------------------------- */
476 
477 /*
478 For Soar 7, the timing code has been completely revamped. When the compile
479 flag NO_TIMING_STUFF is not set, statistics will be now be collected on the
480 total cpu time, total kernel time, time spent in the individual phases of a
481 decision cycle, time spent executing the input and output functions, and time
482 spent executing callbacks (or monitors). When the DETAILED_TIMING_STATS flag
483 is set, additional statistics will be collected for ownership, match, and
484 chunking computations according to the phase in which they occur. (Notice
485 that DETAILED_TIMING_STATS can only be collected when NO_TIMING_STUFF is not
486 true.)
487 
488 The total_cpu_time is turned on when one of the run_<x> functions is
489 initiated. This timer is not turned off while the do_one_top_level_phase()
490 function is executing. The total_kernel_time timer is turned on just after
491 the total_cpu_time timer and turned off just before the other is turned off.
492 This guarantees that the total kernel time -- including the time it takes to
493 turn on and off the kernel timer -- is a part of the total cpu time. The
494 total_kernel_time is also turned off whenever a callback is initiated or when
495 the input and output functions are executing.
496 
497 The decision_cycle_phase_timers measure the kernel time for each phase of the
498 decision cycle (ie, INPUT_PHASE, PREFERENCE_PHASE, WM_PHASE, OUTPUT_PHASE,
499 and DECISION_PHASE). Each is turned on at the beginning of its corresponding
500 phase in do_one_top_level_phase and turned off at the end of that phase.
501 These timers are also turned off for callbacks and during the execution of
502 the input and output functions.
503 
504 The monitors_cpu_time timers are also indexed by the current phase. Whenever
505 a callback is initiated, both the total_kernel_time and
506 decision_cycle_phase_timer for the current phase are turned off and the
507 monitors_cpu_time turned on. After the callback has terminated, the kernel
508 timers are turned back on. Notice that the same relationship holds here as
509 it did between the total_cpu_time and total_kernel_time timers. The
510 total_kernel_time is always turned off last and turned on first, in
511 comparison to the decision_cycle_phase_timer. This means that turning the
512 decision_cycle_phase_timers on and off is included as part of the kernel time
513 and helps ensure that the total_kernel_time is always greater than the sum of
514 the decision_cycle_timers.
515 
516 The input_function_cpu_time and output_function_cpu_time timers measure the
517 time it takes to execute the input and output functions respectively. Both
518 the total_kernel_time and decision_cycle_phase_timers are turned off when
519 these timers are turned on (with the same ordering as discussed previously).
520 The input function is a little tricky. Because add-wme can be called by the
521 input routine, which then calls do_buffered_wm_and_ownership_changes, we
522 can't just turn off the kernel timers for input and expect to get numbers for
523 both match_time (see next para) and kernel time. The solution implemented in
524 the 28.07.96 changes is to not turn off the kernel timers until the actual
525 INPUT_PHASE_CALLBACK is initiated. This takes care of all but direct
526 additions and removals of WMEs. Since these are done through the add-wme and
527 remove-wme commands, the input_timer is turned off there was well, and the
528 kernel timers turned back on (for the buffered wm changes). However, this is
529 a hack and may introduce problems when add-wme and remove-wme are used at the
530 command line or someplace in the decision cycle other than input (probably
531 rare but possible).
532 
533 The DETAILED_TIMING_STATS flag enables collection of statistics on match,
534 ownership and chunking calculations performed in each part of the decision
535 cycle. An 'other' value is reported which is simply the difference between
536 the sum of the deailed timers and the kernel timer for some pahse. The other
537 value should always be greater than or equal to zero.
538 
539 The "stats" command (in soarCommandUtils) has been updated to report these
540 new timing values. The output is provided in a spreadsheet-style format to
541 display the information in a succinct form. There are also some derived
542 totals in that report. The derived totals in the right column are simply the
543 sum of the all the other columns in a particular row; for example, the
544 derived total for the first row, kernel time, is just the sum of all the
545 decision_cycle_phase_timers. The derived totals in the bottom row are the
546 sum of all the basic timers in that row (i.e., no DETAILED statistics are
547 included in the sum). For example, the derived total under input is equal to
548 the sum of decision_cycle_phase_timer and the monitors_time for the
549 INPUT_PHASE, and the input_function_cpu_time and represents the total time
550 spent in the input phase for the current run. The number in the lower
551 right-hand corner is the sum of the derived totals above it in that right
552 column (and should always be equal to the numbers to the left of it in that
553 row).
554 
555 Also reported with the stats command are the values of total_cpu_time and
556 total_kernel_time. If the ordering discussed above is strictly enforced,
557 total_kernel_time should always be slightly greater than the derived total
558 kernel time and total_cpu_time greater than the derived total CPU time. REW */
559 
560  /* REW: begin 28.07.96 */
561 #ifndef NO_TIMING_STUFF
562  soar_process_timer timers_cpu; // start_total_tv
563  soar_process_timer timers_kernel; // start_kernel_tv
564  soar_process_timer timers_phase; // start_phase_tv
565 
566  soar_timer_accumulator timers_total_cpu_time; // total_cpu_time
567  soar_timer_accumulator timers_total_kernel_time; // total_kernel_time
568  soar_timer_accumulator timers_decision_cycle_phase[NUM_PHASE_TYPES]; // decision_cycle_phase_timers
569 
570  soar_timer_accumulator timers_monitors_cpu_time[NUM_PHASE_TYPES]; // monitors_cpu_time, uses timers_phase
571  soar_timer_accumulator timers_input_function_cpu_time; // input_function_cpu_time, uses timers_kernel
572  soar_timer_accumulator timers_output_function_cpu_time; // output_function_cpu_time, uses timers_kernel
573 
574  uint64_t last_derived_kernel_time_usec; // Total of the time spent in the phases of the decision cycle,
575  // excluding Input Function, Output function, and pre-defined callbacks.
576  // Computed at the end of the output phase, so it is not valid for current
577  // phase until then.
578  uint64_t max_dc_time_usec; // Holds maximum amount of decision cycle time
579  uint64_t max_dc_time_cycle; // Holds cycle_count that maximum amount of decision cycle time happened
580 
581  double max_dc_epmem_time_sec; // Holds maximum amount epmem time
582  double total_dc_epmem_time_sec; // Holds last amount epmem time, used to calculate delta
583  uint64_t max_dc_epmem_time_cycle; // Holds what cycle max_dc_epmem_time_sec was acheived
584 
585  double max_dc_smem_time_sec; // Holds maximum amount smem time
586  double total_dc_smem_time_sec; // Holds last amount smem time, used to calculate delta
587  uint64_t max_dc_smem_time_cycle; // Holds what cycle max_dc_smem_time_sec was acheived
588 
589  soar_timer_accumulator callback_timers[NUMBER_OF_CALLBACKS];
590 
591  /* accumulated cpu time spent in various parts of the system */
592  /* only used if DETAILED_TIMING_STATS is #def'd in kernel.h */
593 #ifdef DETAILED_TIMING_STATS
594  soar_process_timer timers_gds; // start_gds_tv
595  soar_timer_accumulator timers_ownership_cpu_time[NUM_PHASE_TYPES]; // ownership_cpu_time
596  soar_timer_accumulator timers_chunking_cpu_time[NUM_PHASE_TYPES]; // chunking_cpu_time
597  soar_timer_accumulator timers_match_cpu_time[NUM_PHASE_TYPES]; // match_cpu_time
598  soar_timer_accumulator timers_gds_cpu_time[NUM_PHASE_TYPES]; // gds_cpu_time
599 #endif // DETAILED_TIMING_STATS
600  /* REW: end 28.07.96 */
601 #endif // NO_TIMING_STUFF
602 
603  /* RMJ */
604  /* Keep track of real time steps for constant real-time per decision */
605  /* used only if #def'd REAL_TIME_BEHAVIOR */
606  struct timeval *real_time_tracker;
608 
609  /* RMJ */
610  /* Keep track of duration of attentional lapses */
611  /* Used only if #def'd ATTENTION_LAPSE in */
612  struct timeval *attention_lapse_tracker;
614 
615 
616  /* ----------------------- Chunker stuff -------------------------- */
617 
620  uint64_t chunk_count;
637 
638  /* ----------------------- Misc. top-level stuff -------------------------- */
639 
645 
646  /* ----------------------- Reorderer stuff -------------------------- */
647 
649 
650  /* ----------------------- Memory utilities -------------------------- */
651 
652  /* Counters for memory usage of various types */
654 
655  /* List of all memory pools being used */
657 
658  memory_pool cons_cell_pool; /* pool for cons cells */
659  memory_pool dl_cons_pool; /* doubly-linked list cells */
660 
661  /* ----------------------- Explain.c stuff -------------------------- */
662 
665  char explain_chunk_name[256]; /* AGR 564 */
666  /* made explain_flag EXPLAIN_SYSPARAM instead, KJC 7/96 */
667  /* Bool explain_flag; */
668 
669  /* ----------------------- Firer stuff -------------------------- */
670 
673 
674  /* production_being_fired -- during firing, points to the prod. being fired */
676 
679 
680  /* ==================================================================
681  Decider stuff
682  =================================================================== */
683 
685 
690 
691  /* ---------------------------------------------------------------------
692  Top_goal and bottom_goal point to the top and bottom goal identifiers,
693  respectively. (If there is no goal stack at all, they're both NIL.)
694  Top_state points to the top state (symbol) if there is a top state, and
695  is NIL of there isn't any top state selected.
696  --------------------------------------------------------------------- */
697 
701 
707 
718 
719  /* ------------------ Printing utilities stuff --------------------- */
720 
724 
725  /* ----------------------- Trace Formats -------------------------- */
726 
733 
734  ::list * wme_filter_list; /* kjh(CUSP-B2) */
735 
736  /* ----------------------- RHS Function Stuff -------------------------- */
737 
738  /* --- "make-constant-symbol" counter --- */
739  uint64_t mcs_counter;
740 
741  /* ----------------------- O support stuff -------------------------- */
742 
745 
746  /* ----------------------- I/O stuff -------------------------- */
747 
750 
754 
756 
759 
762 
765 
766  /* ------------ Varible Generator stuff (in production.c) ---------------- */
767 
770 
771  /* ------------------- Experimental features ---------------------- */
773 
774  /* ------------------- Info about the agent itself ---------------------- */
775 
776  char * name; /* name of this Soar agent */
777 
778 /* --------- I (RBD) don't know what the following stuff is ------------ */
779 
780  /* Soar uses these to generate nicely formatted output strings */
781  char current_line[1024];
783 
784  /*mvp 5-17-94 */
786 
788  /* char path[MAXPATHLEN]; AGR 568 */
789 
790  //soar_callback_array soar_callbacks;
792 
793  const char * alternate_input_string;
794  const char * alternate_input_suffix;
795  Bool alternate_input_exit; /* Soar-Bugs #54, TMH */
796  expansion_node * lex_alias; /* AGR 568 */
797  Bool load_errors_quit; /* AGR 527c */
799 
800 
801  /* RCHONG: begin 10.11 */
806 
807  struct ms_change_struct * ms_o_assertions; /* changes to match set */
808  struct ms_change_struct * ms_i_assertions; /* changes to match set */
809  /* RCHONG: end 10.11 */
810 
811  struct ms_change_struct * postponed_assertions; /* New waterfall model: postponed assertion list */
812 
813  /* REW: begin 08.20.97 */
818  struct ms_change_struct *nil_goal_retractions; /* dll of all retractions for removed (ie nil) goals */
819  /* REW: end 08.20.97 */
820 
842 
843  /* delineate btwn Pref/WM(propose) and Pref/WM(apply) KJC 10.05.98 */
845 
846  /* REW: begin 10.24.97 */
849  /* REW: end 10.24.97 */
850 
851  /* JC ADDED: Need to store RHS functions here so that agent's don't step on each other */
853 
854  enum ni_mode numeric_indifferent_mode; /* SW 08.19.2003 */
855 
856  // exploration
858 
859  // reinforcement learning
863 
865 
866  // select
868 
869  // predict
871  std::string *prediction;
872 
873  // wma
877 
881 
882  unsigned int wma_power_size;
889 
890  // epmem
894 
898 
899 
901  std::vector<epmem_time_id> *epmem_node_mins;
902  std::vector<bool> *epmem_node_maxes;
903 
905  std::vector<epmem_time_id> *epmem_edge_mins;
906  std::vector<bool> *epmem_edge_maxes;
907 
912 
915 
917 
920 
921 
922  // smem
926 
929 
930  uint64_t smem_validation;
932  int64_t smem_max_cycle;
933 
936 
937  // dynamic memory pools
938  std::map< size_t, memory_pool* >* dyn_memory_pools;
939 
940  // dynamic RHS counters
941  std::map< std::string, uint64_t >* dyn_counters;
942 
943 
944  // JRV: Added to support XML management inside Soar
945  // These handles should not be used directly, see xml.h
946  xml_handle xml_destination; // The current destination for all XML generation, essentially either == to xml_trace or xml_commands
947  xml_handle xml_trace; // During a run, xml_destination will be set to this pointer.
948  xml_handle xml_commands; // During commands, xml_destination will be set to this pointer.
949 
950  // stats database
954 
955  // Soar execution will be interrupted when this substate level is removed
957 
958 } agent;
959 /*************** end of agent struct *****/
960 
961 void init_soar_agent(agent* thisAgent);
962 
963 #ifdef USE_MACROS
964 
965 #define allocate_cons(thisAgent, dest_cons_pointer) \
966  allocate_with_pool (thisAgent, &thisAgent->cons_cell_pool, (dest_cons_pointer))
967 
968 #define free_cons(thisAgent, c) free_with_pool (&thisAgent->cons_cell_pool, (c))
969 
970 #define push(thisAgent, item, list_header) { \
971  cons *push_cons_xy298; \
972  allocate_cons (thisAgent, &push_cons_xy298); \
973  push_cons_xy298->first = (item); \
974  push_cons_xy298->rest = (list_header); \
975  (list_header) = push_cons_xy298; }
976 
977 #else
978 
979 #ifdef __cplusplus
980 //}
981 #endif
982 
983 template <typename T>
984 inline void allocate_cons(agent* thisAgent, T * dest_cons_pointer)
985 {
986  allocate_with_pool (thisAgent, &thisAgent->cons_cell_pool, (dest_cons_pointer));
987 }
988 
989 template <typename T>
990 inline void free_cons(agent* thisAgent, T * c)
991 {
992  free_with_pool (&thisAgent->cons_cell_pool, (c));
993 }
994 
995 template <typename P, typename T>
996 inline void push(agent* thisAgent, P item, T * & list_header)
997 {
998  cons *push_cons_xy298;
999  allocate_cons (thisAgent, &push_cons_xy298);
1000  push_cons_xy298->first = (item);
1001  push_cons_xy298->rest = (list_header);
1002  (list_header) = push_cons_xy298;
1003 }
1004 
1005 #ifdef __cplusplus
1006 //extern "C"
1007 //{
1008 #endif
1009 
1010 #endif /* USE_MACROS */
1011 
1012 //extern char * soar_version_string;
1013 
1014 //extern agent * soar_agent;
1015 
1016 extern agent * create_soar_agent (char * name);
1017 extern void destroy_soar_agent (agent* soar_agent);
1018 
1019 //void initialize_soar_agent(Kernel *thisKernel, agent* thisAgent);
1020 //
1021 /* Ideally, this should be in "lexer.h", but to avoid circular dependencies
1022  among header files, I am forced to put it here. */
1023 #ifdef USE_MACROS
1024 #define reading_from_top_level(soar_agent) (!soar_agent->current_file->parent_file)
1025 #else
1026 
1028 {
1029  return (!soarAgent->current_file->parent_file);
1030 }
1031 
1032 #endif /* USE_MACROS */
1033 
1034 #ifdef __cplusplus
1035 //}
1036 #endif
1037 
1038 #endif
1039