コード例 #1
0
ファイル: rlglue.py プロジェクト: evenmarbles/rlglued
    def force_connection(self):
        if self._network is None:
            svn_version = get_svn_codec_version()
            codec_version = get_codec_version()

            host_string = os.getenv("RLGLUED_HOST")
            port_string = os.getenv("RLGLUED_PORT")

            host = network.kLocalHost
            if host_string is not None:
                host = host_string

            try:
                port = int(port_string)
            except TypeError:
                port = network.kDefaultPort

            print "RL-Glue Python Experiment Codec Version: " + codec_version + " (Build " + svn_version + ")"
            print "\tConnecting to " + host + " on port " + str(port) + "..."
            sys.stdout.flush()

            self._network = network.Network()
            self._network.connect(host, port)
            self._network.clear_send_buffer()
            self._network.put_int(network.kExperimentConnection)
            self._network.put_int(0)
            self._network.send()
コード例 #2
0
ファイル: loader.py プロジェクト: evenmarbles/rlglued
def load_agent(agent):
    svn_version = get_svn_codec_version()
    codec_version = get_codec_version()
    client = ClientAgent(agent)

    host_string = os.getenv("RLGLUED_HOST")
    port_string = os.getenv("RLGLUED_PORT")

    host = network.kLocalHost
    if host_string is not None:
        host = host_string

    try:
        port = int(port_string)
    except TypeError:
        port = network.kDefaultPort

    print "RL-Glue Python Agent Codec Version: " + codec_version + " (Build " + svn_version + ")"
    print "\tConnecting to " + host + " on port " + str(port) + "..."
    sys.stdout.flush()

    client.connect(host, port, network.kRetryTimeout)
    print "\t Agent Codec Connected"
    client.run_event_loop()
    client.close()