I usually try and limit functions/methods to like 20-25 lines absolute max. play_game is way too long, try and break it up into functions.So some things I could suggest from a quick glance over: Made changes based on advice in this thread: Hearts v1.1 Both will be interesting challenges for sure. I plan on continuing each step on the challenges page so eventually I'll create a UI version of this in Pygame (step 14-2), and then ultimately an online version (step 20-2) though I have absolutely no idea at this point how I'll accomplish that last one. Thank you, and I appreciate your time! :) I also tried my best to style it properly, if I screwed that up let me know too. Also just if anyone finds any bugs/has thoughts on it in general, that'd be great as well. If anyone has time to look through my code and let me know if there are things I did that I should not have done, or would be improved via another method, I would be happy to hear about it. I am not a hearts expert, the strategies I gave them are not perfect I'm sure. I also am sure a lot of my code is not ideal (particularly the sections with computer AI figuring out what cards to pass and what cards to play) trying to break down strategies to the point I could put them into code was pretty challenging for me. I have been learning Python for about 2 months at this point, and have worked my way through Invent Your Own Computer Games With Python, Automate the Boring Stuff, (both by Al Swiegart) and Python Crash Course, and I have never done a project anywhere near this size this is the first time I've created classes at all in my own code, so I'm not confident I did so correctly/optimally. The hearts.py file is the main game, the shinsai_games.py is a module I made for re-use with other games, mostly based off the suggestions provided on the PCC Challenges page, then the hearts_classes.py file is classes specific to the card game Hearts. I ran into some interesting challenges, in particular figuring out the computer player AI. I started on Wednesday, so it took me 3 days (about 7 hours a day) then some refactoring and testing this morning to complete this. I chose Hearts because I (foolishly) thought it would be fairly simple, plus I love the game. I'm on step 9.5 where you use the steps to that point to create your own card game. Good day! I've been working through the playing card challenges for Python Crash Course, 2nd Edition.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |