Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. __author__ = 'Mors'
  2. from random import randint
  3.  
  4.  
  5. moves = ["F", "F'", "R", "R'", "L", "L'", "U", "U'", "D", "D'", "B", "B'", "F2", "R2", "L2", "U2", "D2", "B2"]
  6. scramble = []
  7.  
  8. lenght = len(scramble)
  9. lenght_moves = len(moves) - 1
  10.  
  11. def good_move(scramble, lenght):
  12. if scramble[lenght] == "R" or scramble[lenght] == "R'" or scramble[lenght] == "R2":
  13. if scramble[lenght - 1] == "R" or scramble[lenght - 1] == "R'" or scramble[lenght - 1] == "R2":
  14. return False
  15. if scramble[lenght] == "L" or scramble[lenght] == "L'" or scramble[lenght] == "L2":
  16. if scramble[lenght - 1] == "L" or scramble[lenght - 1] == "L'" or scramble[lenght - 1] == "L2":
  17. return False
  18. if scramble[lenght] == "F" or scramble[lenght] == "F'" or scramble[lenght] == "F2":
  19. if scramble[lenght - 1] == "F" or scramble[lenght - 1] == "F'" or scramble[lenght - 1] == "F2":
  20. return False
  21. if scramble[lenght] == "U" or scramble[lenght] == "U'" or scramble[lenght] == "U2":
  22. if scramble[lenght - 1] == "U" or scramble[lenght - 1] == "U'" or scramble[lenght - 1] == "U2":
  23. return False
  24. if scramble[lenght] == "D" or scramble[lenght] == "D'" or scramble[lenght] == "D2":
  25. if scramble[lenght - 1] == "D" or scramble[lenght - 1] == "D'" or scramble[lenght - 1] == "D2":
  26. return False
  27. if scramble[lenght] == "B" or scramble[lenght] == "B'" or scramble[lenght] == "B2":
  28. if scramble[lenght - 1] == "B" or scramble[lenght - 1] == "B'" or scramble[lenght - 1] == "B2":
  29. return False
  30.  
  31. return True
  32.  
  33.  
  34.  
  35.  
  36.  
  37. while (lenght < 20):
  38. print (lenght)
  39. print (scramble)
  40. random = randint(0, lenght_moves)
  41. if lenght - 1 >= 1:
  42. if good_move(scramble, lenght - 1) == False:
  43. print ("I'm here")
  44. while (good_move(scramble, lenght - 1)) != False:
  45. random = randint(0, lenght_moves)
  46. print (random)
  47. scramble.remove(lenght - 1)
  48. scramble.append(moves[random])
  49. else:
  50. scramble.append(moves[random])
  51.  
  52. else:
  53. scramble.append(moves[random])
  54.  
  55. lenght = len(scramble)
  56.  
  57. print (scramble)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement