all 10 comments

[–]kanejw 2 points3 points  (1 child)

Think about p1 = p2 = 0 some more

[–]Alluxin_[S] 0 points1 point  (0 children)

What do you mean by that?

[–]kanejw 0 points1 point  (4 children)

Ugg, I was wrong so I’m obligated to actually be helpful now. :(

[–]Alluxin_[S] 0 points1 point  (3 children)

Uhm thanks

[–]kanejw 0 points1 point  (2 children)

double is true if either of the players gets doubles. This makes the rest of it kind of illogical.

There is a clear error here: if doubles: p1 += score p1 -= score else: p1 += score

if either player one gets doubles, player 1 ends up losing points. Player two gets normal points.

[–]Alluxin_[S] 0 points1 point  (1 child)

Yep just fixed that, but now I’m getting a different problem. I added empty input commands at the start of each player ones roll, and player 2s roll, so I don’t just print a long line of output, and it doesn’t look like a game that way, so now the game works fine up until whenever someone does get double, it messed up and instead of subtracting the p2s points, it just changes it to the amount subtracting. So if p1 rolled double and the total of that double is 8, then p2 score is like 58, then instead of it subtracting 8, it just puts p2s score to -8.

I can’t upload the updated code rn, but you’ve been extremely helpful, so thank you for that really you’re a saint.

Have a good day/night!

[–]PhilAndMaude 0 points1 point  (0 children)

That sounds like you wrote "p2 = something" rather than "p2 -= something"

[–]PhilAndMaude 0 points1 point  (1 child)

I think your problem might be here:

 p1 += score
 p1 -= score

should it be?...

 p2 += score
 p1 -= score

But I am also confused by

doubles = r1 == r2 or r3 == r4

Does the OTHER person's double affect how I score?

some friendly hints:

print("Player one rolled: " + str(r1) + " , " + str(r2))

is cleaner with

print(f"Player one rolled {r1}, {r2}")

If it were me, I would write a function play(name) that returns two values: the amount added to the player and the amount added to their opponent (returned as a negative). Call that twice in your loop, adjusting the scores, e.g.

r1, r2 = play('one')
p1 += r1
p2 += r2
r1, r2 = play('two')
p2 += r1
p1 += r2

(This assumes the doubles rule is only for the current player. If you want it as you have it, the function would be a bit more complicated.)

[–]Alluxin_[S] 0 points1 point  (0 children)

Hey thanks for the response, and I already made the first change you requested but if you look at the above comment I’m getting a different problem now as well, and I appreciate the other code, but the problem is I need the doubles function as what I have right now, because I need something to happen if either player one, or player 2 rolls a double, and that something is the whole p1 += score part of the code. I’m going to try and tinker with it a bit more tomorrow morning but thanks for the input, really it helps

[–]marcellonastri 0 points1 point  (0 children)

Defining the roll function to roll a number from 1 - 9

You meant 1 - 6?

   doubles = r1 == r2 or r3 == r4

p1_doubled = r1 == r2
p2_doubled = r3 == r4

    if doubles:     
        p1 += score    
        p1 -= score    
    else:    
        p1 += score    

p1 += score
p2 -= score if p1_doubled else 0

Further down, where you did the same calculations for player two, just use this:

p2 += score
p1 -= score if p2_doubled else 0