matchWall.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import utils.conf
  2. import utils.getarray
  3. # 判断能否摆下组件的贴墙边
  4. from utils import getarray
  5. # 判断当前边能否放下指定模块
  6. def canMatch(wallLength, moduleLengths):
  7. moduleTotalLength = 0;
  8. for item in moduleLengths:
  9. moduleTotalLength = moduleTotalLength + item
  10. return (moduleTotalLength <= wallLength)
  11. # matchResult = canMatch(3,(1,1,2))
  12. # print(matchResult)
  13. # 获取当前位置的所有摆法
  14. def matchWalls(roomLengths, moduleLengths):
  15. m = len(roomLengths)
  16. n = len(moduleLengths)
  17. a=getarray.getAllArray(m,n)
  18. canMatchTop = canMatch(roomLengths[2], moduleLengths)
  19. if(canMatchTop):
  20. print("begin to calc top")
  21. matchWall(roomLengths,moduleLengths,"222")
  22. else:
  23. for item in a:
  24. matchWall(roomLengths,moduleLengths,a[item])
  25. def matchWall(roomLengths, moduleLengths, positions):
  26. m = len(roomLengths)
  27. n = len(moduleLengths)
  28. a = getarray.getitemIndexArray(positions,m,n)
  29. pass
  30. #一字摆法
  31. def matchTopWall(roomLengths,moduleLengths):
  32. matchWalls(roomLengths, moduleLengths, "222")
  33. matchWalls([1,2,3,4],[1,1,1])