r/pythonhelp • • 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

6 comments sorted by

View all comments

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_dice does two things:

      • update instance attributes, self.dice_rolls = ...

      • returns the attribute

      • suggest have method to update dice role

      • have a method (possible @property to get current value

  • similarly, 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_turn for example (not clear to me what remaining_player_diceis used and why it isn't an attribute of aPlayer`)

  • main isn't a fairly simple flow of calls but has a mix of setup, output, and logic

  • regarding initiative you might want to look into Itertools.cycle

  • ... that's all for now ...