Advertisement
luckytyphlosion

pokered Random in python

Nov 14th, 2015
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. from random import randint
  2. import threading
  3. import time
  4.  
  5. RNG = 0
  6. hRandomAdd = 0
  7. hRandomSub = 0
  8.  
  9. whichRandom = False
  10. numberToFind = randint(0,255)
  11. if randint(0,1) != 0:
  12.     whichRandom = True
  13.  
  14. print "Looking for Random Number %s in %s" % (numberToFind, "hRandomAdd" if whichRandom else "hRandomSub")
  15.  
  16. time.sleep(3)
  17.  
  18. def callRandom():
  19.     global hRandomAdd
  20.     global hRandomSub
  21.     hRandomAdd += RNG
  22.     hRandomSub -= (RNG + ((hRandomAdd & 0b100000000) >> 8))
  23.     hRandomAdd = hRandomAdd & 0xff
  24.     hRandomSub = hRandomSub % 0x100
  25.     print "hRandomAdd: %s\r\nhRandomSub: %s\r\nrDIV: %s\r\n---------------" % (hRandomAdd,hRandomSub,RNG)
  26.    
  27.     r = threading.Timer(1/59.7275,callRandom)
  28.     r.daemon = True
  29.     r.start()
  30.    
  31. def rDIV():
  32.     t = threading.Timer(1/16384, rDIV)
  33.     t.daemon = True
  34.     t.start()
  35.     global RNG
  36.     RNG += 1
  37.     RNG = RNG & 0xff
  38.    
  39. callRandom()
  40. rDIV()
  41.  
  42. if whichRandom:
  43.     while hRandomAdd != numberToFind:
  44.         pass
  45. else:
  46.     while hRandomSub != numberToFind:
  47.         pass
  48.        
  49. print "\r\nDone!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement