Búsqueda de Sonares 3D

sonar3d.py 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import bisect
  2. from Sonar import *
  3. p = 3
  4. start = 2
  5. end = 2
  6. array = [-1] * (p*p)
  7. array[1] = 0
  8. n = (p*p)
  9. c = Sonar()
  10. counter = 0
  11. while 1:
  12. costas = 0
  13. if end < start:
  14. break
  15. if array[end] + 1> n-1: #or len(next) == 0 or bisect.bisect(next, array[end]) >= len(next):
  16. #bisect.insort(next, array[end])
  17. array[end] = -1
  18. end -=1
  19. continue
  20. #if not array[end] == 0:
  21. #tmp = array[end]
  22. # array[end] += 1 #next[bisect.bisect_right(next, tmp)]
  23. #next.remove(array[end])
  24. #bisect.insort(next, tmp)
  25. #else:
  26. array[end] += 1
  27. counter+= 1
  28. #print "Check Point:", array[:end+1]
  29. if c.is3DSonar1D(array[:end+1], p, end+1):
  30. costas = 1
  31. if end+1 == n:
  32. print array[:end+1]
  33. if costas and end < (n-1):
  34. end += 1
  35. elif costas and end == (n-1):
  36. pass
  37. else:
  38. pass