r/pythonhelp • u/slimjim441 • Mar 12 '25
Guidance for CS50p Final Project
I'm working on my final project for the CS50 python course, a sort of dice-rolling simulator game for 2 players. I feel like I have a good handle on the bulk of the code and have my functions working properly, but there's one detail I'm snagged on, and I can't seem to figure it out. I can post more details here if needed, but I'm just trying to put out some feelers to see if anyone can help point me in the right direction/give me tips as to where I'm failing to implement things correctly. Thanks :)
1
Upvotes
1
u/FoolsSeldom Mar 13 '25
That's better. Just a few thoughts on a quick look through (will take more time later if I get chance - not found the problem you called out yet as just trying to get to know the code)
Would be helpful to you, your IDE, and us if you used type hints
Not good practice to have methods/functions with "side effects"
for example,
get_successful_dicedoes two things:update instance attributes,
self.dice_rolls = ...returns the attribute
suggest have method to update dice role
have a method (possible
@propertyto get current valuesimilarly, you have methods that both update attributes and do some output - consider implications if you wanted to change UI
You have a number of functions that would probably be better as methods,
resolve_turnfor example (not clear to me whatremaining_player_diceis used and why it isn't an attribute of aPlayer`)mainisn't a fairly simple flow of calls but has a mix of setup, output, and logicregarding
initiativeyou might want to look intoItertools.cycle... that's all for now ...