Remote agent/Simulation: Difference between revisions

m
syntax highlighting fixup automation
(Added Wren)
m (syntax highlighting fixup automation)
Line 5:
 
=={{header|Go}}==
<langsyntaxhighlight lang="go">package world
 
import (
Line 253:
}
return true
}</langsyntaxhighlight>
{{out}}
<pre>
Line 306:
If it is started on a terminal (perl's -t is true) it sets the terminal to cbreak mode and can be talked to directly.
Otherwise it can be run under xinetd.
<langsyntaxhighlight lang="perl">#!/usr/bin/perl
 
use strict; # https://rosettacode.org/wiki/Remote_agent
Line 438:
#warn "final\n";
#show;
</syntaxhighlight>
</lang>
 
=={{header|Phix}}==
<!--<langsyntaxhighlight Phixlang="phix">(notonline)-->
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\Remote_Agent_Simulator.exw
Line 566:
<span style="color: #000000;">create_world</span><span style="color: #0000FF;">()</span>
<span style="color: #000000;">register_world</span><span style="color: #0000FF;">(</span><span style="color: #000000;">accept_command</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">get_event</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">get_world</span><span style="color: #0000FF;">)</span>
<!--</langsyntaxhighlight>-->
{{out}}
Of course this is half on one screen and half on another for non-direct (ie the ipc) version.<br>
Line 596:
This is the server. For the client, see [[Remote agent/Agent logic#PicoLisp]].
After starting (gameServer), you might for testing purposes also connect with 'telnet', type the commands, and see the responses.
<langsyntaxhighlight PicoLisplang="picolisp"># Global variables:
# '*Port' is the port where the server is listening
# '*Sock' is the TCP socket after a client connected
Line 726:
(if (== *Agent This) "*" " ")
(: field)
(if (: ball) (lowc @) " ") ) ) ) )</langsyntaxhighlight>
 
For local tests, you can start also it interactively:
Line 752:
=={{header|Tcl}}==
{{libheader|TclOO}}
<langsyntaxhighlight lang="tcl">package require TclOO
 
# Utility: pick random item of list
Line 984:
# Make the server and run the event loop
BallMaze server $port $width $height {*}$argv
vwait forever</langsyntaxhighlight>
Example call (with the server restricted to only serving on 127.0.0.1):
<pre>tclsh8.5 agent.world.tcl 54545 8 8 -myaddr localhost</pre>
Line 993:
{{libheader|Wren-fmt}}
{{libheader|Wren-seq}}
<langsyntaxhighlight lang="ecmascript">/* world.wren */
 
import "./ifc" for Ifc, Log
Line 1,197:
Log.print(maze.join())
}
}</langsyntaxhighlight>
<br>
Finally, we need a 'driver' script to run the various 'remote agent' modules (world, agent and ifc) as a whole assuming they've all been placed in the same directory.
Line 1,206:
 
{{libheader|Wren-queue}}
<langsyntaxhighlight lang="ecmascript">/* driver.wren */
 
import "./ifc" for Streamer, Ifc, Log
Line 1,247:
af.call(aqs)
wf.call(wqs)
}</langsyntaxhighlight>
 
{{out}}
10,327

edits