4 Replies - 468 Views - Last Post: 16 July 2017 - 02:50 AM Rate Topic: -----

#1 Snaef98  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 11-July 17

Question about Random Numbers.

Posted 15 July 2017 - 04:41 AM

I have noticed something odd about using random when seeding it with ints. Specifically:

Random MonsterEncounter = new Random();
                    int ChoosenMonster = MonsterEncounter.Next(1, 2);



It seems as if the max roll is always 1 less then specified max. For the above example it would only roll 1-1?
Is This A Good Question/Topic? 0
  • +

Replies To: Question about Random Numbers.

#2 ndc85430  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 587
  • View blog
  • Posts: 2,466
  • Joined: 13-June 14

Re: Question about Random Numbers.

Posted 15 July 2017 - 04:57 AM

You should read the documentation for whatever API you're using, since that will tell you about what the method is expected to return.
Was This Post Helpful? 0
  • +
  • -

#3 Snaef98  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 11-July 17

Re: Question about Random Numbers.

Posted 15 July 2017 - 10:09 AM

Yeah I checked on that and switched some code "only have 1 instance of random".
Was This Post Helpful? 0
  • +
  • -

#4 ndc85430  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 587
  • View blog
  • Posts: 2,466
  • Joined: 13-June 14

Re: Question about Random Numbers.

Posted 15 July 2017 - 10:20 AM

That really doesn't make much sense. Your question seemed to be about the range of values that the method would return and the docs should tell you precisely what to expect.
Was This Post Helpful? 0
  • +
  • -

#5 Snaef98  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 11-July 17

Re: Question about Random Numbers.

Posted 16 July 2017 - 02:50 AM

I think its just a bug that occurs as part of a larger but when you use more then 1 random instance. It seems fixed for now. If I see any further issues ill check back with the forums. Thanks for trying to help ;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1