Langton's ant: Difference between revisions

m (→‎{{header|REXX}}: corrected a comment, changed the wording in the REXX section header. -- ~~~~)
Line 2,671:
=={{header|Prolog}}==
This sort of problem, when stated in Prolog, reads a bit like a story book. Our main goal (go) succeeds if we can move north from the middle of the 100x100 matrix, and update_win- which outputs the black/1 blocks. The move/3 and direction/3 goals are really quite self explanatory, mirroring the instructions for the task.
{{works with|SWI Prolog|version 6.2.6 by Jan Wielemaker, University of Amsterdam}}
[[File:ant.jpg|thumb|right|Sample output]]
<lang prolog>%_______________________________________________________________
Line 2,683:
send(C, center(point(X,Y))), send(@win, display, C).
update_win :- % Make a 500x500 window, find all the black points and plot them
new(@win, window('LangdonsLangtons\' Ant')),
send(@win, size, size(500,500)), send(@win, open),
black(Row/Col),plot_point(Row,Col),fail.
Anonymous user