75
votes
Accepted
Monopoly simulator
You really need to remove some of your global variables.
As an example I'd change all your browns to use a list instead.
brown = [0, 0]
As you do a lot of logic ...
29
votes
Monopoly simulator
You have a lot of verbose repetition, you should learn to simplify things with loops and functions.
First, you're printing the board with each line getting a print statement, but you could just use a ...
27
votes
Simple text-based RPG in Java
OOP
This task really begs for object oriented programming.
As a first step,
I suggest moving the maxhp, playerhp, ...
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 ...
16
votes
Accepted
Printing all possible sums of two n-sided dice rolls
As @BenC mostly put a code dump, I'll explain ways that your code could have improved.
reverseIt
Programming this is just wrong in Python.
This is as there are ...
14
votes
Accepted
Find the total number of ways W, in which a sum S can be reached in N throws of a dice
1. Review
The sum \$s=0\$ can be reached in \$n=0\$ throws in exactly one way, but:
...
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
Printing all possible sums of two n-sided dice rolls
For your specific case of two rolls of n-sided dice:
...
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
Printing all possible sums of two n-sided dice rolls
I've got a suggestion to an alternative way of generating your list based on your own thoughts on how the sequence grows. But first a few general remarks related to the style of your code.
Naming of ...
11
votes
Simple text-based RPG in Java
Some of your switch cases are unnecessarily long, repetitive and include lots of code.
You could easily replace them with indexed arrays, making it easier to read, shorter, and easier to expand with ...
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
Printing all possible sums of two n-sided dice rolls
On top of @BenC answer which provide an efficient writting for a straitforward algorithm, I'll provide a version where you build the resulting list already sorted, saving you some computation.
The ...
8
votes
Accepted
Generate set of random numbers and remove lowest
This seems like a nice thing to do with your kids!
Python has these things called comprehensions.
For example a list comprehension for the first 5 multiples of 2 could be either:
...
8
votes
Accepted
Scoring solution for Farkle (dice game)?
"Pythonic" programming
Code is "pythonic" when it expresses its intention clearly, is easy to read or even looks like pseudo-code, and uses as little low-level garbage as possible. Let's take a look ...
8
votes
Accepted
Exurbb (automated turn based) Battle Simulator
Summary
A lot of work still needs to be done on this.
Fix all the suggestions below then resubmit for further review.
Dice Rolling.
...
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 ...
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