summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2012-11-08 21:20:03 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2012-11-08 21:20:03 +0100
commit99ae1c838854d8fc1cceaed0d102e7394b3e0ce0 (patch)
treec631a514ba60d56f18a9e1f03bc2fc692ca2a29a
parent8a4d56ac9cb75284dfcaeb094d68dd60f8fc45bc (diff)
downloadwbs-99ae1c838854d8fc1cceaed0d102e7394b3e0ce0.tar.gz
wbs-99ae1c838854d8fc1cceaed0d102e7394b3e0ce0.tar.bz2
wbs-99ae1c838854d8fc1cceaed0d102e7394b3e0ce0.zip
pd_client: Prepend new choice to history in loop()
So that we dont produce a list with an empty list in the initial do-invokation.
-rw-r--r--pd_client.pl10
1 files changed, 5 insertions, 5 deletions
diff --git a/pd_client.pl b/pd_client.pl
index 94d1ad5..8aaf93b 100644
--- a/pd_client.pl
+++ b/pd_client.pl
@@ -11,19 +11,19 @@ start(Module, Host, Port):-
launch(Module, StreamIn, StreamOut) :-
atom_concat('rules/', Module, Path), consult(Path),
- do([], StreamIn, StreamOut, Module, [], []).
+ do(StreamIn, StreamOut, Module, [], []).
% -1 = EOF
byte_to_atom(-1, e):-!.
byte_to_atom(A, B):-name(B, [A]).
-do(e, _, _, _, _, _) :- !.
-do(Choice, StreamIn, StreamOut, Module, ModuleState, Hist) :-
+do(_, _, _, _, [e|_]) :- !.
+do(StreamIn, StreamOut, Module, ModuleState, Hist) :-
call(Module, Hist, ModuleDecision, ModuleState, NewModuleState),
write(StreamOut, ModuleDecision), flush_output(StreamOut),
- loop(StreamIn, StreamOut, Module, NewModuleState, [Choice|Hist]).
+ loop(StreamIn, StreamOut, Module, NewModuleState, Hist).
loop(StreamIn, StreamOut, Module, ModuleState, Hist) :-
get_code(StreamIn, ChoiceCode), byte_to_atom(ChoiceCode, Choice),
write(Choice),
- do(Choice, StreamIn, StreamOut, Module, ModuleState, Hist).
+ do(StreamIn, StreamOut, Module, ModuleState, [Choice|Hist]).