Last active
December 2, 2021 19:19
-
-
Save Grayfox96/6cfbfaccc72a022bf276e478ea00cea2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
def s32(integer: int) -> int: | |
return ((integer & 0xffffffff) ^ 0x80000000) - 0x80000000 | |
def datetime_to_seed(datetime: int) -> int: | |
seed = s32(datetime + 1) | |
seed = s32(s32(seed * 1108104919) + 11786) | |
seed = s32(s32(seed * 1566083941) + 15413) | |
seed = s32(s32(seed >> 16) + s32(seed << 16)) | |
if seed >= 0: | |
return seed | |
else: | |
return 0x100000000 + seed | |
def main(): | |
dt_input = input('Date and time (e.g. 1/30/2020 15:34:20): ') | |
dt_input = dt_input.strip() | |
dt = datetime.datetime.strptime(dt_input, '%m/%d/%Y %H:%M:%S') | |
dt_string = f'{dt.month:02}/{dt.day:02}/{int(str(dt.year)[-2:]):02} {dt.hour:02}:{dt.minute:02}:{dt.second:02}' | |
dt = dt + datetime.timedelta(seconds=1) | |
xored_datetime = dt.month ^ dt.day ^ int(hex(dt.year)[-2:], 16) ^ dt.hour ^ dt.minute ^ dt.second ^ 0b00010010 | |
print(f'Datetime (on selecting new game) -> Seed\n' | |
f'{dt_string:32} -> {datetime_to_seed(xored_datetime):10} ({xored_datetime})') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment