1/*
    2
    3* &ght;module> 
    4% This file loads the world (world.pl), the map of the world, 
    5% the agents and their definitions.
    6% This file is used as a configuation file and a startup script.
    7%
    8% July 10,1996
    9% John Eikenberry
   10%
   11% Logicmoo Project PrologMUD: A MUD server written in Prolog
   12% Maintainer: Douglas Miles
   13% Dec 13, 2035
   14%
   15*/
   16
   17%:- if(( ( \+ ((current_prolog_flag(logicmoo_include,Call),Call))) )). 
   18% :- module(mud_loader,[]).
   19%:- endif.
   20%:- set_prolog_flag(pfc_booted,false).
   21
   22
   23
   24:- thread_local(t_l:disable_px/0).   25% :- must(\+ t_l:disable_px).
   26:- retractall(t_l:disable_px).
   32% UNDO % :- add_import_module(baseKB,world,end).
   33% % UNDO % :- add_import_module(baseKB,baseKB,end).
   34% UNDO % :- add_import_module(baseKB,mud_testing,end).
   35% UNDO % :- add_import_module(baseKB,mud_telnet,end).
   36% UNDO % :- add_import_module(mud_testing,mud_telnet,end).
   37% UNDO % :- add_import_module(mud_telnet,world,end).
   38% UNDO % :- add_import_module(baseKB,lmcache,end).
   39% % UNDO % :- add_import_module(baseKB,world,end).
   40
   41:- dynamic   user:file_search_path/2.   42:- multifile user:file_search_path/2.   43
   44:- op(200,fy,(-)).   45
   46:- set_prolog_flag(verbose_load,true).   47
   48
   49
   50:- dynamic user:prolog_load_file/2.   51:- multifile user:prolog_load_file/2.   52:- module_transparent user:prolog_load_file/2.   53
   54user:prolog_load_file(ModuleSpec, Options) :-
   55 Found = f(_),
   56 once((
   57 strip_module(ModuleSpec, Module, Spec),
   58 nonvar(Spec),
   59 contains_wildcard(Spec),
   60 forall((enumerate_files(ModuleSpec,Result),exists_file(Result)),
   61   (load_files(Module:Result,Options),nb_setarg(1,Found,true))))),
   62 ground(Found),!.
   63 
   64
   65%:- include(mud_header).
   66
   67
   68:- set_prolog_flag(generate_debug_info, true).   69% [Optionaly] Set the Prolog optimize/debug flags
   70%:- set_prolog_flag(verbose_load,true).
   71%:- use_module(library(gui_tracer)).
   72%:- set_prolog_flag(gui_tracer, false).
   73%:- set_prolog_flag(answer_write_options, [quoted(true), portray(true), max_depth(1000), spacing(next_argument)]).
   74%:- catch(noguitracer,_,true).
   75
   76
   77%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   78:- dmsg("[Optional] Load the Logicmoo Early Network System").   79%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   80:- if(\+ app_argv('--nonet')).   81:- whenever_flag_permits(load_network,load_library_system(library(logicmoo_network))).   82:- endif.   83
   84:- user:use_module(library(logicmoo_utils_all)).   85
   86% ==============================================
   87% [Required] Load the Logicmoo User System
   88% ==============================================
   89:- user:load_library_system(library(logicmoo_lib)).   90
   91:- use_module(library(logicmoo/butterfly_console)).   92
   93
   94:- if(\+ app_argv('--nonet')).   95:- whenever_flag_permits(load_network,load_library_system(library(logicmoo_webbot))).   96:- endif.   97
   98% [Optionaly] Set up the Prolog optimize/debug flags
   99%:- set_prolog_flag(debug,false).
  100%:- set_optimize(true).
  101
  102
  103% [Optionaly] load the mpred_online system
  104% :- if_file_exists(ensure_loaded(library(logicmoo/mpred_online))).
  105
  106:- if( \+ user:file_search_path(prologmud,_)).  107:- prolog_load_context(directory,Dir),
  108   asserta(user:file_search_path(prologmud,Dir)).  109:- endif.  110
  111% xyzFn(R,X,Y,Z):-dmsg(xyzFn(R,X,Y,Z)),trace_or_throw(xyzFn(R,X,Y,Z)).
  112
  113% :- multifile prolog:message/3.
  114% prolog:message(git(update_versions),A,A):-!.
  115
  116:- use_module(library(settings)).  117% :- use_module(library(check)).
  118% :- make.
  119%:- portray_text(true).
  120
  121/*
  122:-set_prolog_stack(global, limit(32*10**9)).
  123:-set_prolog_stack(local, limit(32*10**9)).
  124:-set_prolog_stack(trail, limit(32*10**9)).
  125*/
  126
  127:- multifile( entailment:rdf /3 ).  128
  129% [Optionaly] Solve the Halting problem
  130:-use_module(library(process)).  131% :-use_module(library(pce)).
  132:- has_gui_debug -> true ; remove_pred(pce_principal,send,2).  133:- has_gui_debug -> true ; remove_pred(pce_principal,new,2).  134
  135
  136:- export(add_game_dir/2).  137add_game_dir(GAMEDIR,Else):- add_to_search_path_first(game, GAMEDIR),now_try_game_dir(Else).
  138
  139
  140now_try_game_dir(Else):-  
  141 enumerate_files(game('.'), GAMEDIR) *-> 
  142  ((exists_directory(GAMEDIR) -> 
  143    with_all_dmsg(( 
  144      % forall(enumerate_files(game('**/*.pl'),X),ensure_loaded(X)),
  145      forall(no_repeats_old(X,enumerate_files(game('*.pfc.pl'),X)),declare_load_dbase(X)))); (wdmsg(missing(GAMEDIR)),Else)));  (wdmsg(no_game_dir),Else).
  146
  147
  148:-context_module(CM),assert(loading_from_cm(CM)).  149create_module(M):-current_module(M),!.
  150create_module(M):-context_module(CM),module(M),asserta(M:this_is_a_module(M)),writeq(switching_back_to_module(M,CM)),module(CM).
  151:-create_module(user).  152:-create_module(t_l).  153%:-create_module(baseKB).
  154%:-create_module(moo).
  155
  156
  157:-module_transparent parser_chat80_module/1.  158:-multifile parser_chat80_module/1.  159:-export((parser_chat80_module/1)).  160parser_chat80_module(moo).
  161
  162
  163
  164:-export(prolog_repl/0).  165
  166prolog_repl:- !, with_all_dmsg((nl,fmt("Press Ctrl-D to resume to the mud!"),nl,!,call_u(break))).
  167/*
  168prolog_repl:- with_all_dmsg((nl,fmt("Press Ctrl-D to resume to the mud!"),nl,
  169  current_input(In),
  170  current_output(Out),
  171  % current_error(Err),
  172  /*must(lmcache:main_thread_error_stream(Err)),*/
  173  set_prolog_IO(In,Out,Out),
  174  % must(get_thread_current_error(O)),
  175  with_ioe(call_u(break)))).
  176*/
  177
  178%:- set_prolog_flag(gui,false).
  179%:- set_prolog_flag(history,1000).
  180
  181% :- prolog_ide(debug_monitor),prolog_ide(open_debug_status). % ,prolog_ide(xref).
  182
  183
  184
  185
  186:-export(within_user/1).  187
  188
  189within_user(Call):- '@'(Call,'user').
  190
  191% ======================================================
  192% Configure the logicmoo utilities into the file path
  193% :- include('logicmoo_util/logicmoo_util_header').
  194% :- user:use_module('logicmoo_util/logicmoo_util_all.pl').
  195% And adds the local directories to file search path of logicmoo(..)
  196% ======================================================
  197
  198
  199:- dynamic   user:file_search_path/2.  200:- multifile user:file_search_path/2.  201
  202:- user:use_module(library(settings)).  203
  204:- ignore((user:file_search_path(cliopatria,SP),
  205   exists_directory(SP),!,
  206   writeq(user:file_search_path(cliopatria,SP)),nl)).  207   %set_setting_default(cliopatria_binding:path, SP).
  208   %save_settings('moo_settings.db').
  209   %%setting(cliopatria_binding:path, atom, SP, 'Path to root of cliopatria install'),!.
  210
  211% :- user:use_module(logicmoo('http/user_page')).
  212
  213
  214if_version_greater(V,Goal):- current_prolog_flag(version,F), ((F > V) -> call(Goal) ; true).
  215:- meta_predicate(if_version_greater(?,0)).  216
  217% set to false because we don't want to use the mudconsole
  218:- if_flag_true(false, if_version_greater(70109,baseKB:ensure_loaded(logicmoo('mudconsole/mudconsolestart')))).  219
  220% [Optionaly 1st run] tell where ClioPatria is located and restart for the 2nd run
  221%:- set_setting(cliopatria_binding:path, '/devel/ClioPatria'), save_settings('moo_settings.db').
  222
  223start_boxer:-
  224   %threads,
  225   ensure_loaded(logicmoo(candc/parser_boxer)),
  226   % make,   
  227   runtime_boot(prolog_repl).
  228
  229
  230
  231% We don't start cliopatria we here. We have to manually start
  232%  with  ?- start_servers.
  233hard_work:-!.
  234hard_work:-
  235   with_no_mpred_expansions(locally_hide(op(200,fy,'@'),
  236   ((
  237 %  use_module('t:/devel/cliopatria/rdfql/sparql_runtime.pl'),
  238  % ensure_loaded(logicmoo(launchcliopatria)),
  239  % ensure_loaded(logicmoo(testwebconsole)),
  240  % kill_term_expansion, 
  241   ensure_loaded(swish(logicmoo_run_swish))
  242   )))),!.
  243
  244% [Required] load the mud PFCs
  245%:- set_prolog_flag(pfc_booted,false).
  246
  247:- retractall(t_l:disable_px).  248
  249:- set_prolog_flag(expect_pfc_file,soon).  250:- show_entry(gripe_time(40,ensure_loaded(prologmud('mud_builtin.pfc')))).  251:- set_prolog_flag(expect_pfc_file,never).  252
  253% :- show_entry(gripe_time(40,force_reload_mpred_file(prologmud('mud_builtin.pfc')))).
  254
  255slow_work:- locally_hide( set_prolog_flag(subclause_expansion,false) , within_user(after_boot(hard_work))).
  256
  257thread_work:- thread_property(X, status(running)),X=loading_code,!.
  258thread_work:- thread_create(slow_work,_,[alias(loading_code)]).
  259
  260% start_servers :- if_version_greater(70111,thread_work).
  261start_servers :- if_version_greater(70111,slow_work).
  262
  263run_setup_now:-
  264   within_user((
  265      finish_processing_world      
  266   % TO UNDO register_timer_thread(npc_ticker,90,npc_tick)
  267   )).
  268
  269run_setup:- within_user(after_boot(run_setup_now)).
  270
  271
  272
  273
  274% [Optionaly] load and start sparql server
  275% starts in forground
  276%:- after_boot(slow_work).
  277% starts in thread (the the above was commented out)
  278%:- after_boot(start_servers).
  279% commented out except on run
  280
  281
  282debug_repl_w_cyc(Module,CallFirst):- !,         
  283          locally_hide(t_l:useOnlyExternalDBs,
  284            locally(baseKB:use_cyc_database,
  285               ((decl_type(person),          
  286                ensure_mpred_file_loaded(logicmoo('rooms/startrek.all.pfc.pl')),
  287                module(Module),
  288                show_call(CallFirst), 
  289                prolog_repl)))).
  290debug_repl_wo_cyc(Module,CallFirst):- !,         
  291          locally(t_l:useOnlyExternalDBs,
  292            locally_hide(baseKB:use_cyc_database,
  293               ((decl_type(person),          
  294                ensure_mpred_file_loaded(logicmoo('rooms/startrek.all.pfc.pl')),
  295                module(Module),
  296                show_call(CallFirst), 
  297                prolog_repl)))).
  298
  299%  bug.. swi does not maintain context_module(CM) outside
  300%  of the current caller (so we have no idea what the real context module is!?!)
  301debug_repl_m(Module,CallFirst):- 
  302        context_module(CM),
  303          call_cleanup(
  304            (module(Module),
  305              debug_repl_wo_cyc(Module,CallFirst)),
  306            module(CM)).
  307
  308% [Required] Defines debug80
  309debug80:- parser_chat80_module(M),debug_repl_wo_cyc(M,M:t1).
  310
  311% [Optionaly] Allows testing/debug of the chat80 system (withouyt loading the servers)
  312% :- parser_chat80:t1.
  313
  314% [Required] Defines debug_e2c
  315debug_e2c:- debug_repl_wo_cyc(parser_e2c,cache_the_posms).
  316
  317
  318% [Required] Defines debug_talk
  319debug_talk:- debug_repl_wo_cyc(parser_talk,t3).
  320
  321
  322% [Optional] This loads boxer
  323% :- after_boot(locally(set_prolog_flag(subclause_expansion,false),within_user(ignore(catch(start_boxer,_,true))))).
  324
  325% [Optional] Testing PTTP
  326% :-is_startup_file('run_debug.pl')->doall(do_pttp_test(_));true.
  327
  328% Was this our startup file?
  329was_runs_tests_pl:-is_startup_file('run_tests.pl').
  330
  331% [Optional] Interactively debug E2C
  332% :- debug_e2c.
  333
  334
  335:- ain((mud_test_local :- cwc,if_defined(kellerStorage:kellerStorageTestSuite,true))).  336
  337% :-curt80.
  338
  339
  340% the real tests now (once)
  341:- ain((mud_test_local :- cwc,if_flag_true(was_runs_tests_pl,after_boot(must_det(run_mud_tests))))).  342
  343 % :- if_flag_true(was_runs_tests_pl, doall(now_run_local_tests_dbg)).
  344
  345
  346% [Optionaly] Allows testing/debug of the chat80 system (withouyt loading the servers)
  347% :- debug80.
  348/*
  349
  350explorer(player1)> prolog statistics
  351notice(you,begin(you,req1(statistics)))
  352statistics.
  353188.523 seconds cpu time for 282,024,744 inferences
  3541,004,265 atoms, 14,959 functors, 11,578 predicates, 176 modules, 268,104,937 VM-codes
  355
  356                       Limit    Allocated       In use
  357Local  stack :137,438,953,472      126,976       41,032 Bytes
  358Global stack :137,438,953,472  805,302,256  669,634,856 Bytes
  359Trail  stack :137,438,953,472      129,016        2,448 Bytes
  360
  3611 garbage collections gained 41,528 bytes in 0.000 seconds.
  3622 atom garbage collections gained 19,741 atoms in 1.360 seconds.
  363Stack shifts: 4 local, 22 global, 20 trail in 0.038 seconds.
  3642 threads, 0 finished threads used 0.000 seconds.
  365true.
  366
  367cmdresult(statistics,true)
  368
  369*/
  370
  371% :- kill_term_expansion.
  372% :- slow_work.
  373% :- prolog.
  374% :- now_run_local_tests_dbg.
  375% :- prolog.
  376
  377% :-foc_current_agent(P),assertz_if_new(agent_action_queue(P,chat80)).
  378:- if_flag_true(was_runs_tests_pl, runtime_boot(login_and_run)).  379
  380
  381% So scripted versions don't just exit
  382%:- if_flag_true(was_runs_tests_pl,after_boot(prolog)).
  383
  384%:- kill_term_expansion.
  385%:- prolog.
  386
  387% :-proccess_command_line.
  388
  389/*
  390If we ask, 'What is "Being"?', we keep within an understanding of the 'is', though we are unable to fix conceptionally what that 'is' signifies. We do not even know the horizon in terms of which that meaning is to be grasped and fixed. But irregardless we have this vague average understanding of Being is still a Fact.
  391
  392PTTP input formulas:
  393  1  firstOrder(motherOf,joe,sue).
  394  2  not_firstOrder(motherOf,_,A);firstOrder(female,A).
  395  3  not_firstOrder(sonOf,B,A);firstOrder(motherOf,A,B);firstOrder(fatherOf,A,B).
  396  4  query:-firstOrder(female,_).
  397PTTP to Prolog translation time: 0.0028555670000001143 seconds
  398
  399Prolog compilation time: 0.0004133299999997675 seconds
  4002.
  401Proof time: 4.34149999994915e-5 seconds
  402Proof:
  403length = 2, depth = 1
  404Goal#  Wff#  Wff Instance
  405-----  ----  ------------
  406  [0]    4   query :- [1].
  407  [1]    2      firstOrder(female,sue) :- [2].
  408  [2]    1         firstOrder(motherOf,joe,sue).
  409Proof end.
  410%                    succceeded(prove_timed(logicmoo_example1,query))
  411%                do_pttp_test(logicmoo_example1_holds)
  412
  413PTTP input formulas:
  414  1  firstOrder(motherOf,joe,sue).
  415  2  not_firstOrder(motherOf,_,A);firstOrder(female,A).
  416  3  not_firstOrder(sonOf,B,A);firstOrder(motherOf,A,B);firstOrder(fatherOf,A,B).
  417  4  query:-firstOrder(female,_).
  418PTTP to Prolog translation time: 0.0024834679999994336 seconds
  419
  420Prolog compilation time: 0.00039567500000003974 seconds
  4212.
  422Proof time: 3.7734999999372576e-5 seconds
  423Proof:
  424length = 2, depth = 1
  425Goal#  Wff#  Wff Instance
  426-----  ----  ------------
  427  [0]    4   query :- [1].
  428  [1]    2      firstOrder(female,sue) :- [2].
  429  [2]    1         firstOrder(motherOf,joe,sue).
  430Proof end.
  431%                    succceeded(prove_timed(logicmoo_example1_holds,query))
  432%                do_pttp_test(logicmoo_example2)
  433
  434
  435*/
  436
  437
  438% standard header used in all files that all modules are loaded (therefore useful for when(?) the day comes that modules *can*only*see their explicitly imported modules)
  439%:- prolog_flag(unknown,error,fail). % Not sure if this is needed for Quintus
  440%:- use_module(library(random)).
  441%:- use_module(library(date)).
  442% This one is for use with SWI
  443%:- use_module(library(quintus)).
  444
  445
  446% logicmoo utils shared with other systems
  447:- set_prolog_flag(double_quotes, atom).  448:- set_prolog_flag(double_quotes, string).  449
  450
  451% logicmoo vworld mud server
  452
  453:- ensure_loaded(prologmud(server/mud_telnet)).  454
  455
  456% :- ensure_loaded(('/root/lib/swipl/pack/prologmud/prolog/prologmud/actions/eat.pl')).
  457
  458
  459% :- ensure_loaded_no_mpreds(prologmud(server/mud_telnet)).
  460:- ensure_loaded(prologmud(server/mud_irc)).  461:- set_prolog_flag(expect_pfc_file,soon).  462:- if(app_argv1('--profile')).  463:- profile(ensure_loaded(prologmud('vworld/world.pfc'))).  464:- else.  465:- ensure_loaded(prologmud('vworld/world.pfc')).  466:- endif.  467
  468
  469:- ensure_loaded(prologmud(server/mud_testing)).  470
  471
  472/*
  473
  474 First time you run this 2 million clauses are qcompiled 
  475 (I've excluded 7 million more clauses that are only available with spec ial C Y C  Liciens ing)
  476
  477%     /devel/logicmoo/src_data/pldata/tiny_kb.pl *qcompiled* into tiny_kb 2.40 sec, 8,481 clauses
  478%     /devel/logicmoo/src_data/pldata/nldata_freq_pdat.pl *qcompiled* into nldata_freq_pdat 7.88 sec, 107,704 clauses
  479%     /devel/logicmoo/src_data/pldata/nldata_BRN_WSJ_LEXICON.pl *qcompiled* into nldata_BRN_WSJ_LEXICON 7.65 sec, 113,863 clauses
  480%     /devel/logicmoo/src_data/pldata/nldata_colloc_pdat.pl *qcompiled* into nldata_colloc_pdat 6.31 sec, 64,081 clauses
  481%     /devel/logicmoo/src_data/pldata/nldata_cycl_pos0.pl *qcompiled* into nldata_cycl_pos0 0.20 sec, 2,488 clauses
  482%     /devel/logicmoo/src_data/pldata/nldata_dictionary_some01.pl *qcompiled* into nldata_dictionary_some01 0.03 sec, 293 clauses
  483%     /devel/logicmoo/src_data/pldata/tt0_00022_cycl.pl *qcompiled* into tt0_00022_cycl 26.86 sec, 313,234 clauses
  484%     /devel/logicmoo/src_data/pldata/hl_holds.pl *qcompiled* into hl_holds 175.31 sec, 1,041,317 clauses
  485%     /devel/logicmoo/src_data/pldata/mworld0_declpreds.pl *qcompiled* into dbase 0.05 sec, 680 clauses
  486%     /devel/logicmoo/src_data/pldata/mworld0.pl *qcompiled* into mworld0 60.49 sec, 483,046 clauses
  487
  488  It took several minutes on my 24 core machine with 128gb ram on all SSDs as you can see.. 
  489
  490  But afterwards (the results next) .. it is able to load the system from .qlf in a mater of under 3 seconds!
  491
  492  No other SQL clone has been able to beat this .. Prolog uses 80% less ram and 10x times faster than
  493    any SQL indexing strategy I've for a large database (wtf? secret is all atoms are keys)  
  494   (The atom table (pointers to strings) is of no interest/use during join ops obviouslly.. 
  495     in which i have to do millions of join ops per semantic parse)
  496
  497%     pldata('tiny_kb') loaded into tiny_kb 0.02 sec, 9,016 clauses
  498%     pldata('nldata_freq_pdat') loaded into nldata_freq_pdat 0.10 sec, 107,709 clauses
  499%     pldata('nldata_BRN_WSJ_LEXICON') loaded into nldata_BRN_WSJ_LEXICON 0.09 sec, 113,868 clauses
  500%     pldata('nldata_colloc_pdat') loaded into nldata_colloc_pdat 0.06 sec, 64,086 clauses
  501%     pldata('nldata_cycl_pos0') loaded into nldata_cycl_pos0 0.00 sec, 2,479 clauses
  502%     pldata('nldata_dictionary_some01') loaded into nldata_dictionary_some01 0.00 sec, 264 clauses
  503%     pldata('tt0_00022_cycl') loaded into tt0_00022_cycl 0.28 sec, 313,287 clauses
  504%     pldata('hl_holds') loaded into hl_holds 1.31 sec, 1,041,321 clauses
  505%     pldata('mworld0_declpreds') loaded into dbase 0.00 sec, 679 clauses
  506%     pldata('mworld0') loaded into mworld0 0.60 sec, 483,058 clauses
  507
  508*/
  509
  510
  511% done in 'user' to avoid reloading when we reload dbase
  512ensure_q_loaded(File):-
  513    expand_file_search_path(pldata('mworld0_declpreds.pl'),Path),exists_file(Path),!,                                 
  514   '@'(load_files(File,[if(not_loaded),qcompile(auto),expand(true),derived_from(Path)]),user).
  515
  516make_qlfs:-
  517 %ensure_q_loaded(pldata('tiny_kb')),
  518 ensure_q_loaded(pldata('nldata_freq_pdat')),
  519 ensure_q_loaded(pldata('nldata_BRN_WSJ_LEXICON')),
  520 ensure_q_loaded(pldata('nldata_colloc_pdat')),
  521 ensure_q_loaded(pldata('nldata_cycl_pos0')),
  522 ensure_q_loaded(pldata('nldata_dictionary_some01')),
  523 % ensure_q_loaded(pldata('tt0_00022_cycl')),
  524 %ensure_q_loaded(pldata('hl_holds')),
  525 %ensure_q_loaded(pldata('mworld0')),
  526 %ensure_q_loaded(pldata('mworld0_declpreds')),
  527 nop(catch(ensure_q_loaded(pldata('withvars_988')),_,true)).
  528
  529% :- catch(pldata('mworld0_declpreds.qlf'),_,make_qlfs).
  530
  531
  532/*
  533
  534% done in 'user' to avoid reloading when we reload dbase
  535
  536:- include_prolog_files('../src_asserts/pldata/?*.pl').
  537
  538*/
  539
  540:-export(ensure_nl_loaded/1).  541system:ensure_nl_loaded(F):- baseKB:load_files([F],[expand(true),if(changed),qcompile(auto)]).
  542
  543% :- ensure_loaded(pldata(tiny_kb)).
  544/*
  545:- system:ensure_nl_loaded(pldata(nldata_freq_pdat)).
  546:- system:ensure_nl_loaded(pldata(nldata_BRN_WSJ_LEXICON)).
  547:- system:ensure_nl_loaded(pldata(nldata_colloc_pdat)).
  548:- system:ensure_nl_loaded(pldata(nldata_cycl_pos0)).
  549:- system:ensure_nl_loaded(pldata(nldata_dictionary_some01)).
  550:- system:ensure_nl_loaded(pldata(nldata_talk_db_pdat)).
  551*/
  552% :- ensure_loaded(pldata(tt0_00022_cycl)).
  553% :- ensure_loaded(pldata(hl_holds)).
  554% :- ensure_loaded(pldata(mworld0)).
  555% :- system:ensure_nl_loaded(pldata(transform_dump)).
  556% :- catch(ensure_loaded(pldata(withvars_988)),_,true).
  557download_and_install_el:-
  558  shell('wget -N http://logicmoo.org/devel/LogicmooDeveloperFramework/TEMP~/www.logicmoo.org/downloads/datafiles/PlDataBinary.zip',_),
  559  shell('unzip -u -d ../src_assets/pldata/PlDataBinary.zip'),
  560  catch(ensure_loaded(pldata(el_assertions)),E,fmt('Cant use el_assertions',E)).
  561
  562%:- xperimental_big_data->catch(ensure_loaded(pldata(el_assertions)),_,download_and_install_el);true.
  563
  564% :- asserta(lmcache:loaded_external_kbs(mud)),show_call(kbp_to_mpred_t).
  565
  566:- ensure_loaded(prologmud(parsing/parser_imperative)).  567:- ensure_loaded(prologmud(parsing/simple_decl_parser)). 
  568:- dynamic(baseKB:mudStowing/2).  569
  570/*
  571:- ensure_loaded(logicmoo(parsing/parser_talk)). 
  572:- ensure_loaded(logicmoo(parsing/parser_e2c)). 
  573:- ensure_loaded(logicmoo(parsing/parser_CURT)). 
  574:- ensure_loaded(logicmoo(parsing/parser_chat80)). 
  575*/
  576
  577%:- ensure_loaded(logicmoo(dbase/mpred_ext_lisp)).
  578%:- ensure_loaded(logicmoo(dbase/mpred_ext_chr)).
  579
  580include_prolog_file_mask(F):- 
  581  dmsg(include_prolog_file_mask(F)), 
  582  absolute_file_name(F,I),
  583  expand_file_name(I,O),
  584  maplist(ensure_mpred_file_loaded,O).
  585
  586
  587% NPC planners
  588:- ain(monitoredDiskFiles(prologmud('./mobs/?*.pl'))).  589:- ain(monitoredDiskFiles(prologmud('./actions/?*.pl'))).  590:- ain(monitoredDiskFiles(prologmud('./objs/?*.pl'))).  591
  592rescan_disk_files:- 
  593   forall(monitoredDiskFiles(Mask),include_prolog_file_mask(Mask)).
  594
  595:- multifile(prolog:make_hook/2).  596:- dynamic(prolog:make_hook/2).  597prolog:make_hook(after, []):- rescan_disk_files.
  598
  599:- rescan_disk_files.  600
  601% Define the agents traits, both for your agent and the world inhabitants. 
  602% agent name and stats ([] = defaults).
  603% Agents with numbered names (eg. prey(1)) are able to be used multiple times.
  604% Just copy their line and increment the number to make more of them.
  605/*
  606:-create_agent(predator(1),[str(4),stm(2),height(2),spd(3)]).
  607:-create_agent(prey(1),[str(0),stm(-8),spd(1),height(1)]).
  608:-create_agent(prey(2),[str(0),stm(-8),spd(1),height(1)]).
  609:-create_agent(prey(3),[str(0),stm(-8),spd(1),height(1)]).
  610%:-create_agent(prey(4),[str(0),stm(-8),spd(1),height(1)]).
  611:-create_agent(monster(1),[str(6),stm(2),height(2),spd(1)]).
  612:-create_agent(monster(2),[str(6),stm(2),height(2),spd(1)]).
  613:-create_agent(explorer(1),[str(2),spd(4),stm(3),height(2)]).
  614:-create_agent(vacuum(1),[]).
  615:-create_agent(explorer(2),[]).
  616*/
  617
  618:- ain((agent_text_command(Agent,["run",Term], Agent,actProlog(Term)):- ignore(Term=someCode))).  619
  620%:-forall(make_tabled_perm(get_all_templates(TEMPL)),dmsg(TEMPL)).
  621%:-forall(make_tabled_perm(grab_argsIsa(F,Types)),dmsg(grab_argsIsa(F,Types))).
  622
  623
  624% :- show_entry(ensure_mpred_file_loaded(prologmud(server/builtin))).
  625% :- must(rescan_pfc).
  626% :- show_entry(forall(filematch('./*/*.pfc.pl', X),(dmsg(ensure_mpred_file_loaded(X)),ensure_mpred_file_loaded(X)))).
  627
  628
  629% standard header used in all files that all modules are loaded (therefore useful for when(?) the day comes that modules *can*only*see their explicitly imported modules)
  630% :- include(prologmud(mud_header)).
  631
  632% These contain the definition of the object cols.
  633% Load the map file appropriate for the world being used.
  634% Load the mud files appropriate for the mobs being used.
  635
  636/*
  637:- show_entry(forall(filematch(prologmud('* /?*.pfc.pl'), X),dmsg(X))).
  638:- show_entry(ensure_mpred_file_loaded(prologmud('* /?*.pfc.pl'))).
  639:- show_entry(forall(filematch(prologmud('* / * /?*.pfc.pl'), X),dmsg(X))).
  640%:- show_entry(ensure_mpred_file_loaded(prologmud('* / * /?*.pfc.pl'))).
  641*/
  642
  643% puts world into running state
  644% :- must(old_setup).
  645
  646% [Optionaly] Start the telnet server
  647
  648
  649% standard footer to clean up any header defined states
  650:- include(prologmud(mud_footer)).  651/*
  652% Load datalog
  653:- if_flag_true(fullStart, ((ensure_loaded(logicmoo('des/des.pl')),
  654  flush_output,
  655  init_des,
  656  display_status,
  657 %  des,
  658   !))).
  659
  660*/
  661
  662
  663
  664% GOLOG SYSTEM WITHOUT FLUX (Default Commented Out)
  665%:- if_flag_true(fullStart,ensure_loaded(logicmoo('indigolog/indigolog_main_swi.pl'))).
  666
  667% FLUX AGENT SYSTEM WITHOUT GOLOG (Default Commented Out)
  668%:- if_flag_true(fullStart,ensure_loaded(logicmoo('indigolog/flux_main_swi.pl'))).
  669
  670% FLUX AGENT SYSTEM WITH GOLOG
  671% :- if_flag_true(true,ensure_loaded(logicmoo('indigolog/indigolog_main_swi_flux.pl'))).
  672
  673
  674% when we import new and awefull code base (the previous )this can be helpfull
  675% we redfine list_undefined/1 .. this is the old version
  676/*
  677lundef :- A = [],
  678       check:( merge_options(A, [module_class([user])], B),
  679        prolog_walk_code([undefined(trace), on_trace(found_undef)|B]),
  680        findall(C-D, retract(undef(C, D)), E),
  681        (   E==[]
  682        ->  true
  683        ;   print_message(warning, check(undefined_predicates)),
  684            keysort(E, F),
  685            group_pairs_by_key(F, G),
  686            maplist(report_undefined, G)
  687        )).
  688*/
  689% :- if_flag_true(fullStart,remove_undef_search).
  690
  691
  692/*
  693  ==
  694  ?- [library(mudconsole)].
  695  ?- mc_start.				% opens browser
  696
  697   or else http_mud_server
  698
  699  ?- mc_format('Hello ~w', [world]).
  700  ?- mc_html(p(['Hello ', b(world)])).
  701  ?- mc_ask([age(Age)], [p('How old are you'), input([name(age)])]).
  702  Age = 24.				% col 24 <enter>
  703  ==
  704
  705*/
  706
  707%:-mred_untrace.
  708%:-mred_no_spy_all.
  709%.
  710
  711==> tSourceCode(iSourceCode7).
  712:- current_prolog_flag(pfc_booted,true).  713% should happen *after game loaded %
  714% :- set_prolog_flag(assert_attvars,true).
  715:- ain(isLoaded(iSourceCode7)).