Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6636651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:12:46+00:00 2026-05-25T23:12:46+00:00

The c#/XNA process for creating random numbers is pretty quick and easy, however, it

  • 0

The c#/XNA process for creating random numbers is pretty quick and easy, however, it is quite possibly the worst distributing random number generator I have ever seen. Is there a better method that is easy to implement for c#/XNA?

rand.Next() just doesn’t suit my needs.

from:

static private Random rand = new Random();

I randomly place objects, all over my program. sometimes 10, sometimes 200.

When calling for random objects (the x val and y val are both random on a 2d plane), they group. The generation code is clean and calls them good, iterated cleanly and pulls a new random number with each value. But they group, noticeably bad, which isn’t very good with random numbers after all. I’m intermediate skill with c#, I crossed over from as3, which seemed to handle randomness better.

I am well-aware that they are pseudo random, but C# on a windows system, the grouping is grotesque.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:12:47+00:00Added an answer on May 25, 2026 at 11:12 pm

    Can you use System.Security.Cryptography.RandomNumberGenerator from XNA?

    var rand = RandomNumberGenerator.Create();
    byte[] bytes = new byte[4];
    
    rand.GetBytes(bytes);
    
    int next = BitConverter.ToInt32(bytes, 0);
    

    To get a value within a min/max range:

    static RandomNumberGenerator _rand = RandomNumberGenerator.Create();
    
    static int RandomNext(int min, int max)
    {
        if (min > max) throw new ArgumentOutOfRangeException("min");
    
        byte[] bytes = new byte[4]; 
    
        _rand.GetBytes(bytes);
    
        uint next = BitConverter.ToUInt32(bytes, 0);
    
        int range = max - min;
    
        return (int)((next % range) + min);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use XNA as a nice easy basis for some graphics processing I'm doing
I made a program in XNA 4.0 that should simulate an assembly line process.
I am using XNA my rocket is creating smoke objects when it fly. I
The XNA game that I am working on for WP7 supports multiple languages. However,
I'm using XNA and creating a bunch of forms that roll their own 'game
XNA games have an Unload() method, where content is supposed to be unloaded. But
In XNA, how do I load in a texture or mesh from a file
Using XNA 4.0, I am currently playing songs from the user's PC/XBox360 using the
I have develop an XNA game on computer 1. When I send it to
I've used XNA and Visual Studio 2005 integrated with Flash. I'm curious to see

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.