I am new to programming here, so please be patient. :)

So, I am making a game where you pick a number 1-100, the calculator tries to guess it, and you tell it if it's high or low. The problem is, the randint( command is giving out numbers with a pattern. ex: 28 48 63 73 80 85 89 92 94. The numbers are all similar and seem to go up by a certain amount each time. Anyone know what could be wrong? Thanks!

Have you kept going?

When it comes to computers and calculators, there is no such thing as true randomness. Rather, the random number generators are based on a complex algorithm that is meant to produce a sequence of numbers with no distinguishable pattern. While this seems rather conspicuous, it could just be that you got "lucky". If you keep going and repeatedly get 99, then that would be a cause for concern.

When in doubt, just select any random number and reset the seed for the randomizer:

17→rand

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

I do have a seed, however, and no matter what the seed is, I still get the same kind of formula, slowly increasing numbers until it chooses a number to stop at, repeating that number over and over.

can you show us your code?

if you happen to care:

class TIrandom: def __init__(self,seed = random() * time()): '''TI 83/84+ Random Number generators''' self.__MAX1 = 2147483563 self.__MAX2 = 2147483399 self.__MULT1 = 40014 self.__MULT2 = 40692 seed %= 1000000000 if seed == 0: seed1 = 12345 seed2 = 67890 else: seed2 = seed seed1 = self.__MULT1*seed self.__seed1 = seed1 self.__seed2 = seed2 def __iterate(self): self.__seed1 = (self.__seed1*self.__MULT1) % self.__MAX1 self.__seed2 = (self.__seed2*self.__MULT2) % self.__MAX2 def rand(self, number_of_outputs=1): self.out = [] for x in xrange(number_of_outputs): self.__iterate() ans = (self.__seed1-self.__seed2)/float(self.__MAX1) ans += (ans<=0) self.out += [ans] return self.__output() def randInt(self, lower, upper, number_of_outputs=1): self.out = [] lower, upper = min(lower, upper), max(lower,upper) for x in xrange(number_of_outputs): self.out += [int(lower + (upper-lower+1) * self.rand())] return self.__output() def __output(self): if len(self.out) == 1: return self.out[0] return self.out

Visit Calccrypto for info on crypto

KC2ZOF

More than likely, an Assembly program drew outside of the graph buffer and screwed up your RNG. If 0→rand and [2nd][+][7][2][2] don't help, you should visit #cemetech on EFnet and ask about fixing it, since your case may be special and need more Q&A probing.

It could be that you are taking randInt(A,B and slowly converging A and B to a point based on guesses?

Z80 Assembly>English>TI-BASIC>Python>French>C>0

Yes, that is exactly what I am doing, but after exactly 2 guesses, the random numbers start… well… not being random. :) Is this just a problem in my code, or possibly a bigger issue?

The point of the program is you pick a number 1-100, the program guesses it, and you tell it if it's high, low, or right. This is just the basic meat of the code, and where i suspect the issue is happening. Forgive me for any stupid mistakes/no optimization, I am mostly self-taught.

```
:Lbl Z
:randint(A,B)->C
:Disp "I guess...",C
:Menu("Am i...","High?",D,"Low?",F,"Right?",G)
:Lbl D
:C->B
:Goto Z
:Lbl F
:C->A
:Goto Z
:Lbl G
:Disp " I WIN!!"
```

I don't suppose it could be something as simple as resetting your A and B variables to 1 and 100? Perhaps you could upload the actual program (though I don't know how) so that we could test it out.

I think that the problem may be that A and B are not constants. When you reuse that one single randint( command something is changing the function of the command. Try adding randint(A,B)->C before the goto Z in labels F and D. Then delete the first line of command (lbl z) and put it after the first rand int. It should look like this.

```
:randint(A,B)->C
:lbl Z
:Disp "I guess...",C
:Menu("Am i...","High?",D,"Low?",F,"Right?",G)
: Lbl D
: C->B
:randint(A,B)->C
:Goto Z
: Lbl F
:C->A
:randint(A,B)->C
:Goto Z
:Lbl G
:Disp " I WIN!!"
```

I tried this program as is, and didn't see any issues at all. Could you elaborate on how the results are not being random?

@jurgella

I just realized that at the beginning of your program you are not defining your A and B variables. You may want to add this at the beginning of your program, or just use different variables, such as C and D.

```
:1->A
:100->B
```