Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2014
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.73 KB | None | 0 0
  1. #Example stored info
  2. allEdges = [[['test', 50], [['pCube1', ['x'], 50], ['pCube2', ['y', 'y2'], 50]]], [['test2', 50], [['pCube1', ['x', 'y', 'y2'], 50]]], [['test3', 50], [['pCube1', ['x'], 50], ['pCube2', ['y'], 50], ['pCube3', ['x', 'x2', 'y', 'y2'], 50]]]]
  3.  
  4. #calculate probability
  5. totalProbability = 0
  6. for i in range( len( allEdges ) ):
  7.     totalProbability += float(allEdges[i][0][1])
  8.  
  9. #display text
  10. if debugInfo == True:
  11.     for i in range( len( allEdges ) ):
  12.         edgeInfo = allEdges[i][0]
  13.         objInfo = allEdges[i][1]
  14.         outputText = "'" + str(edgeInfo[0]) + "' (" + str( round( edgeInfo[1]/totalProbability, 2 ) ) + "% probability, chance of " + str( edgeInfo[1] ) + ") is applied to '"
  15.         for j in range( len( objInfo ) ):
  16.             outputText += objInfo[j][0] + "' for side"
  17.             objSides = objInfo[j][1]
  18.             if len( objSides ) > 1:
  19.                 outputText += "s"
  20.             for m in range( len( objSides ) ):
  21.                 outputText += " " + str( objSides[m] ).replace( "x2", "-x" ).replace( "y2", "-y" )
  22.                 if m == len( objSides )-2:
  23.                     outputText += " and"
  24.                 if m < len( objSides )-2:
  25.                     outputText += ","
  26.             if j == len( objInfo )-2:
  27.                 outputText += " and '"
  28.             if j < len( objInfo )-2:
  29.                 outputText += ", '"
  30.         print outputText
  31.  
  32.  
  33. #output:
  34. #'test' (0.33% probability, chance of 50) is applied to 'pCube1' for side x and 'pCube2' for sides y and -y
  35. #'test2' (0.33% probability, chance of 50) is applied to 'pCube1' for sides x, y and -y
  36. #'test3' (0.33% probability, chance of 50) is applied to 'pCube1' for side x, 'pCube2' for side y and 'pCube3' for sides x, -x, y and -y
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement