ILOVEPIE
Aug 21st, 2011, 09:08 PM
Requires this class:
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:
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
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:
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