+ Reply to Thread
Results 1 to 11 of 11

Thread: [SNIPPET] Python code to generate shiny TID/SIDs from a PID

  1. #1
    Python Tamer ILOVEPIE's Avatar
    Join Date
    Aug 2011
    Posts
    38

    [SNIPPET] Python code to generate shiny TID/SIDs from a PID

    Requires this class:
    Code:
    class bf(object):
    	def __init__(self,value=0):
    		self._d = value
    
    	def __getitem__(self, index):
    		return (self._d >> index) & 1 
    
    	def __setitem__(self,index,value):
    		value    = (value&1L)<<index
    		mask     = (1L)<<index
    		self._d  = (self._d & ~mask) | value
    
    	def __getslice__(self, start, end):
    		mask = 2L**(end - start) -1
    		return (self._d >> start) & mask
    
    	def __setslice__(self, start, end, value):
    		mask = 2L**(end - start) -1
    		value = (value & mask) << start
    		mask = mask << start
    		self._d = (self._d & ~mask) | value
    		return (self._d >> start) & mask
    
    	def __int__(self):
    		return self._d
    Function:
    Code:
    def shinygen(pokemonid):
    	"""Returns Tuple of Shiny TID and SID for given PID"""
    	shiny=False
    	n=0
    	while shiny == False:
    		tid=bf(random.getrandbits(16))
    		sid=bf(random.getrandbits(16))
    		pid=bf(pokemonid)
    		n +=1
    		shiny = True
    		for i in range(0,13):
    			if int(pid[15-i]) + int(pid[31-i])+ int(tid[15-i])+ int(sid[15-i])== 3:
    					shiny = False
    					break
    			elif int(pid[15-i])+ int(pid[31-i])+ int(tid[15-i])+ int(sid[15-i])== 1:
    					shiny = False
    					break
    	if shiny:
    		return (tid,sid)
    	else:
    		return False
    Demo Program that generates shiny TID/SIDs:
    (on dropbox because py2exe is too big to upload [barely])
    http://dl.dropbox.com/u/20328726/MakeShiny.zip
    Last edited by ILOVEPIE; Aug 28th, 2011 at 05:05 PM. Reason: code glitch found and fixed

  2. #2

    Re: [SNIPPET] Python code to generate shiny TID/SIDs from a PID

    so basically.. you're generating random tids/sids and finding a match. That's sort of .. silly, as there are more efficient ways to do it.

    disregarding the number of errors thrown when running your 'snippet' (you should add you need to do things like setting 'pokemonid' as an input value, defining random), the program downloaded from your dropbox doesn't work.
    to clarify, it doesn't give you a shiny tid/sid. only one close to it.
    bond and i tested it.


    nevermind; it's oddly not working with pokegen for me (but bond's managed to get it work, so i suppose it's fine).
    Last edited by arcee; Aug 22nd, 2011 at 12:59 AM.

  3. #3

    Re: [SNIPPET] Python code to generate shiny TID/SIDs from a PID

    take the upper half of the PID, make that the SID
    take the lower half of the PID, make that the TID

    bam shiny

  4. #4
    Python Tamer ILOVEPIE's Avatar
    Join Date
    Aug 2011
    Posts
    38

    Re: [SNIPPET] Python code to generate shiny TID/SIDs from a PID

    I don't know of any better way of generating Shiny TIDs & SIDs considering how shiny calculations are described here: http://www.smogon.com/ingame/rng/pid...tion#how_shiny
    anyways the computor will go through over 3000 combinations in less than a second... it doesn't take long... and the program does work i checked it with pokegen...

  5. #5
    Python Tamer ILOVEPIE's Avatar
    Join Date
    Aug 2011
    Posts
    38

    Re: [SNIPPET] Python code to generate shiny TID/SIDs from a PID

    Quote Originally Posted by Kaphotics View Post
    take the upper half of the PID, make that the SID
    take the lower half of the PID, make that the TID
    ok what if your pid is 11229867

    1010101101011|010
    1010101101011|010
    1010101101011|010
    nope not shiny...

    or even
    9132715
    that will not work either...
    there are many times that algorithm will fail

  6. #6
    Python Tamer ILOVEPIE's Avatar
    Join Date
    Aug 2011
    Posts
    38

    Re: [SNIPPET] Python code to generate shiny TID/SIDs from a PID

    the answer to the random problem is simply:
    Code:
    import random
    the answer to the other problem is to convert to an integer before you call the function

  7. #7

    Re: [SNIPPET] Python code to generate shiny TID/SIDs from a PID

    Quote Originally Posted by ILOVEPIE View Post
    the answer to the random problem is simply:
    Code:
    import random
    exactly .. so shouldn't you, you know, add that in at the top? it's sort of important for the thing to run : p

  8. #8

    Re: [SNIPPET] Python code to generate shiny TID/SIDs from a PID

    Quote Originally Posted by ILOVEPIE View Post
    ok what if your pid is 11229867

    1010101101011|010
    1010101101011|010
    1010101101011|010
    nope not shiny...

    or even
    9132715
    that will not work either...
    there are many times that algorithm will fail
    it's referring to the hexidecimal PID, not the decimal.

    each half of the PID is 4 hex characters long, same deal with the TID/SID.

  9. #9
    Python Tamer ILOVEPIE's Avatar
    Join Date
    Aug 2011
    Posts
    38

    Re: [SNIPPET] Python code to generate shiny TID/SIDs from a PID

    yes i am aware of that but the way to determine shiny is through binary not hex... you can't just set the TID to the upper half and then have the SID set to the lower half... it will work more often than normal but it still fails if you have a PID like 9132715 which if you split it in half has on bits that overlap 3 times

  10. #10

    Re: [SNIPPET] Python code to generate shiny TID/SIDs from a PID

    BEEFCAFE

    BEEF^CAFE
    BEEF^CAFE

    BEEF^CAFE^BEEF^CAFE = BEEF^BEEF^CAFE^CAFE = 0
    ie always shiny if you do it that way :P

  11. #11
    Python Tamer ILOVEPIE's Avatar
    Join Date
    Aug 2011
    Posts
    38

    Re: [SNIPPET] Python code to generate shiny TID/SIDs from a PID

    Quote Originally Posted by arcee View Post
    nevermind; it's oddly not working with pokegen for me (but bond's managed to get it work, so i suppose it's fine).
    Thats because it was checking all values between position 0 and position 11 not between 0 and position 12

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
PPN Top 50