Advertisement
Guest User

Untitled

a guest
May 25th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. matrix = np.array([[3,3,3,3,3,3,3,3,3,3,3,3],
  2. [3,2,2,2,2,2,0,0,0,0,0,3],
  3. [3,2,2,2,2,0,0,0,0,0,0,3],
  4. [3,2,2,2,0,0,0,0,0,0,0,3],
  5. [3,2,2,0,0,0,0,0,0,0,0,3],
  6. [3,2,0,0,0,0,0,0,0,0,0,3],
  7. [3,0,0,0,0,0,0,0,0,0,1,3],
  8. [3,0,0,0,0,0,0,0,0,1,1,3],
  9. [3,0,0,0,0,0,0,0,1,1,1,3],
  10. [3,0,0,0,0,0,0,1,1,1,1,3],
  11. [3,0,0,0,0,0,1,1,1,1,1,3],
  12. [3,3,3,3,3,3,3,3,3,3,3,3]])
  13.  
  14. def neighbor(chips1):
  15. for x in chips1:
  16. y,z = (x[0],x[1])
  17. add = list(starmap(lambda a,b: (y+a, z+b), product((0,-1,+1), (0,-1,+1))))
  18. add = [(x,y) for x,y in add if x <= 10]
  19. add = [(x,y) for x,y in add if y <= 10]
  20. neighbors.append(add)
  21. return neighbors
  22.  
  23. def classify(neighbors,matrix):
  24. for x in enumerate(neighbors):
  25. for j in enumerate(enumerate(neighbors)):
  26. y = x[0]
  27. z = x[1]
  28. if matrix[(y,z)]== 0:
  29. step.append(j)
  30. else:
  31. hop.append(j)
  32. print(hop,step)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement