25
votes
Accepted
Two player dice roll game
This… … … is a mouthfull. The sheer amount of comments make the code very hard to read as it gets buried under tons upon tons of other information. Most of them being just there to state the obvious ...
17
votes
A dice game called "Greed"
Style
You're not being charged by the character; there's no need to abbreviate "count", or "ret" (which I would call "score" instead). Also, main has inconsistent brackets with the rest of the ...
17
votes
Two player dice roll game
You got an excellent grade for this assignment, but there is still room for improvement!
Readability
First and foremost, you'll learn that code readability is very important, as code is harder to read ...
14
votes
Dice simulator program
Here are a few suggestions on how to simplify and format your code.
Break directly from the loop
In your loop construct there really is no point in keeping track of ...
14
votes
2 player dice game with login system
FUNCTIONS!
Divide your code into functions to make it more readable. In a couple of places, your code is 12 levels of indentation deep! That's the equivalent of 48 characters!
Spacing
Operators ...
12
votes
DnD Die in Java with regex
Bug in the validation pattern
The INPUT_VALIDATION_PATTERN doesn't work correctly, as it matches the invalid input "D"....
11
votes
Accepted
Dice game where two players try to get to 49
The simple answer is "yes". But let's take a look at why that's true and how you could make this look better.
First some general notes:
Variable Names: In static typed languages it's common to use ...
10
votes
Simple Python Dice
Your limits are inconsistent: you can’t set the number of sides to the declared minimum: 3
...
10
votes
Accepted
An ASCII histogram of a die rolled n times
The roll function generates a random sequence of integers. The loop body shows me that you know how to seed a pseudo-RNG with a true source of randomness but you're ...
10
votes
Arbitrary Dice with Probability
Since you need to roll many times in the chance_overlap function, you might want to optimize making n rolls, using ...
10
votes
Accepted
Razzle Dazzle simulator
First, your use of camelCase isn't ideal in Python. For variable and function names, snake_case is preferred. I'll be using that with any re-written code that I show.
I think ...
9
votes
Accepted
Simple dice game - JavaScript MVC implementation
MVC thing is hard to be taken right. And yet it is the most popular (my guess) approach in the modern web development.
There are different ways to say what MVC means in particular application. I ...
9
votes
A dice game called "Greed"
Nice separation of functionality, well done!
There are some important details that the other review doesn’t address:
int greed(list_type die_rolls)
Here you are ...
9
votes
Accepted
2 player dice game with login system
This only addresses one aspect of your code, but I think it's an important point to communicate:
Login systems
If you ever actually need a login system, you should investigate cybersecurity and good ...
9
votes
DnD Die in Java with regex
We don't know how your Die fits into the game as a whole, but the way you're rolling your results seems counter-intuitive to me. I'd expect to be able to call ...
8
votes
Dice game where two players try to get to 49
thanks for sharing your code!
There are a few pretty big issues with your current code.
Variable Names
Your current variable names tell us absolutely nothing about what the variable is, or what it'...
8
votes
Simple Python Dice
You spent 55 lines and a stateful class on something that can be accomplished in 3 lines (1 line if you don't count the imports) using only standard library functions:
...
8
votes
Accepted
2-player dice game
Login
Make a function login and move all the code to do with logged_in1 into it.
Use ...
8
votes
Python 3.6 Dice Histogram
Various small comments:
you can write a[x+y] += 1
you always call random.seed with the same input so you'll always have the same ...
8
votes
Arbitrary Dice with Probability
The right functions
def roll(die):
number = random.randint(0,len(die)-1)
b = die[number]
return b
Can be:
...
8
votes
c++ dice game using random numbers
The 2 previous answers provide a lot of good points, here are a few more suggestions:
Generating Random Numbers
As of C++11 there are better random number generators to use that the C standard library ...
7
votes
Basic python dice simulator with log function
There's some things I really like about your code. For one, you used str.format, which is in many ways superior to '%'-...
7
votes
Simple Python Dice
A few remarks:
A two-sided dice is perfectly fine. It is called a coin.
Why limit the sides to sys.maxsize, when Python has arbitrary precision integers (not that ...
7
votes
2-player dice game
@Peilonrayz has a very good review, I just want to add a couple of things to the Login functionality
The login works, but it is not very secure (not that it matters much in this example) but to give ...
7
votes
NEA Computing Task 2 Dice Game
There's a lot in your code that can be refactored but let's start from the beginning with some Python styleguides (also called PEP8)
Imports
It's recommended to write all the imports at the top of ...
7
votes
Accepted
NEA Computing Task 2 Dice Game
Welcome to Code Review!
PEP-8
In python, it is common (and recommended) to follow the PEP-8 style guide for writing clean, maintainable and consistent code.
Functions and variables should be named in ...
7
votes
Accepted
Dice throwing simulation in Java
Welcome to CodeReview. Regarding your issue, a quick solution is:
...
7
votes
c++ dice game using random numbers
For a beginner, this is a nice attempt.
Avoid "using namespace std"
Though this is trivial for a ten lines of code project, it immediately starts leading to issues when code size increases. ...
7
votes
Accepted
Tricky dice game in Python
Variable names
Some names are not clear enough. What p means, a pair? You don't need a pair:
for p in product(dice1,dice2): =>...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
dice × 171python × 80
game × 47
beginner × 42
random × 40
python-3.x × 31
java × 30
c++ × 20
python-2.x × 14
simulation × 14
performance × 13
object-oriented × 11
c# × 10
javascript × 10
programming-challenge × 7
role-playing-game × 6
battle-simulation × 6
ruby × 5
algorithm × 4
parsing × 4
console × 4
homework × 4
c × 3
regex × 3
statistics × 3