-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirst.py
More file actions
40 lines (34 loc) · 840 Bytes
/
first.py
File metadata and controls
40 lines (34 loc) · 840 Bytes
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 matplotlib.pyplot as plt
import numpy as np
from pip import main
field=np.zeros((1000,1000))
person=np.random.randint(0,999,2)
goal=np.random.randint(0,999,2)
path=np.zeros((1000,1000))
print(goal)
print(person)
path[goal[0]][goal[1]]=2
def depalcement(perso,but):
if(perso[0]!=but[0]):
if(perso[0]<but[0]):
perso[0]+=1
else:
perso[0]-=1
if(perso[1]!=but[1]):
if(perso[1]<but[1]):
perso[1]+=1
else:
perso[1]-=1
path[perso[0]][perso[1]]+=1
return perso
while(person[0]!=goal[0] and person[1]!=goal[1]):
person = depalcement(person,goal)
#print(goal[0],goal[1])
#print(person[0],person[1])
print("finish")
print(path)
plt.figure()
plt.imshow(path)
plt.colorbar()
plt.title("la premiere")
plt.savefig("first.png")