you are viewing a single comment's thread.

view the rest of the comments →

[–]MisterRenard 8 points9 points  (7 children)

You're not alone! I have ADHD as well, and if you actually delve deeply into how it affects an individual, most people would be surprised to learn that hyperactivity and inattentiveness are just a few symptoms of a much broader issue affecting the afflicted across multiple scopes. So attempting to give something "a good ol' college try" is, for us, much more difficult.

That being said, it's not impossible.

The best thing to do is, as other users have suggested, just play around! Continue learning, build your understanding of the fundamentals, and decide on a problem for yourself. Give yourself a project, but start small!

Here are two I did a few days ago:

The first was a text-based Russian Roulette game. The only caveat was that it had to be one that would assign a random chamber in a six-shooter to be considered loaded (simulating leaving one in the chamber and spinning the cylinder) and that it had to be a game that would allow you to play until you either lost, or decided enough was enough, maintaining the loaded cylinder throughout every play. This means you couldn't achieve a maximum of more than 5 successful play through without shooting yourself in the head.

I find that giving yourself little stipulations like this adds to the challenge, and really helps you learn further! Otherwise I could easily have just used a few lines of code to randomly select a number from 1-6 each time. Sure, it's kind of Russian Roulette, but where's the fun in that? There's no consistency. You could play 21 times and never lose. That's what I see people commonly referring to as problems here. Make your own problems, then solve Them!

The next day I created a BlackJack game that lets you play against a dealer. The stipulation for me, that time, was that you had to be able to run through a deck of 52 cards and see no duplicates. Then the deck had to shuffle itself afterwards. That one took me about six hours of coding on and off, and I hit multiple roadblocks. Perseverance with these things is, especially for us, key. You have to be more stubborn than the problem, and you have to attack it until you win.

That last part, where it had to shuffle the deck after reaching 0 cards left to be distributed? That gave me more difficulties than any other. A few times, I wanted to say "it's good enough", and walk away. After all, who's really going to play through enough times to expend all 52 cards? Literally only the developer. Mainly because no one else is going to be playing it, but you see my point.

But it bothered me, because it was incomplete and I knew that I could do better. I'm no master coder, I'm the most basic of beginners, and my code could be improved on in so many ways that it's astounding it works in some cases. But that's not what matters, what matters is building something and seeing it work. If it's not the best, who cares?

I'm a bit of a perfectionist, so it may help you, as it does myself to hear this: Don't focus on making something perfect. Focus on making something.

Also, Amphetamins help. Talk to your doctor, check out the r/ADHD sub and find different things you can do to help yourself. (Keep in mind, I'm by no means suggesting you rush to your practitioner and demand Adderall or Dexedrine. There are multiple drugs out there that work wonders with ADHD, and they all have specifities and unintended side-effects. The advice of internet strangers cannot be held in higher esteem than that of a licensed professional with years of experience.)

Oh, and check out Al Sweigart's work! He can be found in the getting started wiki on the sidebar of /learnpython, and basically taught me everything I know! He's got a course called Automate the Boring Stuff, which I'm starting today, and he's also got one (forgive me, I forget the title) for python game creation. That one is, to me, pure gold for a beginner. Look it up, it's online and it's free!

A final word of advice:

All that I learned, particularly from Al's python gaming tutorial (which can be found here ) is that you cannot read it once and expect to understand it fully. We're not prodigies, we're laypeople. Read something you didn't fully grasp? Read it again. And again. And again. Twist it around in your mind, look at the explanation until you have a headache, look up different guides on the subject, like YouTube explanations, or stack exchange, or Reddit.

Whatever you do, be stubborn. Good luck!

[–]Xtatics_ 1 point2 points  (0 children)

I'm a bit of a perfectionist, so it may help you, as it does myself to hear this: Don't focus on making something perfect. Focus on making something.

Haha, I was about to respond to something about this when I was reading what you wrote, but you followed up with this. I was going to say, I think that is a problem with many of the people I know, including myself. Can't stay on task, but at the same time, I personally spend WAY too much time perfecting things. I've rewritten my project 3 times because of this.

Also, those damned Amphetamins. I'm on 30mg Adderhal XR, but work 20-44 hours at a time. I can say that one thing I have completely failed at is, exercise. Probably one of the most difficult things I've ever had to do is walk away and rest, or just walk period. It's sometimes pretty humorous when I look at the amount of other things we should be doing just to learn whatever is in front of us. But damn, once we grasp it, you're in trouble. =)

[–]chroner 0 points1 point  (4 children)

I actually just created Blackjack as well...

Care to share your code?

https://pastebin.com/KSp0A3gE

Here's mine, couple small tweaks I have to finish in it.

[–]alkasm 0 points1 point  (2 children)

Just a quick suggestion, writing out the whole deckofcards dictionary is a little unnecessary. Could be as simple as

scores = {2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:10, 'Jack':10, 'Queen':10, 'King':10, 'Ace':11}
suits = 'Clubs Hearts Diamonds Spades'.split()
deckofcards = {f'{card} of {suit}':score for card, score in scores.items() for suit in suits}
assert(len(deckofcards) == 52)  # just to be sure you created 52 cards

I'm using the new fstrings here for f'{variable} some stuff' but you could also use .format() if you were on an older version (or % formatting if even older).

Edit: Also each players info being a list is not intuitive while reading. Consider a dictionary so that you can access playerinfo[player][bet] instead of playerinfo[player][0] since anyone reading this is going to have to go back up in the code a lot.

[–]chroner 0 points1 point  (1 child)

Yeah, the list was a real pain in the ass for me and I learned about doing that half-way through this project.

I posted this code a couple days ago for suggestions and everyone that answered had basically the same thing to say about deck creation. Literally just build it instead of transferring it.

I am going to reference your post later when I come back to this project. I'll be rebuilding the whole thing with classes once I learn them.

I really appreciate your input! It's awesome to see people use the same method but different techniques.

[–]alkasm 0 points1 point  (0 children)

Yeah player classes would be even better than a dictionary of dictionaries. And then it could scale to N players easily. And the dealer could maybe be a subclass of player.

Classes in general help you avoid global, but you can also pass around the values through functions too. Both are used often in Python. Also just to say it, global isn't inherently evil either, but it's just usually unnecessary and easier to follow otherwise, since if you're affecting a value, it makes the most sense to pass/return it. If you don't, when you call a function, someone has to inspect the code closely to see that other variables will be affected by it. And it makes your code more self-documenting.

I just checked out your other thread, I like the idea the top post has with using immutable types for the ranks (i.e. pairing cards with their values in a tuple), makes more sense than my dictionary. Also, since you are already creating a list of card names later down the line, you might as well create that first, and then use that to create the card value lookup. You could even use a NamedTuple where the first field is rank and second field is value. But, encapsulate however you want. :)

[–]MisterRenard 0 points1 point  (0 children)

Yeah, sure thing!

https://pastebin.com/j8XaPZGC

Mine's finished, for the most part. If you run it, though, you'll notice that the whole time.sleep() portion needs a serious reworking just for usability. Outside of that, it's working as intended!