-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.py
More file actions
56 lines (47 loc) · 1.41 KB
/
Copy pathtest.py
File metadata and controls
56 lines (47 loc) · 1.41 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from clientpy3 import *
import utils
import datetime
import scanner
import time
from get_path import exec_move, min_dist
import random
u = 'BSOD'
pw = 'Alboucai'
print('starting')
cdic = None
data = None
while (cdic is None and data is None):
config = get_config(u,pw)
c_dic = utils.config_parser(config)
data = utils.status(u,pw)
mine_scanner = scanner.scanner('BSOD', 'Alboucai')
mine_scanner.start()
while len(mine_scanner.mines) < 1:
try:
utils.move(u,pw,random.uniform(0,3.14),1)
except (TimeoutError):
pass
while True:
blah = mine_scanner.mines
min_dis = -1
for value in list(blah):
values = value.split(' ')
x = values[0]
y = values[1]
x_,y_ = x,y
dist = min_dist(float(data['position'][0]), float(data['position'][1]),float(x),float(y),float(c_dic['MAP_WIDTH']), float(c_dic['MAP_HEIGHT']))
print((mine_scanner._mines[value][0]))
if (min_dis < 0 or dist < min_dis and ((time.time()-mine_scanner._mines[value][0]) > 30)):
min_dis = dist
x_,y_ = x,y
print('moving to:', x_, y_)
try:
exec_move(u,pw,float(x_),float(y_))
scanner.mine_mutex.acquire()
mine_scanner._mines[value] = (time.time(),u)
scanner.mine_mutex.release()
except(TimeoutError,TypeError):
pass
utils.move(u,pw,random.uniform(0,3.14),1)
time.sleep(1)
mine_scanner.stop()