Random numbers in c#
i use Random rnd = new Random(); x=rnd.Next(10); but every time i get the same number. how to fix it and get different numbers? Tell me easy method. thanks. sorry for bad english. ...
i use Random rnd = new Random(); x=rnd.Next(10); but every time i get the same number. how to fix it and get different numbers? Tell me easy method. thanks. sorry for bad english. ...
I was hoping someone with better math capabilities would assist me in figuring out the total possibilities for a string given it's length and character set. i.e. [a-f0-9]{6} What are the possibilities for this pattern of random characters? ...
Possible Duplicates: Unique random numbers in O(1)? How do you efficiently generate a list of K non-repeating integers between 0 and an upper bound N I want to generate random number in a certain diapason, and I must be sure, that each new number is not a duplicate of formers. One solution is to store formerly generated numb...
I'm trying to figure out a way to create random numbers that "feel" random over short sequences. This is for a quiz game, where there are four possible choices, and the software needs to pick one of the four spots in which to put the correct answer before filling in the other three with distractors. Obviously, arc4random % 4 will create...
Is it possible to retrieve random rows from table X where flags==0? Using MySql and C# ...
My app writes a lot of XML data, and randomly the last line of the following piece of code: // Prepare the DOM document for writing Source source = new DOMSource(node); // Prepare the output stream Result result = new StreamResult(stream); // Write the DOM document to the file Transformer xformer = TransformerFactory.newInstance().new...
I want to write a function which randomizes the order of a sequence of alphabetic characters. For example, the sequence: A B C D E F G . . . ...might be changed to: Z L T A P ... ...which, if passed to the same function again could result in: H R E I C .... Any suggestions? ...
Let's say you have N runnable objects, and for each you want them to execute for random periods of time. Once a runnable object executes for that time period, you want to reschedule it to run for another random period of time. You want to be able to do this for each of the runnables, multiple times. Once a runnable is started, it should...
I'm toying around with writing a random map generator, and am not quite sure how to randomly generate realistic landscapes. I'm working with these sorts of local-scale maps, which presents some interesting problems. One of the simplest cases is the forest: Sparse Medium Dense Typical trees 50% 70% 80...
Given an arbitrary enumeration in C#, how do I select a random value? (I did not find this very basic question on SO. I'll post my answer in a minute as reference for anyone, but please feel free to post your own answer.) ...
I've been trying to make a little simple game just to test my logics, and it's a simple labyrinth, it's ugly, and so far sucky. The engine works pretty well, given that the labyrinth already exists (a matrix), it could be even enjoyable, but I have no intention on drawing a bunch of maps, which might be setting values on 400 (20x20) fie...
An application I'm working on requires a matrix of random numbers. The matrix can grow in any direction at any time, and isn't always full. (I'll probably end up re-implementing it with a quad tree or something else, rather than a matrix with a lot of null objects.) I need a way to generate the same matrix, given the same seed, no matte...
I want to generate a random number in PHP where the digits itself should not repeat in that number. Is that possible? Can you paste sample code here? Ex: 674930, 145289. [i.e Same digit shouldn't come] Thanks ...
I have a Numpy array that looks like >>> a array([[ 3. , 2. , -1. ], [-1. , 0.1, 3. ], [-1. , 2. , 3.5]]) I would like to select a value from each row at random, but I would like to exclude the -1 values from the random sampling. What I do currently is: x=[] for i in range(a.shape[0]): idx=numpy.where(a[i,:]>0...
Hello, I have a requirement in my .net project where I need to select an item from a collection, each item has a Weight (integer from 1 to 10) assigned to it. I need a random generator that would take this weight into consideration i.e. the higher the weight, the more chances the object would be selected. Any code samples in .net are ap...
Hi, I have a JQuery script which acts as a simple image rollover with a nice fade effect. Here is a test version of the current script in action - http://fi-testing.co.uk/SO/rubix-cube.html As you can see, there are 9 blocks, the client wishes for the rollovers to occur randomly (without a hover) to kind of create a ripple/pulsating e...
Is there a traditional way to map over a function that uses IO? Specifically, I'd like to map over a function that returns a random value of some kind. Using a normal map will result in an output of type ([IO b]), but to unpack the values in the list from IO, I need a something of type (IO [b]). So I wrote... mapIO :: (a -> IO b) -> [a]...
Following is from python website, about random.shuffle(x[, random]) Shuffle the sequence x in place. The optional argument random is a 0-argument function returning a random float in [0.0, 1.0); by default, this is the function random(). Note that for even rather small len(x), the total number of permutations of x is large...
so say i have a grid: 0 - 1 - 2 - 3 4 - 5 - 6 - 7 8 - 9 - 10 - 11 12 - 13 - 14 - 15 (but will be more rows...) how can i find out programmatically if a random number (within the range of the numbers) is equal to the far right number: 3,7,11,15...? thanks ...
I want to create a web app similar to http://www.pastebin.com/ in Ruby on Rails. pastebin.com uses a random string to identify an item. Ruby on Rails uses an auto-incrementing number. How can I make Ruby on Rails also use these random strings as IDs for items, instead of auto-incrementing numbers? Thanks ...