From df94c8feedad2a28130ba09e725c0f97aab37a2e Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Sun, 21 Jul 2019 18:48:11 -0700 Subject: [PATCH] Minor cleanup. --- thun/TLA.pl | 28 ++++++++++++++++++---------- thun/thun.pl | 1 - 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/thun/TLA.pl b/thun/TLA.pl index 98ce7a6..e15c1a8 100644 --- a/thun/TLA.pl +++ b/thun/TLA.pl @@ -36,15 +36,15 @@ next(PC, I) :- PC \= done, relly(PC, I, PCnext, Inext), next(PCnext, Inext). % Inext in 1..1001. - type_ok(Small, Big) :- Small in 0..3, Big in 0..5. -next_dh(Small, Big, S, B, Mi, Mo) :- - B #\= 4, type_ok(Small, Big), +next_dh(Moves) :- next_dh(0, 0, Moves). + +next_dh(Small, Big, [[Move, Si, Bi]|Moves]) :- + type_ok(Small, Big), die_hard(Move, Small, Big, Si, Bi), - State = [Move, Si, Bi], - (Bi = 4 -> Mo=[State|Mi] ; next_dh(Si, Bi, S, B, [State|Mi], Mo)). + (Bi = 4 -> Moves=[] ; next_dh(Si, Bi, Moves)). % die_hard(Small, Big, S, B). @@ -66,7 +66,7 @@ big_to_small(Small, Big, S, 0) :- Small + Big #=< 3, S is Small + Big. -big_to_small(Small, Big, 3, B) :- % +big_to_small(Small, Big, 3, B) :- Small + Big #> 3, B is Big - (3 - Small). @@ -80,10 +80,18 @@ small_to_big(Small, Big, S, 5) :- /* - -call_with_depth_limit(next_dh(0, 0, S, B, Mi, Mo), 12, REsult). - - +With some manual reflow of the list for presentation... + +?- call_with_depth_limit(next_dh(Moves), 11, _). +Moves = [ + [fill_big, 0, 5], + [big_to_small, 3, 2], + [empty_small, 0, 2], + [big_to_small, 2, 0], + [fill_big, 2, 5], + [big_to_small, 3, 4] + ] ; +true. diff --git a/thun/thun.pl b/thun/thun.pl index b611059..49710ce 100644 --- a/thun/thun.pl +++ b/thun/thun.pl @@ -220,7 +220,6 @@ combo(branch, [T, F, Expr|S], S, Ei, Eo) :- (append(T, Ei, Eo) ; append(F, Ei, Eo)) ). - combo(loop, [_, false|S], S, E, E ). combo(loop, [B, true|S], S, Ei, Eo) :- append(B, [B, loop|Ei], Eo). -- 2.11.0