<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://calebneedscollege.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Langston%27s_Ant%2C_animated_for_POSIX</id>
	<title>Langston's Ant, animated for POSIX - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://calebneedscollege.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Langston%27s_Ant%2C_animated_for_POSIX"/>
	<link rel="alternate" type="text/html" href="http://calebneedscollege.com/wiki/index.php?title=Langston%27s_Ant,_animated_for_POSIX&amp;action=history"/>
	<updated>2026-05-15T14:27:08Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.1</generator>
	<entry>
		<id>http://calebneedscollege.com/wiki/index.php?title=Langston%27s_Ant,_animated_for_POSIX&amp;diff=157&amp;oldid=prev</id>
		<title>Legg: /* Code */</title>
		<link rel="alternate" type="text/html" href="http://calebneedscollege.com/wiki/index.php?title=Langston%27s_Ant,_animated_for_POSIX&amp;diff=157&amp;oldid=prev"/>
		<updated>2021-05-27T19:08:38Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Code&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 19:08, 27 May 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l20&quot; &gt;Line 20:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 20:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#define Y 20&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#define Y 20&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#define S 1000&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#define S 1000&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#define D 20&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#define D 20 &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;  &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;#include &amp;lt;time.h&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;#include &amp;lt;errno.h&amp;gt;    &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;/* msleep(): Sleep for the requested number of milliseconds. */&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;/* msleep(): Sleep for the requested number of milliseconds. */&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Legg</name></author>
		
	</entry>
	<entry>
		<id>http://calebneedscollege.com/wiki/index.php?title=Langston%27s_Ant,_animated_for_POSIX&amp;diff=156&amp;oldid=prev</id>
		<title>Legg: Created page with &quot;==Synopsis==  Performs a simulation of Langston's Ant as an animation for Linux, Un*x systems.  ==Notes==  There are no borders, the map wraps edge to edge.  Define statements...&quot;</title>
		<link rel="alternate" type="text/html" href="http://calebneedscollege.com/wiki/index.php?title=Langston%27s_Ant,_animated_for_POSIX&amp;diff=156&amp;oldid=prev"/>
		<updated>2021-05-27T19:08:14Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Synopsis==  Performs a simulation of Langston&amp;#039;s Ant as an animation for Linux, Un*x systems.  ==Notes==  There are no borders, the map wraps edge to edge.  Define statements...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Synopsis==&lt;br /&gt;
&lt;br /&gt;
Performs a simulation of Langston's Ant as an animation for Linux, Un*x systems.&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
There are no borders, the map wraps edge to edge.  Define statements have a 20x20 grid, 1000 steps and a delay of 20ms.  The ANT always starts at, or near, the center.  The ant defaults being oriented towards north as an initial condition.&lt;br /&gt;
&lt;br /&gt;
==Compilation==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
gcc -o Ant Ant.c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C++&amp;quot; line='line'&amp;gt;&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include&amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;time.h&amp;gt;&lt;br /&gt;
#include &amp;lt;errno.h&amp;gt; &lt;br /&gt;
#define X 20&lt;br /&gt;
#define Y 20&lt;br /&gt;
#define S 1000&lt;br /&gt;
#define D 20&lt;br /&gt;
#include &amp;lt;time.h&amp;gt;&lt;br /&gt;
#include &amp;lt;errno.h&amp;gt;    &lt;br /&gt;
&lt;br /&gt;
/* msleep(): Sleep for the requested number of milliseconds. */&lt;br /&gt;
int msleep(long msec)&lt;br /&gt;
{&lt;br /&gt;
	struct timespec ts;&lt;br /&gt;
	int res;&lt;br /&gt;
&lt;br /&gt;
	if (msec &amp;lt; 0)&lt;br /&gt;
	{&lt;br /&gt;
		errno = EINVAL;&lt;br /&gt;
		return -1;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	ts.tv_sec = msec / 1000;&lt;br /&gt;
	ts.tv_nsec = (msec % 1000) * 1000000;&lt;br /&gt;
&lt;br /&gt;
	do&lt;br /&gt;
	{&lt;br /&gt;
		res = nanosleep(&amp;amp;ts, &amp;amp;ts);&lt;br /&gt;
	}&lt;br /&gt;
	while (res &amp;amp;&amp;amp; errno == EINTR);&lt;br /&gt;
	return res;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(void)&lt;br /&gt;
{&lt;br /&gt;
	char world[X][Y];&lt;br /&gt;
	unsigned short x, y, c, d, h, s;&lt;br /&gt;
	//init&lt;br /&gt;
	x=X/2; y=Y/2; h=0;&lt;br /&gt;
	for(c=0;c&amp;lt;Y;c++)&lt;br /&gt;
	{&lt;br /&gt;
		for(d=0;d&amp;lt;X;d++)&lt;br /&gt;
		{&lt;br /&gt;
			world[d][c] = '.';&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	//loop&lt;br /&gt;
	for(s=0;s&amp;lt;S;s++)&lt;br /&gt;
	{&lt;br /&gt;
		#ifdef D&lt;br /&gt;
		msleep(D);&lt;br /&gt;
		#endif&lt;br /&gt;
		printf(&amp;quot;\e[1;1H\e[2J&amp;quot;);&lt;br /&gt;
		//print current state&lt;br /&gt;
		printf(&amp;quot;S=%d\n\n&amp;quot;,s+1);&lt;br /&gt;
		printf(&amp;quot;%c&amp;quot;, '/');&lt;br /&gt;
		for(c=0;c&amp;lt;X;c++)&lt;br /&gt;
		{&lt;br /&gt;
			printf(&amp;quot;%c&amp;quot;, '-');&lt;br /&gt;
		}&lt;br /&gt;
		printf(&amp;quot;%c\n&amp;quot;, '\\');&lt;br /&gt;
		for(c=0;c&amp;lt;Y;c++)&lt;br /&gt;
		{&lt;br /&gt;
			printf(&amp;quot;%c&amp;quot;, '|');&lt;br /&gt;
			for(d=0;d&amp;lt;X;d++)&lt;br /&gt;
			{&lt;br /&gt;
				if(d==x &amp;amp;&amp;amp; c==y)&lt;br /&gt;
					printf(&amp;quot;A&amp;quot;);&lt;br /&gt;
				else&lt;br /&gt;
					printf(&amp;quot;%c&amp;quot;,world[d][c]);&lt;br /&gt;
			}&lt;br /&gt;
			printf(&amp;quot;%c\n&amp;quot;, '|');&lt;br /&gt;
		}&lt;br /&gt;
		printf(&amp;quot;%c&amp;quot;, '\\');&lt;br /&gt;
		for(c=0;c&amp;lt;X;c++)&lt;br /&gt;
		{&lt;br /&gt;
			printf(&amp;quot;%c&amp;quot;, '-');&lt;br /&gt;
		}&lt;br /&gt;
		printf(&amp;quot;/\n\n&amp;quot;);&lt;br /&gt;
		//turn logic&lt;br /&gt;
		if(world[x][y]=='.')&lt;br /&gt;
		{&lt;br /&gt;
			h++; //CW&lt;br /&gt;
			h = h % 4;&lt;br /&gt;
			world[x][y]='*';&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{	&lt;br /&gt;
			h--; //CCW&lt;br /&gt;
			h= h % 4;&lt;br /&gt;
			world[x][y]='.';&lt;br /&gt;
		}&lt;br /&gt;
		//move forward&lt;br /&gt;
		if(h==0)&lt;br /&gt;
			{if(y==0) y=Y-1; else y--;}&lt;br /&gt;
		if(h==2)&lt;br /&gt;
			{if(y==Y-1) y=0; else y++;}&lt;br /&gt;
		if(h==1)&lt;br /&gt;
			{if(x==X-1) x=0; else x++;}&lt;br /&gt;
		if(h==3)&lt;br /&gt;
			{if(x==0) x=X-1; else x--;}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	//terminate&lt;br /&gt;
	printf(&amp;quot;\nEOS \n&amp;quot;);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Legg</name></author>
		
	</entry>
</feed>