Elementary cellular automaton: Difference between revisions

m
(Added prolog implementation)
Line 1,542:
 
=={{header|Prolog}}==
<lang prolog>play :- initial([0I),0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0 play(50,0] I).
 
play(0, _) :- !.
play(N, I) :-
maplist(writ, I), nl,
apply_rules(I, Next),
succ(N1, N),
play(N1, Next).</lang>
 
r(0,0,0,0).
Line 1,561 ⟶ 1,568:
r(O,P,Q,P1), r(P,Q,R,Q1), r(Q,R,S,R1), r(R,S,A,S1).
play :- initial(I), play(50, I).
 
writ(0) :- write('.').
writ(1) :- write(1).
 
initial([0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0]).
play(0, _) :- !.
play(N, I) :-
maplist(writ, I), nl,
apply_rules(I, Next),
succ(N1, N),
play(N1, Next).</lang>
 
 
=={{header|Python}}==
Anonymous user