Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- matrix = np.array([[3,3,3,3,3,3,3,3,3,3,3,3],
- [3,2,2,2,2,2,0,0,0,0,0,3],
- [3,2,2,2,2,0,0,0,0,0,0,3],
- [3,2,2,2,0,0,0,0,0,0,0,3],
- [3,2,2,0,0,0,0,0,0,0,0,3],
- [3,2,0,0,0,0,0,0,0,0,0,3],
- [3,0,0,0,0,0,0,0,0,0,1,3],
- [3,0,0,0,0,0,0,0,0,1,1,3],
- [3,0,0,0,0,0,0,0,1,1,1,3],
- [3,0,0,0,0,0,0,1,1,1,1,3],
- [3,0,0,0,0,0,1,1,1,1,1,3],
- [3,3,3,3,3,3,3,3,3,3,3,3]])
- def neighbor(chips1):
- for x in chips1:
- y,z = (x[0],x[1])
- add = list(starmap(lambda a,b: (y+a, z+b), product((0,-1,+1), (0,-1,+1))))
- add = [(x,y) for x,y in add if x <= 10]
- add = [(x,y) for x,y in add if y <= 10]
- neighbors.append(add)
- return neighbors
- def classify(neighbors,matrix):
- for x in enumerate(neighbors):
- for j in enumerate(enumerate(neighbors)):
- y = x[0]
- z = x[1]
- if matrix[(y,z)]== 0:
- step.append(j)
- else:
- hop.append(j)
- print(hop,step)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement