Skip to content

Commit

Permalink
GreedyChess starts with `mettalog examples/games/GreedyChess.metta --…
Browse files Browse the repository at this point in the history
… -G "(chess)" --repl`
  • Loading branch information
TeamSPoon committed Jan 4, 2025
1 parent 6373230 commit 8b86f98
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
6 changes: 3 additions & 3 deletions mettalog
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -684,7 +685,6 @@ function handle_args {
continue
fi


if [[ "$arg" == "--compatio" ]]; then
#debug_this_script=false
compatio=true
Expand Down Expand Up @@ -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)
Expand Down
22 changes: 13 additions & 9 deletions prolog/metta_lang/metta_eval.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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).

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),!.
Expand All @@ -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<Y,TF).
eval_selfless_1(['=>',X,Y],TF):-!,as_tf(X>=Y,TF).
eval_selfless_1(['<=',X,Y],TF):-!,as_tf(X=<Y,TF).
eval_selfless_1(['>',X,Y],TF):-!,as_tf_nowarn(X>Y,TF).
eval_selfless_1(['<',X,Y],TF):-!,as_tf_nowarn(X<Y,TF).
eval_selfless_1(['=>',X,Y],TF):-!,as_tf_nowarn(X>=Y,TF).
eval_selfless_1(['<=',X,Y],TF):-!,as_tf_nowarn(X=<Y,TF).
eval_selfless_1(['\\=',X,Y],TF):-!,as_tf(dif(X,Y),TF).

eval_selfless_2([F|_],_):- var(F),!,fail.
Expand Down

0 comments on commit 8b86f98

Please sign in to comment.