Jump to content

  • Log In with Google      Sign In   
  • Create Account

Calling all IT Pros from Canada and Australia.. we need your help! Support our site by taking a quick sponsored surveyand win a chance at a $50 Amazon gift card. Click here to get started!


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: 3129

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: 6328

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: 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 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: 6250

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.

gzip: H4sIAAAAAAAEAG1QTUvEMBC991e8nvaiFfYoS7yo sLCo6MnjtJ1ugmkiyWRL/72z3T1YEQIJ8z4zA2Xp yPvt1qBpGrRFIJZkk9FyRyUzHCbKIHgn4hnZOrm1 TD0mG0HCCs+QGDGWziKXI6Wm2n++GYwUVH2mrGEE PnGCVQ8K8+JYfXA6URDEQfMZh5h6g5eoAlWJdeEI bbH2qYZf7XMUfw8f/Q0oMeZYNL9/WHF0uFEshvMr XYujd9SycFb+F18QcSOvlJauZ8ejqevdnV7/d550 e0t6prmunh73Bu+vz4c/XUeOQXfJgvKNkhf95U8/ Dtgmy5IBAAA=




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