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