Graphing Langtons Ant Worlds leading expert on Langtons Ant

Getting started.

The following html pages have been prepared for Linux users. However, it is possible using the 'wget' application under windows to get things to work just as well.

These pages will show you how to migrate from m-file scripts that use the wave equation maths to using m-file scripts that utilise the 'LCEE online engine' which can crunch through 5.5 *10^7 iterations per seconds reducing the overall time from several hours to several seconds.

Before we start, please check to see if the LCEE engine is online, make sure you get a response with a build date and version number, if there is no response or you see an error, please be patient as the site may be down while undergoing maintenance. Assuming LCEE is live, Please open a bash terminal, navigate to a clean working directory (A temporary sandpit for the duration of these tutorials) which can be removed when you finish the last page. Now type the following into the terminal. (you can copy & paste but remember not to include the hash!)





# wget http://www.buzwordsalad.com/mfile/www_compare.m



which will download an octave m file which will create a mesh plot, as an alternative, there is a simpler and less cpu intensive version called 'www_compare_sc.m' which you can replace in the wget system call above, now fire up octave by typing the following into the terminal.





# octave



When the Octave terminal is ready to go, simply execute the m-file by typing





www_compare





This will begin the first 12288 iterations of Langtons ant and will take 'Octave' about twenty seconds to compute the 'Binary' and 'Occupancy matrix', after which you will see four graphs appear on the desktop.





Figures 1,2 are created by the Octave maths, figures 3,4 are from the LCEE online engine). Figures 1 and 3 are the BINARY lattice (black and white squares which determine rotation). Figures 2 and 4 are the occupancy plot, the taller the spike the more repeat visits there have been on that square.

The plots above are the clasic langtons ant image with the 104 highway, now we will increase the number of iterations and since we are on a bounded surface you can witness what happens when the highway wraps around and re visits the starting square.

To do this we will modify the www_compare.m file by changing the iteration count from 12288 to 131072, this has already been done for you so lets download it, please quit from octave by typing the following





exit





Now the graphs should have gone and you should be back at the terminal, type in the following to download a new m file and also fire up octave.





# wget http://www.buzwordsalad.com/mfile/www_lcee_131072.m

# octave



Now execute the new m file and see how quickly it runs.





www_lcee_131072



Which will produce the following graphs.







Now edit the www_lcee_131072.m file by typing.





# gedit www_lcee_131072.m &



Now change the '2000' to '780000' and save the changes to disk. (these are base 16 'hexadecimal' numbers where 2000=12,288 and 780000=7,864,320 in decimal, so the new system call should like like this.



system ("wget 'http://buzwordsalad.com/lcee/elsee.sh?-d 2 -xy 8050 -g 00780000 -f 0001' -O report.html");



Leave the 'text editor' open and fire up octave again





# octave



Execute the script



www_lcee_131072



Which will plot the following graph. ( Click here to open a new page and see a selected range of plots)







Now change the '780000'in the m-file back to '3000' and note the -g just before it, the -g tells LCEE that it must iterate the following 32 bit number of times hence the 8 digit hexadecimal number, if you look further left you will see '-xy 8050' which tells LCEE where to start the Ant in the matrix, currently this is 80 (128 decimal) across and 50 (80 decimal) down. So lets set this to zero origin by editing the system call so it looks like this.



system ("wget 'http://buzwordsalad.com/lcee/elsee.sh?-d 2 -xy 0000 -g 00003000 -f 0001' -O report.html");



Save the changes and execute the m-file, this will cause the plot to exist on all four corners since on a bounded surface they are right next to each other.



Now put the xy position back to 8080 and change the direction -d to 0 (0,1,2,3 = North, East, South and West), save the changes and execute the m file, also point your web browser to the directory where the m-file exists and open the 'REPORT.HTML' file which reports the xy position of the last step the ANT took, the final direction and a 48 bit count of the total iterations achieved.



system ("wget 'http://buzwordsalad.com/lcee/elsee.sh?-d 0 -xy 8080 -g 00003800 -f 0001' -O report.html");



This is how my screen looks after the execution of the script.





which will download an octave m file which will create a mesh plot, as an alternative, there is a simpler and less cpu intensive version called 'www_compare_sc.m' which you can replace in the wget system call above, now fire up octave by typing the following into the terminal. When the Octave terminal is ready to go, simply execute the m-file by typing This will begin the first 12288 iterations of Langtons ant and will take 'Octave' about twenty seconds to compute the 'Binary' and 'Occupancy matrix', after which you will see four graphs appear on the desktop. Figures 1,2 are created by the Octave maths, figures 3,4 are from the LCEE online engine). Figures 1 and 3 are the BINARY lattice (black and white squares which determine rotation). Figures 2 and 4 are the occupancy plot, the taller the spike the more repeat visits there have been on that square. The plots above are the clasic langtons ant image with the 104 highway, now we will increase the number of iterations and since we are on a bounded surface you can witness what happens when the highway wraps around and re visits the starting square. To do this we will modify the www_compare.m file by changing the iteration count from 12288 to 131072, this has already been done for you so lets download it, please quit from octave by typing the following Now the graphs should have gone and you should be back at the terminal, type in the following to download a new m file and also fire up octave. Now execute the new m file and see how quickly it runs. Which will produce the following graphs. Now edit the www_lcee_131072.m file by typing. Now change the '2000' to '780000' and save the changes to disk. (these are base 16 'hexadecimal' numbers where 2000=12,288 and 780000=7,864,320 in decimal, so the new system call should like like this. Leave the 'text editor' open and fire up octave again Execute the script Which will plot the following graph. ( Click here to open a new page and see a selected range of plots) Now change the '780000'in the m-file back to '3000' and note the -g just before it, the -g tells LCEE that it must iterate the following 32 bit number of times hence the 8 digit hexadecimal number, if you look further left you will see '-xy 8050' which tells LCEE where to start the Ant in the matrix, currently this is 80 (128 decimal) across and 50 (80 decimal) down. So lets set this to zero origin by editing the system call so it looks like this. Save the changes and execute the m-file, this will cause the plot to exist on all four corners since on a bounded surface they are right next to each other. Now put the xy position back to 8080 and change the direction -d to 0 (0,1,2,3 = North, East, South and West), save the changes and execute the m file, also point your web browser to the directory where the m-file exists and open the 'REPORT.HTML' file which reports the xy position of the last step the ANT took, the final direction and a 48 bit count of the total iterations achieved. This is how my screen looks after the execution of the script. Top left is the binary matrix plot, this is a coiled up (wrapped around) a flat toroidal surface with ALL the elements of Psi_d, note that this is a binary matrix and contains 8 bit signed integers of 1 and -1 which gives an unsigned value of 1 and 255 respectively)

Top middle is the occupancy matrix, this does not exist in the basic Langtons ant wave equation but it does exists in the extended Langtons ant wave equation, it is a surface amplitude plot of the number of visits to each unique square on the binary lattice thus each element in the binary matrix can be calculated by [Psi_d(N) = (-1)^O(N)] where N= the element number in the matrix ExE

Top right is the fantastic Octave terminal where you can see all the reporting from the wget system call

Bottom left is a firefox browser showing the output from the LCEE online engine, what we need to see here is the word 'Success' which means NO errors were found and the data is GOOD.

Bottom middle is the files in the sandpit directory where you are working.

Bottom right is the TEXT EDITOR with the m-file open where you can see the system call on line 14.





Now lets rotate again, this time we will choose 5 as our new starting direction to demonstrate how errors are reported, so type in the following



system ("wget 'http://buzwordsalad.com/lcee/elsee.sh?-d 5 -xy 8080 -g 00003800 -f 0001' -O report.html");





Save the changes and execute the m-file which will report the following error from within octave.





error: reshape: can't reshape 1x0 array to 256x256 array



error: evaluating argument list element number 1



error: called from:



error: /home/dakoder/demo/lcee_online.m at line 32, column 1





To understand what went wrong, simply refresh or open the 'report.html' file (you will find it in your current octave working directory). Once opened you will see the following error.

5,

Initial direction invalid [0=UP, 1=RIGHT, 2=DOWN, 3=LEFT]



Now put the -d switch back to 0 and save the changes.



There are two more m-files which are exclusive to the 'Binary matrix' and 'Occupancy matrix' creation.





wget http://www.buzwordsalad.com/mfile/www_occupancy.m



wget http://www.buzwordsalad.com/mfile/www_binary.m





Now execute the www_occupancy.m file from within octave by typing



www_occupancy



This will generate the following ant terrain.





Stage 1 complete

In this section you were given a couple of 'ready baked' octave scripts, you were then shown how to edit and use the 'LCEE online engine' using the 'system call' within the m-file to plot the 'output_b occupancy and binary files respectively. You should also have a deeper understanding of what these graphs are telling us about the behaviour of Langtons ant. In the next section we will explore the 'bargraph.bin' file, so keep you favourite editor, octave and the bash terminal open and head over to section two