Jump to content

  • Log In with Google      Sign In   
  • Create Account


Rand is the same every time.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Kripis   Members   -  Reputation: 132

Like
0Likes
Like

Posted 08 February 2013 - 01:07 PM

uhm... title. Please help me the source code is below:

 

https://github.com/Kripis/-O/blob/master/Dinky%20Island



Sponsor:

#2 FLeBlanc   Crossbones+   -  Reputation: 3061

Like
3Likes
Like

Posted 08 February 2013 - 01:13 PM

You roll arrayChooser once at program start, but then you don't ever re-roll it as you move, so whatever the event is chosen to be at program start is what it will always be as you play.

#3 samoth   Crossbones+   -  Reputation: 4069

Like
0Likes
Like

Posted 08 February 2013 - 01:14 PM

Stunning... the usual answer (without looking at your code) would be: "Beginner error: you forgot to call srand or you are calling srand with the same value every time before calling rand". But, your code actually looks perfectly correct...

#4 ApEk   Members   -  Reputation: 439

Like
0Likes
Like

Posted 08 February 2013 - 01:19 PM

FleBlanc is correct. The variable arrayChooser never changes because you only call rand() once before the loop.



#5 Kripis   Members   -  Reputation: 132

Like
0Likes
Like

Posted 08 February 2013 - 09:07 PM

How could I fix this?? make a loop before the main loop that changed arrayChooser every time?



#6 fastcall22   Crossbones+   -  Reputation: 2988

Like
1Likes
Like

Posted 08 February 2013 - 09:35 PM

Move line 16 after line 26.

Edited by fastcall22, 08 February 2013 - 09:35 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS