From 8b86f98c9c989c12034e43260e14a2ee000c6e5c Mon Sep 17 00:00:00 2001 From: logicmoo Date: Sat, 4 Jan 2025 10:36:56 -0800 Subject: [PATCH] GreedyChess starts with `mettalog examples/games/GreedyChess.metta -- -G "(chess)" --repl` --- mettalog | 6 +++--- prolog/metta_lang/metta_eval.pl | 22 +++++++++++++--------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/mettalog b/mettalog index 5616e049e..06c3e7cc8 100755 --- a/mettalog +++ b/mettalog @@ -674,7 +674,8 @@ function handle_args { esac if [[ $SKIP_TO_METTALOG_OPTIONS == true ]]; then - METTALOG_OPTIONS+=("$arg") + local quoted_argA=$(quote_arg "$arg") + METTALOG_OPTIONS+=("$quoted_argA") continue fi @@ -684,7 +685,6 @@ function handle_args { continue fi - if [[ "$arg" == "--compatio" ]]; then #debug_this_script=false compatio=true @@ -1082,7 +1082,7 @@ STDIO_OPTIONS=() set_io_flags STDIO_OPTIONS # Generate the final command -METTA_CMD="$MLOG -- --python=$python_flag -- ${PRE_METTALOG_OPTIONS[*]} ${METTALOG_OPTIONS[*]} ${METTALOG_OPTIONS_LAST[*]} ${STDIO_OPTIONS[*]}" +METTA_CMD="$MLOG -- --python=$python_flag -- ${PRE_METTALOG_OPTIONS[@]} ${METTALOG_OPTIONS[@]} ${METTALOG_OPTIONS_LAST[@]} ${STDIO_OPTIONS[@]}" OS=$(uname) diff --git a/prolog/metta_lang/metta_eval.pl b/prolog/metta_lang/metta_eval.pl index 410db6797..c427234d3 100755 --- a/prolog/metta_lang/metta_eval.pl +++ b/prolog/metta_lang/metta_eval.pl @@ -532,8 +532,8 @@ eval_until_eq(_Flags, Eq, XType, YType,_Dpth,_Slf,X,Y,TF):- X==Y,!,check_returnval(Eq,XType,X),check_returnval(Eq,YType,Y),TF='True'. -eval_until_eq(_Flags,_Eq,_XType,_YType,_Dpth,_Slf,X,Y,TF):- notrace(as_tf(X=:=Y,TF)),!. -eval_until_eq(_Flags,_Eq,_XType,_YType,_Dpth,_Slf,X,Y,TF):- notrace(as_tf('#='(X,Y),TF)),!. +eval_until_eq(_Flags,_Eq,_XType,_YType,_Dpth,_Slf,X,Y,TF):- notrace(as_tf_nowarn(X=:=Y,TF)),!. +eval_until_eq(_Flags,_Eq,_XType,_YType,_Dpth,_Slf,X,Y,TF):- notrace(as_tf_nowarn('#='(X,Y),TF)),!. %eval_until_eq(Flags,Eq,XType,YType,_Dpth,_Slf,X,Y,TF):- X\=@=Y,X=Y,!,check_returnval(Eq,XType,YType,Y,TF). eval_until_eq(_Flags,Eq,XType,YType,_Depth,_Self,X,Y,TF):- var(X),var(Y),!,as_tf_traceable(X=Y,TF),check_returnval(Eq,XType,X),check_returnval(Eq,YType,Y),!. %eval_until_eq(_Flags,Eq,XType,YType,_Dpth,_Slf,X,Y,TF):- X=Y,!,check_returnval(Eq,XType,YType,Y,TF). @@ -1514,7 +1514,7 @@ nb_bound(NameOrInstance, State)) ; is_valid_nb_state(NameOrInstance) -> State = NameOrInstance - ; writeln('Error: Invalid input.') + ; fbug('Error: Invalid input.') ), is_valid_nb_state(State). @@ -2613,13 +2613,15 @@ join_s2ps(F,Args,P):-atom(F),P=..[F|Args]. eval_call(S,TF):- - s2ps(S,P), !, fbug(eval_call(P,'$VAR'('TF'))), + s2ps(S,P), !, fbug_eval(eval_call(P,'$VAR'('TF'))), as_tf_traceable(P,TF). eval_call_fn(S,R):- - s2ps(S,P), !, fbug(eval_call_fn(P,'$VAR'('R'))), + s2ps(S,P), !, fbug_eval(eval_call_fn(P,'$VAR'('R'))), as_tf_traceable(call(P,R),TF),TF\=='False'. +fbug_eval(G):- if_trace(e,fbug(G)). + is_host_function([AE|More],Pred,Len):- is_system_pred(AE), length([AE|More],Len), @@ -2682,7 +2684,9 @@ as_nop(G,NoResult):- G\=[_|_], rtrace_on_failure(G),!, as_nop(NoResult). + as_tf(G,TF):- G\=[_|_], catch_warn((call(G)*->TF='True';TF='False')). +as_tf_nowarn(G,TF):- G\=[_|_], catch_nowarn((call(G)*->TF='True';TF='False')). as_tf_traceable(G,TF):- G\=[_|_], ((catch(G,E,((trace,writeln(E),rtrace(G),!,throw(E))))*->TF='True';TF='False')). %eval_selfless_1(['==',X,Y],TF):- as_tf(X=:=Y,TF),!. %eval_selfless_1(['==',X,Y],TF):- as_tf(X=@=Y,TF),!. @@ -2704,10 +2708,10 @@ allow_clp:- false_flag. eval_selfless_1([F|XY],TF):- allow_clp, \+ ground(XY),!,fake_notrace(args_to_mathlib(XY,Lib)),!,eval_selfless3(Lib,[F|XY],TF). -eval_selfless_1(['>',X,Y],TF):-!,as_tf(X>Y,TF). -eval_selfless_1(['<',X,Y],TF):-!,as_tf(X',X,Y],TF):-!,as_tf(X>=Y,TF). -eval_selfless_1(['<=',X,Y],TF):-!,as_tf(X=',X,Y],TF):-!,as_tf_nowarn(X>Y,TF). +eval_selfless_1(['<',X,Y],TF):-!,as_tf_nowarn(X',X,Y],TF):-!,as_tf_nowarn(X>=Y,TF). +eval_selfless_1(['<=',X,Y],TF):-!,as_tf_nowarn(X=