This tag is for questions pertaining to random numbers, whether pseudo random or truly random.
3
votes
1answer
38 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
54 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
130 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
58 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 ...
-6
votes
0answers
32 views
Picking a Server randomly out of a server list C Code [closed]
can someone help in writing a better code to pick a random server out of a list of servers from an Array, for some reason, when i run this it always picks the 1st or second server only, it is really ...
5
votes
3answers
89 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
47 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
77 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
96 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 ...
6
votes
3answers
99 views
7
votes
1answer
60 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
121 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
105 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
232 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
830 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
119 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
145 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
171 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
188 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
238 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
79 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
112 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
679 views
6
votes
2answers
95 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
51 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
180 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
63 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
59 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
660 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
51 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
175 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
72 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
50 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
457 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
155 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
119 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
40 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
214 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
77 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
92 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.
...
8
votes
2answers
337 views
D&D dice rolling app
This JavaScript object is part of a mobile application that rolls dice for our D&D games.
Here are some example of possible inputs from the user:
2d4
2d4 + 3d6
2d4 + 3d6 + 12
...
5
votes
1answer
53 views
Attempting a fluent API for creating random int arrays
I have attempted doing a fluent API for creating random int arrays, and the following is what I came up with:
fluent_arrays.h:
...
4
votes
1answer
69 views
Modified Coupon Collector's Problem in Java
What is Coupon Collector's Problem?
In probability theory, the coupon collector's problem describes the "collect all coupons and win" contests. It asks the following question: Suppose that there ...
3
votes
1answer
76 views
Pitting two Blackjack bots against each other
I'm taking part in this Daily Challenge on http://www.reddit.com/r/dailyprogrammer/comments/29zut0/772014_challenge_170_easy_blackjack_checker/
Basically, you have to develop a program that runs two ...
10
votes
3answers
431 views
Picking random lines out of text files
So I was doing something which creates an airplane with an actual airline code, number, airplane type and so on.
The airline code and airplane type are stored in a txt file so I can add more later to ...