Browse Source

whrandom -> random

Chris Brunner 18 years ago
parent
commit
181d891578

+ 2 - 1
direct/src/gui/DirectGuiTest.py

@@ -6,7 +6,8 @@ __all__ = []
 if __name__ == "__main__":
 if __name__ == "__main__":
     from direct.directbase import DirectStart
     from direct.directbase import DirectStart
     from DirectGui import *
     from DirectGui import *
-    from whrandom import *
+    #from whrandom import *
+    from random import *
 
 
     # EXAMPLE CODE
     # EXAMPLE CODE
     # Load a model
     # Load a model

+ 17 - 15
direct/src/leveleditor/LevelEditor.py

@@ -11,14 +11,16 @@ from direct.tkwidgets.SceneGraphExplorer import *
 from tkMessageBox import showinfo
 from tkMessageBox import showinfo
 from tkFileDialog import *
 from tkFileDialog import *
 from Tkinter import *
 from Tkinter import *
-from whrandom import *
+#from whrandom import *
+from random import *
 from direct.tkwidgets import Floater
 from direct.tkwidgets import Floater
 from direct.tkwidgets import VectorWidgets
 from direct.tkwidgets import VectorWidgets
 import string
 import string
 import os
 import os
 import getopt
 import getopt
 import sys
 import sys
-import whrandom
+#import whrandom
+import random
 import types
 import types
 from direct.task import Task
 from direct.task import Task
 import Pmw
 import Pmw
@@ -1603,7 +1605,7 @@ class LevelEditor(NodePath, DirectObject):
             print "createDoor %s" % type
             print "createDoor %s" % type
             if not (self.getCurrent('door_double_texture')):
             if not (self.getCurrent('door_double_texture')):
                 doorStyles = self.styleManager.attributeDictionary['door_double_texture'].getList()[1:]
                 doorStyles = self.styleManager.attributeDictionary['door_double_texture'].getList()[1:]
-                defaultDoorStyle = whrandom.choice(doorStyles)
+                defaultDoorStyle = random.choice(doorStyles)
                 self.setCurrent('door_double_texture', defaultDoorStyle)
                 self.setCurrent('door_double_texture', defaultDoorStyle)
             newDNADoor.setCode(self.getCurrent('door_double_texture'))
             newDNADoor.setCode(self.getCurrent('door_double_texture'))
             print "doorcolor = %s" % self.getCurrent('door_color')
             print "doorcolor = %s" % self.getCurrent('door_color')
@@ -1612,7 +1614,7 @@ class LevelEditor(NodePath, DirectObject):
             newDNADoor = DNAFlatDoor('door')
             newDNADoor = DNAFlatDoor('door')
             if not (self.getCurrent('door_single_texture')):
             if not (self.getCurrent('door_single_texture')):
                 doorStyles = self.styleManager.attributeDictionary['door_single_texture'].getList()[1:]
                 doorStyles = self.styleManager.attributeDictionary['door_single_texture'].getList()[1:]
-                defaultDoorStyle = whrandom.choice(doorStyles)
+                defaultDoorStyle = random.choice(doorStyles)
                 self.setCurrent('door_single_texture', defaultDoorStyle)
                 self.setCurrent('door_single_texture', defaultDoorStyle)
             newDNADoor.setCode(self.getCurrent('door_single_texture'))
             newDNADoor.setCode(self.getCurrent('door_single_texture'))
             newDNADoor.setColor(self.getCurrent('door_color'))
             newDNADoor.setColor(self.getCurrent('door_color'))
@@ -3599,7 +3601,7 @@ class LevelEditor(NodePath, DirectObject):
                 colorList = self.getAttribute('door_color').getList()
                 colorList = self.getAttribute('door_color').getList()
                 colorList = colorList[1:3] + colorList[4:len(colorList)]
                 colorList = colorList[1:3] + colorList[4:len(colorList)]
                 # Set a random door color
                 # Set a random door color
-                doorColor = whrandom.choice(colorList)
+                doorColor = random.choice(colorList)
                 self.setCurrent('door_color', doorColor)
                 self.setCurrent('door_color', doorColor)
                 self.addLandmark(oldDNANode.getCode(), oldDNANode.getBuildingType())
                 self.addLandmark(oldDNANode.getCode(), oldDNANode.getBuildingType())
                 bldg = self.lastNodePath
                 bldg = self.lastNodePath
@@ -3703,13 +3705,13 @@ class LevelEditor(NodePath, DirectObject):
                     elif curveType == 'trees':
                     elif curveType == 'trees':
                         curve.getPoint(currT, currPoint)
                         curve.getPoint(currT, currPoint)
                         # trees are spaced anywhere from 40-80 ft apart
                         # trees are spaced anywhere from 40-80 ft apart
-                        treeWidth = whrandom.randint(40, 80)
+                        treeWidth = random.randint(40, 80)
                         curGroupWidth += treeWidth
                         curGroupWidth += treeWidth
                         # Adjust grid orientation based upon next point along curve
                         # Adjust grid orientation based upon next point along curve
                         currT, currPoint = self.findBldgEndPoint(treeWidth, curve, currT, currPoint, rd = 0)
                         currT, currPoint = self.findBldgEndPoint(treeWidth, curve, currT, currPoint, rd = 0)
 
 
                         # Add some trees
                         # Add some trees
-                        tree = whrandom.choice(["prop_tree_small_ul",
+                        tree = random.choice(["prop_tree_small_ul",
                                                 "prop_tree_small_ur",
                                                 "prop_tree_small_ur",
                                                 "prop_tree_large_ur",
                                                 "prop_tree_large_ur",
                                                 "prop_tree_large_ul"])
                                                 "prop_tree_large_ul"])
@@ -3717,7 +3719,7 @@ class LevelEditor(NodePath, DirectObject):
                         #use snow if necessaryy
                         #use snow if necessaryy
 
 
                         if (useSnowTree):
                         if (useSnowTree):
-                            tree = whrandom.choice(["prop_snow_tree_small_ul",
+                            tree = random.choice(["prop_snow_tree_small_ul",
                                                     "prop_snow_tree_small_ur",
                                                     "prop_snow_tree_small_ur",
                                                     "prop_snow_tree_large_ur",
                                                     "prop_snow_tree_large_ur",
                                                     "prop_snow_tree_large_ul"])
                                                     "prop_snow_tree_large_ul"])
@@ -3763,14 +3765,14 @@ class LevelEditor(NodePath, DirectObject):
                             #add a prop_tree to force it to be shown
                             #add a prop_tree to force it to be shown
                             curve.getPoint(currT, currPoint)
                             curve.getPoint(currT, currPoint)
                             #trees are spaced anywhere from 40-80 ft apart
                             #trees are spaced anywhere from 40-80 ft apart
-                            #treeWidth = whrandom.randint(40, 80)
+                            #treeWidth = random.randint(40, 80)
                             treeWidth = barricadeWidth
                             treeWidth = barricadeWidth
                             curGroupWidth += treeWidth
                             curGroupWidth += treeWidth
                             # Adjust grid orientation based upon next point along curve
                             # Adjust grid orientation based upon next point along curve
                             currT, currPoint = self.findBldgEndPoint(treeWidth, curve, currT, currPoint, rd = 0)
                             currT, currPoint = self.findBldgEndPoint(treeWidth, curve, currT, currPoint, rd = 0)
 
 
                             # Add some trees
                             # Add some trees
-                            tree = whrandom.choice(["prop_snow_tree_small_ul",
+                            tree = random.choice(["prop_snow_tree_small_ul",
                                                 "prop_snow_tree_small_ur",
                                                 "prop_snow_tree_small_ur",
                                                 "prop_snow_tree_large_ur",
                                                 "prop_snow_tree_large_ur",
                                                 "prop_snow_tree_large_ul"])
                                                 "prop_snow_tree_large_ul"])
@@ -3873,20 +3875,20 @@ class LevelEditor(NodePath, DirectObject):
                     elif curveType == 'trees':
                     elif curveType == 'trees':
                         curve.getPoint(currT, currPoint)
                         curve.getPoint(currT, currPoint)
                         # trees are spaced anywhere from 40-80 ft apart
                         # trees are spaced anywhere from 40-80 ft apart
-                        treeWidth = whrandom.randint(40, 80)
+                        treeWidth = random.randint(40, 80)
                         curGroupWidth += treeWidth
                         curGroupWidth += treeWidth
                         # Adjust grid orientation based upon next point along curve
                         # Adjust grid orientation based upon next point along curve
                         currT, currPoint = self.findBldgEndPoint(treeWidth, curve, currT, currPoint, rd = 0)
                         currT, currPoint = self.findBldgEndPoint(treeWidth, curve, currT, currPoint, rd = 0)
 
 
                         # Add some trees
                         # Add some trees
-                        tree = whrandom.choice(["prop_tree_small_ul",
+                        tree = random.choice(["prop_tree_small_ul",
                                                 "prop_tree_small_ur",
                                                 "prop_tree_small_ur",
                                                 "prop_tree_large_ur",
                                                 "prop_tree_large_ur",
                                                 "prop_tree_large_ul"])
                                                 "prop_tree_large_ul"])
 
 
                         #use snow tree if necessary
                         #use snow tree if necessary
                         if (useSnowTree):
                         if (useSnowTree):
-                            tree = whrandom.choice(["prop_snow_tree_small_ul",
+                            tree = random.choice(["prop_snow_tree_small_ul",
                                                     "prop_snow_tree_small_ur",
                                                     "prop_snow_tree_small_ur",
                                                     "prop_snow_tree_large_ur",
                                                     "prop_snow_tree_large_ur",
                                                     "prop_snow_tree_large_ul"])
                                                     "prop_snow_tree_large_ul"])
@@ -3932,14 +3934,14 @@ class LevelEditor(NodePath, DirectObject):
                             #add a prop_tree to force it to be shown
                             #add a prop_tree to force it to be shown
                             curve.getPoint(currT, currPoint)
                             curve.getPoint(currT, currPoint)
                             #trees are spaced anywhere from 40-80 ft apart
                             #trees are spaced anywhere from 40-80 ft apart
-                            #treeWidth = whrandom.randint(40, 80)
+                            #treeWidth = random.randint(40, 80)
                             treeWidth = barricadeWidth
                             treeWidth = barricadeWidth
                             curGroupWidth += treeWidth
                             curGroupWidth += treeWidth
                             # Adjust grid orientation based upon next point along curve
                             # Adjust grid orientation based upon next point along curve
                             currT, currPoint = self.findBldgEndPoint(treeWidth, curve, currT, currPoint, rd = 0)
                             currT, currPoint = self.findBldgEndPoint(treeWidth, curve, currT, currPoint, rd = 0)
 
 
                             # Add some trees
                             # Add some trees
-                            tree = whrandom.choice(["prop_snow_tree_small_ul",
+                            tree = random.choice(["prop_snow_tree_small_ul",
                                                 "prop_snow_tree_small_ur",
                                                 "prop_snow_tree_small_ur",
                                                 "prop_snow_tree_large_ur",
                                                 "prop_snow_tree_large_ur",
                                                 "prop_snow_tree_large_ul"])
                                                 "prop_snow_tree_large_ul"])

+ 2 - 2
direct/src/showbase/ShowBase.py

@@ -217,11 +217,11 @@ class ShowBase(DirectObject.DirectObject):
             # If we're either playing back or recording, pass the
             # If we're either playing back or recording, pass the
             # random seed into the system so each session will have
             # random seed into the system so each session will have
             # the same random seed.
             # the same random seed.
-            import random, whrandom
+            import random #, whrandom
 
 
             seed = self.recorder.getRandomSeed()
             seed = self.recorder.getRandomSeed()
             random.seed(seed)
             random.seed(seed)
-            whrandom.seed(seed & 0xff, (seed >> 8) & 0xff, (seed >> 16) & 0xff)
+            #whrandom.seed(seed & 0xff, (seed >> 8) & 0xff, (seed >> 16) & 0xff)
 
 
         # Now that we've set up the window structures, assign an exitfunc.
         # Now that we've set up the window structures, assign an exitfunc.
         self.oldexitfunc = getattr(sys, 'exitfunc', None)
         self.oldexitfunc = getattr(sys, 'exitfunc', None)