Hi all,

As a side project, I am porting the rand* commands on TI-84 PLUS (rand, randInt, randBin, randIntNoRep, randM and randNorm) to Python. This will enable you to generate random numbers on your PC that are the same as the ones the calculator gives.

For example, to make groups, my teacher asks me a seed for rand, gives us all a number and then divides groups with randInt. I would like to generate a seed so I am together in a group with a friend of mine. In order to do that, I want to bruteforce a seed that sets us together on my PC.

So I started with porting the rand command to python. Thanks Richard. I then ported randInt and randBin (just for completeness). I am now stuck at randIntNoRep. Can anyone post an implementation of it in TI-BASIC or another PL? It will need to ouput the same numbers as the original randIntNoRep command (assuming you are using the same seed).

In case you are curious, here is the code I already have.

I added support for randM. An implementation of randIntNoRep is still wanted
I haven't looked into the OS to see how it implements randInNoRep, but have you tried the equivalent of the following?

Code:
```vals = range(start, end) dummy = [yourlib.rand() for i in range(start, end)] dummy, vals = (list(t) for t in zip(*sorted(zip(dummy, vals))))```
Is this the same as the implementation on http://tibasicdev.wikidot.com/randintnorep ? Tried that, it didn't work. (it worked but gave other values).

Code:
```rand(52→L₂ seq(X,X,0,51→L₁ SortA(L₂,L₁```
Can you not just use random? For example:

Code:
``` import random random.seed([x])   //you could find a certain seed that would put you and your friend together? Just manipulate it in some way random.randint(a,b)   //a random integer between a and b random.uniform(a,b)   //basically the same as rand - gives you a float between a and b ```

obviously there's more in the library.

Why do you need your own library if there's random?
Michael2_3B wrote:
Why do you need your own library if there's random?
The PRNG underlying Python's random numbers is not the same as the one that TI-BASIC uses. He wants to be able to get the same random numbers from the same seed that he would get on a calculator.

redfast00 wrote:
Is this the same as the implementation on http://tibasicdev.wikidot.com/randintnorep ? Tried that, it didn't work. (it worked but gave other values).

Code:
```rand(52→L₂ seq(X,X,0,51→L₁ SortA(L₂,L₁```
Yes, it's essentially the same as that, but in Python.
Do we know where the OS PRNG is located?
The algorithm is documented in many places, here is an example.
@CVSoft
I already have the algorithm for rand, and then derived randInt, randBin, randM. The problem is that I don't know how the algorithm for shuffeling (randIntNoRep) works.
@elfprince13
What (free & opensource) tools would one use to reverse engineer this?
An emulator (e.g. jsTIfied, WabbitEmu) and/or https://github.com/drdnar/eZDisasm are important tools for reverse engineering.

Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

»
» All times are UTC - 5 Hours

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum