This tag is for questions pertaining to random numbers, whether pseudo random or truly random.

learn more… | top users | synonyms

12
votes
3answers
119 views

Weighted Probabilities with Integers for Game

The idea here is to pick a skill at random for the player each round. Four skills will be chosen, they are all random, and the same skill can repeat multiple times. The player has a skill level for ...
-1
votes
0answers
47 views

Text-based RPG game skeleton [closed]

I'm new to programming and I wanted to try my hand at it. Right now I have not gotten very far, but I'm working on the foundation. The model I'm following for this game is borrowed from other ...
4
votes
0answers
38 views

Bean Machine Simulation

I could not find a solution from my book's website (student-level access) but I feel that I am missing something that I'm supposed to learn from this exercise. Instructions: Balls are dropped from ...
10
votes
5answers
765 views

Generating a password to save to a .txt file

Here is my basic password generator which saves your password to a .txt file which you can choose the name of etc. ...
6
votes
3answers
651 views

Random number generation seeding in C++

I wrote a small function to return a random in a given range: ...
4
votes
2answers
63 views

Lorem ipsum chat bot

I'm a web development student, and I made a chat bot that emulates an SMS app commonly found on smartphones, etc. It responds with random lorem ipsum text. I'm wondering if my functions are too long ...
3
votes
1answer
40 views

Implement selection from array by 'random' or 'if/elif conditionals'

I'm working on some code examples in 'Automate the boring stuff in python...' to prepare for my first year of CS. I want to know if its better to use an array with random selection below or rather ...
7
votes
1answer
58 views

Small text-based RPG (v2)

This is my first text-based game I made. It's very small because I just learned Python and wanted to start small, and then code bigger programs. I added some stuff since the last time. Please give ...
5
votes
3answers
133 views

Small text-based RPG

This is my first text-based game I made. It's very small because I just learned Python and wanted to start small and then code bigger programs. Please comment on this. ...
8
votes
2answers
1k views

Guess a random number between 1 and 100

I want some recommendations or something I could add to the game. Please tell me what I could do better or what I did wrong. I made this during the time I learned Python. ...
8
votes
2answers
1k views

Text based fight game

I learned code about a week ago and I wanna hear some recommendations and stuff I could add to my code. This is a fight system I made for my text based game. Please tell me what I could do better. ...
6
votes
1answer
68 views

Generating 3D voxel terrain with Perlin Noise

I've created this simple 3D voxel terrain generator using Perlin Noise. I have a few concerns about it though. Is there any way to make it more performant? It currently takes ~1.5 seconds to ...
5
votes
3answers
95 views

Guess the bigger number out of two random integers

I want to make my code more efficient by instead of repeating my code again for level two, as the only change from level one to level two is the random numbers change from ...
1
vote
1answer
54 views

Brute-force word cracking program using /dev/urandom

I've been having fun with this program and trying to use different methods and such to achieve the fastest possible word cracking program I can come up with. I'm pretty happy with my current program ...
4
votes
1answer
83 views

Using random to generate strings

I have code that reads from files of surnames, female and male names and randomly generates a name in the following format: lastname, male/female name. The files are in the following format: ...
3
votes
2answers
105 views

Math quiz for teachers & students

I have been programming a maths quiz that can be used for teachers and I have have been trying to make the code as short as possible so it is easier to understand. If there is any way I could make it ...
7
votes
3answers
126 views

Slot Machine in Python

I have made this little program which allows you to play a slot machine: ...
8
votes
1answer
62 views

Poker probabilities finder

This code finds the probabilities of the various scores in Poker. It uses a Monte Carlo approach, in which, two million (\$2 \times 10^{6}\$) hands are simulated and evaluated, not an exhaustive ...
5
votes
2answers
125 views

Russian Roulette in Java using JFrame

A while ago I got bored and being the beginner programmer I am I made a Russian Roulette game in Java using JFrame. The first few windows are JOptionPanes that are a welcoming screen, an update log ...
2
votes
1answer
111 views

Bogosort vs bogobogosort [closed]

A question on Stack Overflow had me look up the article on bogosort on Wikipedia. There they describe the bogosort algorithm and the bogobogosort algorithm. They say, about this last algorithm, that: ...
5
votes
2answers
269 views

Alien Name Generator (using blocks of consonants and vowels)

This is my first script in Python, and I am looking for tips and constructive criticism about code style, whether there are more efficient ways of doing things, etc. (not as interested in tips about ...
10
votes
3answers
835 views

App for generating passwords

I wrote a simple JS app to generate passwords. I read up on some of the commenting standards for JS, and started reading the book Clean Code. I am not sure if I am writing the ...
8
votes
4answers
120 views

Buffon's Needle experiment

I was working on a program that simulates the Buffon's Needle experiment. If anyone is not familiar with it, a Wiki link is provided - Buffons's Needle The point of Buffon's experiment is to find ...
7
votes
4answers
147 views

Matrix struct with random values allocation and deallocation

I've written this code in 2013 or 2014, I think. I've rediscovered it today in one of my folders, made some changes and now I'm left (and my 2013/2014 me as well) wondering how good it looks for other ...
1
vote
2answers
194 views

Lotto/lucky draw

The following script draws 6 numbers at random. I input another 6 numbers and compare with random numbers generated, if they're the same, you win. ...
1
vote
4answers
191 views

Generating random numbers from thread timing in C++

I have the following code blocks that generate apparently random numbers by using thread timing variations. I am looking for a general code review, and a specific focus on whether the results are ...
7
votes
2answers
239 views

Random value excluding both limits

The javascript method Math.random() returns a (pseudo-)random float between 0 (inclusive) and 1 (exclusive). In some use cases, I need both limits to be excluded, ...
6
votes
1answer
81 views

Shuffling an arbitrary list or sequence

After reading this question I wanted to write a short example of how a list or sequence could be shuffled in .net. The result turned out to not be very short: Program.cs ...
6
votes
3answers
118 views

Efficient random code generator

I made a 16 character code generator. It works like a charm now, but I was wondering if there's any way to do it more efficiently. ...
10
votes
2answers
127 views

Random walk with equal probability

This method randomly increments or decrements (with equal probability) until either -3 or 3 are reached. I'd like to maintain printing the value of pos on each ...
8
votes
5answers
706 views

Generating new random items from a list

...
6
votes
2answers
102 views

Simple dice class

I've built a simple dice class utility for rolling dice. It supports weighted rolling, and usage is fairly simple. Here's the code. ...
4
votes
1answer
53 views

Identicon Generator

I'm just playing with Python, trying to refamiliarize myself with it since I haven't used it in a few years. I'm using Python3, but as far as I know it could easily be Python2 with a change to the ...
5
votes
2answers
249 views

Password generator with Secure Random

I have a small program in Java with GUI, which is generating passwords using Secure Random. I am posting my code here because I want to correct myself in style and, eventually, in efficiency of ...
7
votes
1answer
66 views

Improving Terrain Generation Time in C#

I am working on making my code run smoother, since I will be using it a lot in a game in development, but I am stumped. Is there any way I could make this run faster? Improvements to the terrain ...
3
votes
1answer
60 views

Retrieve random element from array not contained in second array

I have a function, getUnusedName that returns a random name, but first checks if it's already used by any object within a second array. Observing how many times ...
13
votes
3answers
683 views

Slot Machine Constructor

This is a fun little program I made of a fruit machine gambler, aka "slot machine". What mistakes am I making? How can I make this better OOP programming, less spaghetti? ...
2
votes
2answers
53 views

Generating random XML documents

I'm trying to generate a fresh XML file using Perl XML::Mini::Document. It's working fine, but I don't know whether it's the right way to do it. Performance is the ...
8
votes
2answers
176 views

Approximate (250 over 100) permutation best fitting certain criteria

Given a list of 250 words of 4 letters each, what is the fastest way, in Python, to find a subsample of 100 words (drawn without replacement) so that the distribution of letters across the whole ...
4
votes
1answer
81 views

Poker Odds Calculation with Monte Carlo

I have created an Odds Calculator in Java. The program gives me the odds, but I want to make sure that they are correct. Maybe someone can tell me a calculator I can compare my results with or knows ...
3
votes
1answer
52 views

Generating realistic terrain data - Part 2

I've made a "heightmap" terrain generator similar to my previous one, except this one has some improvements, and some new features. The way this one works is similar to my last one, but slightly ...
6
votes
2answers
59 views

First dice roller

The part I'm really wondering about is in the "if, elif, else" part. I set the variable to bring up the raw input thing so it would stay there long enough to read instead of just printing a response ...
7
votes
3answers
501 views

n-digit Verification Code Generator

This is a verification code generator, which generates n-digit numeric strings. (code can be 0000, so I chose String as a return ...
5
votes
3answers
161 views

Random letter test

My first test (randomUpperCaseLetter) checks if the returned random letter is an uppercase ASCII one. The second one (...
2
votes
2answers
124 views

Artificial Stock Market Algorithm

I'm attempting to make a stock trading game in Javascript and I've been trying to find an algorithm to generate fake stock prices. Currently, each Stock object has ...
2
votes
1answer
43 views

Random date gen class. Returns a tuple of a start date and end date

Just interested in any comments about the way the code is written. I am very new to python and programming. I did think about a func with a generator, but thought this approach was better. ...
2
votes
1answer
247 views

Console random password generator

This program is a random password generator. It asks the user how many chars they want their password to be and how many passwords it should generate. I used the ...
4
votes
1answer
78 views

Von Neumann extractor to remove bias from pseudorandom array

Von Neumann extraction is a technique to remove bias from a source of entropy. You extract an unbiased array of bits from a biased one by comparing pairs of consecutive bits in the array and returning ...
2
votes
1answer
99 views

Generating realistic terrain data

I have some fascination with terrain generators, so I whipped up this generator in Python. The way it works is pretty simple, but I figure that I should give an explanation for those who don't want to ...
6
votes
1answer
76 views

Moody game characters

I've been doing some self-imposed exercises to get accustomed to Python and below is my code. ...