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   Members   

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



#2   Members   

3133
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   Members   

8927
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   Members   

517
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   Members   

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   Moderators   

9738
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.

zlib: eJzVVLsSAiEQ6/1qCwoK i7PxA/2S2zMOZljYB1TO ZG7OhUtiduH9egZQCJH9 KcJyo4Wq9t0/RXkKmjx+ cgU4FIMWHhKCU+o/Nx2R LEPgQWLtnfcErbiEl0u4 0UrMghhZewgYcptoEF42 YMj+Z1kg+bVvqxhyo17h nUf+h4b2W4bR4XO01TJ7 qFNzA7jjbxyL71Avh6Tv odnFk4hnxxAf4w6496Kd OgH7/RxC




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.