Hot answers tagged

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 ...
Peilonrayz's user avatar
  • 42.8k
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 ...
SuperBiasedMan's user avatar
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, ...
janos's user avatar
  • 111k
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 ...
301_Moved_Permanently's user avatar
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 ...
Errorsatz's user avatar
  • 1,354
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 ...
gazoh's user avatar
  • 3,004
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 ...
Peilonrayz's user avatar
  • 42.8k
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: ...
Gareth Rees's user avatar
  • 49.6k
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 ...
Stephen Rauch's user avatar
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 ...
Solomon Ucko's user avatar
  • 1,566
12 votes

Printing all possible sums of two n-sided dice rolls

For your specific case of two rolls of n-sided dice: ...
BenC's user avatar
  • 2,738
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"....
mindoverflow's user avatar
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 ...
holroy's user avatar
  • 11.5k
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 ...
user985366's user avatar
  • 1,695
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 ...
TheAtomicOption's user avatar
10 votes

Simple Python Dice

Your limits are inconsistent: you can’t set the number of sides to the declared minimum: 3 ...
AJNeufeld's user avatar
  • 33.3k
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 ...
Indiana Kernick's user avatar
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 ...
Graipher's user avatar
  • 40.9k
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 ...
Carcigenicate's user avatar
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 ...
sineemore's user avatar
  • 1,785
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 ...
Cris Luengo's user avatar
  • 5,178
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 ...
Graham's user avatar
  • 1,369
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 ...
forsvarir's user avatar
  • 11.6k
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 ...
301_Moved_Permanently's user avatar
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: ...
Peilonrayz's user avatar
  • 42.8k
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 ...
Adam Smith's user avatar
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. ...
Martin York's user avatar
  • 94.3k
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'...
chatton's user avatar
  • 1,496
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: ...
jpmc26's user avatar
  • 1,203
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 ...
Peilonrayz's user avatar
  • 42.8k

Only top scored, non community-wiki answers of a minimum length are eligible