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

learn more… | top users | synonyms

3
votes
1answer
35 views

Generate voxel terrain with Perlin Noise

For my chunk generator for my game, it currently uses a triple nested loop, which seems very inefficient. It also seems like I could cut down a lot of code in the function somehow. Does anyone have ...
6
votes
4answers
863 views

Random string generator

I decided to make a random string generator for fun, and it works for the most part. Since I'm an amateur at programming, I thought I would post the code to get some feedback on it, and hopefully ...
5
votes
3answers
115 views

Simulation for rolling dice in X-Wing

I've recently started playing the X-Wing Miniature game, and there is quite some math behind some of the dice rolls, as they are affected by many abilities and so on. Manually calculating these is ...
5
votes
1answer
90 views

CIS194: Risk!-style “battles”

After reading LYAH and using RWH as a reference, I've been doing the exercises from CIS194, which is often suggested to beginners on irc://freenode.net/#haskell and ...
6
votes
2answers
41 views

Creating a list of new areas for patches of conserved land within a watershed

I'm writing code to create a list of new areas for patches of conserved land within a watershed based on the current size distribution of conserved land patches that are in the watershed now. I'm ...
8
votes
2answers
70 views

Simple command-line password generator

I'm very new to Haskell, I've read most of learnyouahaskell.com and played around with some simple things, but this is probably the most 'complicated' bit of Haskell I've written so far. I have an ...
8
votes
2answers
81 views

Random jagged int array generator

I've been working on learning about irregular arrays and thought making a generator such as this one would be a good exercise in applying what I have learned. The following class generates an array ...
1
vote
2answers
67 views

Random uniqueID for each ID SQL

How can I improve this code? I wanted to know if there's a possibility to remove the for loop, and UPDATE a different ...
10
votes
4answers
826 views

Generate set of random numbers and remove lowest

I'm learning some Python with my kids, and we're making a program to generate D & D characters from user input. One portion of the code is to generate stats, which are a set of six numbers where ...
12
votes
4answers
923 views

Rubik's cube timer & scrambler

This uses a linked list to store the data. I used a linked list as it's the only type of data structure that I know currently. Using chrono, I can get microseconds ...
3
votes
1answer
182 views

Function to generate a UUID

I am trying to prevent CSRF for my login page (linked from here), and for this I am going to use a random token generator to create a UUID for the session. The function that I have so far is as such: ...
2
votes
2answers
189 views

C program to generate Seed programs from statically defined Befunge code

My program takes static input, and then number crunches for a few hours. I am currently using Macros, but is there a better, more "user friendly" way to do this without losing on performance. I have ...
5
votes
2answers
232 views

Mapping & Sorting Randomly Generated Numbers

Below is the assignment I was given and the coding is what I have came up with. I would appreciate criticism on how I did and on ways to have gone differently about it. You want to number your ...
6
votes
1answer
289 views

Simple random generator

Based on this question, I have made a simple program to print a sequence of random numbers. The program seems to run fine, but I would like to know if my implementation is correct and how I can ...
4
votes
0answers
29 views

Coin flips and Dice rolls in a stored procedure

I saw a post in chat a few days ago, of what I thought was an interesting (albeit fairly simple) statistical challenge: By @skiwi: If I shoot once with 50% chance of target A and 50% of target B, ...
3
votes
2answers
106 views

Random Message Generator using Arrays

...
14
votes
3answers
683 views

Simple password generator

Here is a simple password generator in Java: ...
5
votes
2answers
99 views

Simple TicTacToe game, played by two simple A.I. players

I made two player objects (p1 and p2): ...
7
votes
2answers
346 views

Three-number lottery simulator

Please let me know how I can make it better, especially with avoiding repetition without the need to replace the user guesses. ...
12
votes
3answers
869 views

Seed std::mt19937 from std::random_device

To fill you in: Many people seed their Mersenne Twister engines like this: std::mt19937 rng(std::random_device{}()); However, this only provides a single ...
5
votes
2answers
52 views

Summing random numbers in parallel

I am playing around with parallelization in Java and am trying to see how to squeeze out more performance on my multi-core box. My machine has 6 physical cores, 12 with hyperthreading. However, with ...
5
votes
2answers
213 views

Random Engine - follow up

I have ported the code from my previous question "Generate a random numbers class" to C++14 and made a few modifications. How can I improve it further? ...
7
votes
1answer
75 views

Random number generator initialisation

For a server-side Java application I want to have a random number generator. I'm using the ISAAC algorithm from Apache Commons Math 3 because it is both cryptographically strong and fast. I have ...
6
votes
3answers
236 views

Generate valid random rgb color strings

I'd want to see if is possible to optimize performance even further of the following generate color method. ...
4
votes
3answers
573 views

Generating a random hex color

Is there any better way of doing this? ...
5
votes
2answers
222 views

Basic random password generator

I'm trying to pick up some Haskell skills so thought I'd write a random password generator to get to grips with using IO. It was far trickier than I expected and I ...
5
votes
3answers
104 views

Python Turtle screen saver

Leon asked a question which got closed both here and at Stack Overflow, but I kind of liked the idea, so I implemented a working version of his code, which I now want reviewed. With regards to Leon's ...
4
votes
1answer
384 views

Java Dice Roller with GUI

Three days ago I wrote about a Java Dice Roller I wrote. I've now added a GUI to that program. Here it is: DiceRollerGUI.java: ...
5
votes
2answers
994 views

Java Dice Roller

I've written a basic dice program in Java which takes a number of faces then randomly selects a number within that boundary. Here is the code: ...
0
votes
1answer
52 views

Procedural generation of an infinite map made up of 1's and 0's

This is my function to procedural generate an infinite random map of 1's and 0's it only calculates what you can see at the time and when the view moves it calculates the next rows. Complexity is the ...
5
votes
1answer
50 views

Fill a container from several threads

I want to generate some random data and store it in a container. I split the container into disjoint intervals using iterators and pass them to a thread function (I hope its body isn't important ...
11
votes
1answer
317 views

Balanced Random Assignment in Python

It has been a very long time since I've used Python. What I'm looking for: I would like to create a 6-by-6 random matrix where each component is either 1 or 2, so that there are 18 ones and 18 twos. ...
5
votes
2answers
83 views

Fluent API for creating random integer arrays in Java

Now I have this fluent API for creating random integer arrays. I can say that I want an array of particular length, having a particular minimum/maximum values and using a particular (or default) ...
4
votes
0answers
95 views

Better rand() API

I use this document as a basis for my mini-library: Motivation The std::rand friends are discouraged in C++14, so we want: A direct replacement to ...
2
votes
2answers
334 views

Simple stream cipher encryption/decryption function

This is a Python implementation of a stream cipher encryption algorithm. This implementation originates from the one displayed on the TI-Basic wikidot cryptography page. I am well aware that this ...
12
votes
3answers
134 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 ...
6
votes
1answer
188 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
972 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
1k views

Random number generation seeding in C++

I wrote a small function to return a random in a given range: ...
5
votes
2answers
97 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
53 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
78 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
181 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
134 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
119 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
90 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
101 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: ...