Remote agent/Simulation/C: Difference between revisions

no edit summary
m (Fixed syntax highlighting.)
imported>Katsumi
No edit summary
 
Line 3:
 
;<nowiki>server.c:</nowiki>
<syntaxhighlight lang="c">#include <stdio.hline>
<lang c>#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Line 131 ⟶ 132:
 
return 1;
}</langsyntaxhighlight>
 
;<nowiki>client.c:</nowiki>
}</syntaxhighlight lang="c" line>
<lang c>#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Line 406 ⟶ 408:
turn(c_cw), say(c_cw), hear();
try_forward(fd);
}
}</lang>
</syntaxhighlight>
 
;<nowiki>common.c:</nowiki>
<syntaxhighlight lang="c" line>
<lang c>struct agent_t{ int x, y, facing, ball; } agent = { 0, 0, 0, -1 };
enum {
c_fwd, c_cw, c_ccw, c_get, c_drop, c_over, c_stop,
Line 612 ⟶ 616:
if (dir == c_cw)
if (++agent.facing > 3) agent.facing = 0;
}
}</syntaxhighlight>
</syntaxhighlight>
Anonymous user