-
Notifications
You must be signed in to change notification settings - Fork 0
/
mee.py
40 lines (30 loc) · 988 Bytes
/
mee.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import json
from browser import document, ajax
def on_complete(req):
if req.status==200 or req.status==0:
print(req.text)
else:
print("error "+req.text)
def mee_connection(url):
req = ajax.ajax()
req.bind('complete',on_complete)
req.open('GET',url,False)
req.set_header('content-type','application/x-www-form-urlencoded')
req.send()
def placeBlock(slotNum = 1, direction="back"):
url = "http://localhost:8080/place"
qs = "?slotNum=" + str(slotNum)+"&direction="+ direction
mee_connection(url+qs)
def moveAgent(direction="forward"):
url = "http://localhost:8080/move"
qs = "?direction=" + direction
mee_connection(url+qs)
def turnAgent(direction="left"):
url = "http://localhost:8080/turn"
qs = "?direction=" + direction
mee_connection(url+qs)
def tpAgent():
url = "http://localhost:8080/tptoplayer"
for i in range(3):
moveAgent()
mee_connection(url)