Skip to content

Commit

Permalink
Improve example learner.
Browse files Browse the repository at this point in the history
  • Loading branch information
PremekPaska committed Jul 25, 2017
1 parent 0499421 commit 84cb5e4
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions evaluation/examples/linux-python/agent/example_learner.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,36 @@
socket.send_string("hello")


def handler(signal, frame):
def disconnect():
print('exiting...')
socket.disconnect(address)


def handler(signal, frame):
disconnect()
exit()


signal.signal(signal.SIGINT, handler)

reward = socket.recv()
next_input = socket.recv()

def read_data():
_reward = socket.recv()
_input_str = socket.recv().decode('utf-8')
return _reward, _input_str


reward, input_str = read_data()

while True:
print("reward: {}".format(reward))
print("input : {}".format(input_str))
for c in input_str:
if ord(c) >= 256:
print("Unexpected unicode character. Should be < 256.")

socket.send_string("a") # your attempt to solve the current task
reward = socket.recv()
next_input = socket.recv()
print(reward)
reward, input_str = read_data()


signal.pause()
disconnect()

0 comments on commit 84cb5e4

Please sign in to comment.