当前位置:   article > 正文

骑士巡游问题 python_closed knight's tour python

closed knight's tour python
  1. # -*- coding: utf-8 -*-
  2. import numpy as np
  3. def printP():
  4. global n
  5. global pieces
  6. for i in range(n):
  7. for j in range(n):
  8. print "%d\t"%pieces[i][j],
  9. print ""
  10. def init():
  11. '''
  12. 初始化棋盘
  13. '''
  14. global n
  15. global pieces
  16. global point #用于记录剩余的点
  17. pieces = [([0]*100)for j in range(100)]
  18. pieces = np.array(pieces)
  19. point = []
  20. for i in range(n):
  21. for j in range(n):
  22. point.append((i,j))
  23. def checkXY(x,y):
  24. '''
  25. 检查点(x,y)是否在棋盘上
  26. '''
  27. global n
  28. if x>=0 and x<n and y>=0 and y<n:
  29. return True
  30. return False
  31. def out1(x,y):
  32. '''
  33. 找出所有方向(包括已经被走过的点)
  34. '''
  35. global n
  36. global pieces
  37. global direction
  38. outLine1 = []
  39. for i in range(8):
  40. x1 = x+direction[i][0]
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/573532
推荐阅读
相关标签
  

闽ICP备14008679号