Skip to content

Instantly share code, notes, and snippets.

@atomictom
Created March 25, 2014 03:55
Show Gist options
  • Save atomictom/9754995 to your computer and use it in GitHub Desktop.
Save atomictom/9754995 to your computer and use it in GitHub Desktop.
# Pseudo code for the sockets
# Game
def connection(player, socket=zqm.socket(zqm.REQ)):
while True:
# Send to the NN
info = player.get_info()
info_p = info.pickle()
socket.send(info_p)
# Recv from the NN
reply = socket.recv()
reply_list = reply.unpickle()
for r in reply_list:
player.notify(r)
def main()
threading.Thread(connection).start()
# ------------------------------------------------------------
# NN
def connection(NN, socket=zqm.socket(zqm.REP)):
while True:
# Recv from the game
info = socket.recv()
info_p = info.unpickle()
NN.update_input(info_p)
# Send the NN's results to the game
results = NN.get_results()
results_p = results.pickle()
socket.send(results_p)
def main()
threading.Thread(connection).start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment