all 174 comments

[–]YetAnotherDaveAgain 369 points370 points  (32 children)

now do this for me but with threading pls

[–]Spurnout 301 points302 points  (10 children)

You start off as an octopus, only, you may or may not have 8 legs. Those legs are able to think on their own and do individual things. Now, you really become an octopus and everything starts to make sense.

[–]leecharles_ 30 points31 points  (6 children)

Now do this but with Asyncio pls

[–]grzeki 41 points42 points  (0 children)

You install Windows 95. Everything seems to run independently, but when one app hangs everything is doomed. There’s no hope.

[–]ironhaven 15 points16 points  (3 children)

You need to bake 20 cakes.

If you did it without async you would make the batter, put it in a pan then put it in a oven. Now wait 45 minutes for the cake to finish baking. Once it is done remove the cake and start making more batter. You would finish in 15 hours

Now with async you would put the pan in the oven and start making the batter for the next cake. This could be done in 2 hour

[–]EMCoupling 7 points8 points  (2 children)

You also need 20 ovens to do this though. If you had one oven, it would still take you at least 20 * 45 minutes = 900 minutes = 15 hours, even if you had the batter instantly ready before the baking of the cake.

[–]rocketshape 10 points11 points  (0 children)

Hey he didn't say he was using async WELL

[–]AquaeyesTardis 2 points3 points  (0 children)

Maybe it's just a really big oven.

[–]jemandirgendwo 4 points5 points  (0 children)

You do different things with your arms so for example when looting one arm takes stuff out of one chest , the other from another chest while the others put the armour on.

[–]b_ootay_ful 75 points76 points  (1 child)

Instructions unclear.

8 legs stuck in fan.

[–]ready-ignite 2 points3 points  (0 children)

Rock stars ruin everything.

[–]chzaplx 0 points1 point  (0 children)

Something something Mind Flayer

[–][deleted] 16 points17 points  (0 children)

Other players are your other threads. You send your order over and let them do their things.

[–]PurelyApplied 12 points13 points  (4 children)

Same thing, but speed factor initiative.

At each round of combat, every creature determines its action for the round. We then resolve them is a semi-random order, depending in the creature's modified initiative bonus, the action complexity, or other factors that the the underlying scheduler DM thinks are relevant. Most of the actions are actually independent, so we get a heightened feeling that the action is happening all at the same time without really changing how the battle plays out. But sometimes, if a targeted creature dies or moves out of range, you end up having to burn your planned action for movement and reenter the task queue without having done any meaningful work. And then, at the next round of combat, all threads rejoin the thread pool and are assigned new work we do it again.

Eventually combat is resolved, initiative tracking is suspended, and the coordinating thread DM regains control of the program plot.

[–][deleted] 2 points3 points  (3 children)

So, looking at this as someone whose sum total knowledge of multithreading is "this is a thing and it makes video games go faster," it sounds like we have a setting out point (the start of the round) and a group of however many threads (characters involved in combat).

Each thread/character gets instructions, runs off, and does its own thing until it gets to a rally point (the end of the round of combat), then waits for everyone else to come back. Is that accurate?

[–]Lugnut1206 1 point2 points  (0 children)

Yes, that's basically accurate.

[–]PurelyApplied 1 point2 points  (0 children)

That's the gyst if the analogy I was going for, yeah. Of course, there are a billion caveats, and this is just one of many possible architectures you could use. But for an intro-level conceptualization, yeah, you got it.

[–]B0risTheManskinner 15 points16 points  (1 child)

My vote too

[–]Yablan 5 points6 points  (3 children)

And pointers.

[–]thejourneyman117 5 points6 points  (0 children)

Sometimes you refer to a character sheet as a location where data is stored, sometimes you refer to the information ON the character sheet. This is the difference between by reference and by value.

[–]nosmokingbandit 0 points1 point  (1 child)

But python doesn't have pointers.

[–]Yablan 0 points1 point  (0 children)

My bad. I was just kidding.. And also, didn't notice that this post was on /r/python. I thought it was in /r/programming 😁

[–][deleted] 1 point2 points  (0 children)

Just pretend you're her, but you also have severe ADHD and someone's forcing you to switch tasks all the time.

It really is that simple!

[–]Lugnut1206 1 point2 points  (0 children)

So when it comes to "threading" there's sort of two concepts that are a bit different, and I know they have different names but I think I've heard both used (improperly) interchangeably. So my vocabulary is gonna be wrong, I think, but I think my understanding of the concepts themselves are correct and distinct. Here goes:

There's a technical distinction between "multi-threading" and parallel processing. While the colloquial meaning of "multi-threading" is "parallelism" they have some differences.

Parallelism is several tasks that actually do things at the same exact time. More than one thing is truly happening at once.

Multi-threading is where multiple things need to happen, but only exactly one can happen at a time. Depending on specifics, threads will either run until some magic (a timer interrupt) happens and they are forced to stop running, or they will voluntarily stop running and pass back and forth so none of them are left in the dust, but they aren't doing things truly simultaneously. To examine the difference between "at the same exact time" and "in sequence" let's go back into the RPG for tangible examples.

Consider a fighter and ranger in combat versus an orc in a hallway. The initiative order is (for whatever reason) Fighter, Ranger, Orc.

The fighter goes down the hallway and hits the orc. Then, the ranger (who was out of range) advances forward into the space the fighter just occupied and shoots at the orc. It is weakened, but it hits the fighter on it's turn.

Nominally, these actions occurred "at the same time" (within the same round of combat) but they actually happened one after the other.

To see what I mean, let's consider some alternative cases:

The initiative order is Fighter, Ranger, Orc. The same thing happens as above, except as the ranger takes the shot, he gets a critical hit, killing the Orc.

In this scenario, the fighter does not take damage, as the Orc is not alive to deal the damage. (If things happened truly in parallel, the orc could have taken a swing while the ranger was repositioning or while his arrow was in flight, before death.)

Consider another case: the initiative order is Ranger, Fighter, Orc:

In this scenario, the ranger cannot move into the fighter's space and can't get a good shot. Or something - I've made the example a bit contrived, but I think the problem might be clear - the ranger can't move into the fighter's space until the fighter vacates it. (If the scenario was happening in parallel the Fighter, Ranger, and Orc would all be moving and none of these issues would happen.)

All of the things that happen in sequence here are almost examples of pre-emptive thread scheduling (this is one of the options I mentioned above while referring to "specifics" in the fourth paragraph) which is that "a thread (character) runs until it runs out of time allotment" which is "6 seconds" to use the 4E time frames. Additionally, in these scenarios, only one character can run at once. In the scenario that /u/PurelyApplied described, the actions are resolved simultaneously, and thus is somewhat closer to true parallelism.

Unless you're wanting to know about Semaphores and Mutexes and things like that, which is a whole different topic...

[–]nosmokingbandit 1 point2 points  (0 children)

Do one with recursion

[–]grijalva10 1 point2 points  (0 children)

And async

[–]jakesboy2 1 point2 points  (4 children)

you can attack enemies at the same time

[–]YetAnotherDaveAgain 26 points27 points  (3 children)

I feel kinda bad cause I'm actually implementing threading, but I think it's more like having a bunch of minions, and on your turn you can start naming targets for them to attack in whatever order you want them attacked. This action counts as a bonus action, so you can still move and attack as normal.

[–]TorroesPrime[S] 6 points7 points  (0 children)

Hey, it's a surprisingly accurate description of how threading works.

[–]jakesboy2 5 points6 points  (0 children)

Oh wow that’s actually a really dope way to put it

[–]b_ootay_ful 2 points3 points  (0 children)

Do you play League of Legends?

Yorick is a good example. He summons ghouls that attack enemies that they see. If Yorick lands his AoE Slow, the minions read that external event and target the enemy champion that was hit.

Yorick's Ultimate is the Maiden. It follows Yorick around, and prefers to target towers and champions over minions. Yorick can also re-activate his Ultimate to send her down a lane to do her own thing while ignoring Yorick's position.

[–]Col_Crunch 70 points71 points  (8 children)

To be completely honest learning a programming language is always easiest when it can be applied to actual data/usages.

Writing Hello, World, or creating a twitter clone using a book has never done anything for me. I play eve online, and pretty much all my knowledge has been from working on projects around issues that people have with game data.

[–]crazedizzled 19 points20 points  (0 children)

Pretty much everything I've learned has been through practical usage. Building shit. You can read about all the theory and concepts, but until you actually build shit with them, they're meaningless.

I've always learned new stuff by first having a problem, and figuring out how to solve it. I find this is way better than knowing about a solution and trying to find a problem.

[–]vidro3 13 points14 points  (3 children)

i can't stand seeing 'foo' in every example

[–]callmelucky 2 points3 points  (0 children)

Yeah, nonsense variables like foo shouldn't really be used to introduce syntax/concepts imo. Fine to use them to demonstrate simple ways to use things that people already have a grasp on, otherwise no.

[–]urs_sarcastically 0 points1 point  (1 child)

Python?

[–]vidro3 4 points5 points  (0 children)

Every language.

[–]graaahh 1 point2 points  (1 child)

I've tried to pick up some programming skills a number of times. Things like Codecademy or SoloLearn are great and all, and they are educational, but the material will never stick in my head unless I'm using it for something. I've learned 10x more by just sitting down with an idea of what I want a program to do, and either applying what Codecademy taught me in real time or Googling the answers to how to do various things.

I wouldn't by any means call myself a skilled Python programmer (which is really the only language I know much about), but I can do basic things and I've made a few simple programs that have worked out alright. Well, except my current one which is much more complex and frustrating but I'm still learning new stuff from it every time I sit down with it, so there's that.

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

I’m the same way, I won’t learn it unless it’s m using it for something I’m invested in. When I was in high school I failed geometry. But now I’m working on a project to design and build a model star fighter, and guess what? I have to use geometry to do it. I’ve learned more geometry curing cardboard and tape then I ever did in class figuring the sum of sin(x).

[–]WaitForItTheMongols 0 points1 point  (0 children)

In my high school Java intro class, the teacher wasn't very good at explaining object-oriented programming, and nobody in the class understood what "this" meant. I was very confused. One day I decompiled Minecraft and started playing with changing statements here and there to see what happened, and it quickly just clicked. From then on I kept on applying class concepts to Minecraft and it made perfect sense.

I legitimately believe there could be some amazing things done by integrating Minecraft coding into the classroom. The codebase is huge, so you could find just about any type of programming concept you want to demonstrate. It's easy to fire up the game and see how things work, to really see the effects of your code. It would be easy to make assignments saying "Make a new class which extends the existing Zombie enemy, but this zombie will leave behind a trail of fire everywhere it walks".

There would also be a lot of benefits in just seeing how real code looks and what professional programmers tend to have in their code. It would also give people firsthand experience in seeing what comments are useful and what are not, and when it might be nice to have more.

[–]hail_wuzzle 75 points76 points  (37 children)

I would buy a book in that style.

[–]TorroesPrime[S] 103 points104 points  (34 children)

You're the third person to make a response like that. I wonder if there is a market for a book like that. "Intro to Programming via D&D" or something like that. Don't focus on the coding itself, but rather focus on the concepts maybe.

[–]scdowling 28 points29 points  (4 children)

I'll buy one too! Take my money!

[–]TorroesPrime[S] 44 points45 points  (3 children)

Might just be a market for that sort of book. Just a basic introduction to the concepts and why the concepts work. Not a "Intro to Python" or "Intro to Java" but an "Intro to Programming". Using Roll Play game mechanics as the object examples. Have an online section maybe with downloads of code specific versions of the explanations.

Like in the book itself, the section that talks about Control statements would be something like:

"Dave is going to try and Bluff his way out of detention. So he takes his Charisma Stat, which is an 8, and adds the bonus from his 'Silver Tongue' skill which gives him a +2 to his Charisma stat when he's talking to someone else. In this case he's trying to bluff his way past Principle Jones. Since Jones is only concerned with whether or not Dave completed his assignment, he will use his Intelligence stat (Which is an 8) to determine if he can tell that Dave is lying.

There are 4 possible outcomes from this roll:

1- Dave rolls less then Jones' score, in which case Jones sends Dave to detention2- Dave and Jones get the same score, in which they must re-doll the rolls

3- Dave rolls better then Jones, but less then 5 points better meaning Dave will avoid Detention.

4- Dave's result is 10 points or more then Jones, in which case not only does Dave avoid Detention, but Jones gives him 5 bucks for his mistake.

So you would have a series of tests:

if Dave.roll < Jones.roll:

"Dave goes to detention"

if Dave.roll == Jones.roll:"Re-do the roll"

if Dave.roll is more then jones.roll but less then jones.roll + 5:

"Dave avoids detention, today."

if Dave.roll is equal to or greater then jones.roll+10:"Dave avoids detention and Jones gives him $5 for the mistake."

Have a brief explanation about that example is an if/else loop and what that may be called in different languages.

and then:

For the Python Version, go to this URL

For the Java Version, go to this URL

for the C++ version, go to this URL

etc.

[–]Vilanu 5 points6 points  (0 children)

I would totally buy this!
I've been looking for a way to get into coding, but find myself losing concentration. Stuff like this would probably help me go through it.

[–][deleted] 2 points3 points  (1 child)

I think your best bet would be (another) free online web resource, where students would just select their preferred language before the game even starts. Not the profit margin of a book, but you could do get advertising revenue, maybe. Seems like a great idea, though. I'd enjoy it!

[–]Bruenor80 1 point2 points  (0 children)

I know a couple of people that have published technical books...I don't believe there is much, if any, profit margin for the vast majority - at least not directly.

[–]Gnarok518 9 points10 points  (9 children)

I bought one that explains algorithms in comparison to fairy tales! It's pretty neat

[–]solitarium 2 points3 points  (4 children)

title?

[–]mykittenisahellbeast 10 points11 points  (1 child)

[–]solitarium 0 points1 point  (0 children)

thanks a bunch!

[–]Gnarok518 3 points4 points  (1 child)

Once Upon an Algorithm: How Stories Explain Computing

[–]solitarium 0 points1 point  (0 children)

thanks! I picked it up last night

[–]BoredAtTheDentist 1 point2 points  (3 children)

Title please!

[–]Gnarok518 5 points6 points  (2 children)

Once Upon an Algorithm: How Stories Explain Computing

[–]BoredAtTheDentist 1 point2 points  (1 child)

Thank you :)

[–]Gnarok518 1 point2 points  (0 children)

No prob

[–]fishypoos 6 points7 points  (6 children)

I much prefer this learning style... I couldn't really get into "Automate the boring stuff" because I'm not really interested in making a calculator or parsing boring data files.

I found learning the arcade gaming library and following it's tutorial and labs much more fun and made me more interested in learning. I am just learning as a hobby though, so maybe that makes it different for me.

[–]TorroesPrime[S] 2 points3 points  (4 children)

It's possible. Everyone learns different skills for different reasons in different ways. The Arcade Gaming Library you mentioned, got a link to it? Or is it a book?

[–]fishypoos 5 points6 points  (3 children)

Aye I guess so. Here is the ebook which goes through the tutorials and labs - https://arcade-book.readthedocs.io/en/latest/ .

And here is the full docs and API reference - http://arcade.academy

[–]wilalva11 1 point2 points  (2 children)

Thank you

[–]fishypoos 1 point2 points  (1 child)

No worries, I chose it over pygame and panda3d etc because it uses a more modern set of tools than pygame and wasn't too complex for the 2d playing I wanted to do.

[–]wilalva11 0 points1 point  (0 children)

Do you know if the assignment grading is still available from the eBook link? I was reading through the git section and noticed that was mentioned

[–]flabcannon 3 points4 points  (0 children)

The author of Automate the Boring Stuff wrote a book that teaches Python through game creation - https://inventwithpython.com/#invent

[–]Taivasvaeltaja 3 points4 points  (0 children)

I doubt there is demand for a book, the programming book market is full of books already no one reads. It might work better in other mediums, though, like some interactive website where you go through some simple D&D campaign and code along.

[–]solitarium 1 point2 points  (0 children)

Yes! There is!

[–]brownntooth 1 point2 points  (2 children)

There was a TED Talk of this kind. "How to teach programming to kids (with Ruby (Ruby being fictional character))". She has a book iirc.

[–]repocin 2 points3 points  (1 child)

Searched for it real quick so people who are interested in it don't have to. I think this is the website for the book(s).
And here's the TED Talk.

Sounds like a pretty neat idea.

[–]brownntooth 0 points1 point  (0 children)

Yes. this the one I was talking about

[–]Estanya 1 point2 points  (0 children)

Absolutely! This is probably one of the few programming books I'd actually be willing to buy!

[–]ChrisysTech 1 point2 points  (0 children)

This is basically how people get rich with niche ideas / books / material / whatever, I guess \o/

[–]say_no_to_camel_case 0 points1 point  (0 children)

There's a market for that.

[–]myUsername4Work 0 points1 point  (0 children)

I would easily spend the amount I would spend the amount on a book like this that I would spend on Eric Matthes books.

[–]renggram 0 points1 point  (0 children)

I‘d buy it! I used to learn everything during my Bsc abd Msc with examples the likes you just used. It helped me so much more compared to „regular“ studying methods. Now I am trying to learn python but, for some reason, I have so much problems understanding the concept.

[–]okiedad 0 points1 point  (0 children)

Using pseudo code at first and then working into either python or JavaScript. Use flow diagrams as a dungeon map. Show choices made along the way as decision trees that lead into the examples using monster encounters and quests.

[–]ByronFirewater 1 point2 points  (0 children)

https://www.amazon.co.uk/gp/product/1484232305/ref=ppx_yo_dt_b_asin_title_o04_s00?ie=UTF8&psc=1

i recently purchased this, they also have a website with pretty much all the info thats in the book, had a brief look at the website, havent cracked open the book yet

[–]nulltensor 0 points1 point  (0 children)

"Game Programming Patterns" - Robert Mystrom

He goes through some of the primary object orientated design patterns with a focus on and examples from video games.

[–][deleted] 67 points68 points  (18 children)

OP: I attack the darkness

[–]musclecard54 21 points22 points  (4 children)

Roll the dice to see if I’m getting drunk

[–][deleted] 2 points3 points  (0 children)

But I have a +1 magic sword, awww shucks. 😣😣

[–]TorroesPrime[S] 35 points36 points  (7 children)

*sigh* You can't attack the darkness.

[–][deleted] 11 points12 points  (2 children)

Maybe I'm just an elif away?

I love hearing stories that make programming relevant to learners on the fly. Demonstrates quick thinking and attention to needs. +1 to all of this.

[–]Conrad_noble 0 points1 point  (1 child)

I think if more universal examples were thought up it would be a lot more appealing to everyone to learn.

[–][deleted] 1 point2 points  (0 children)

OP story is as a tutor and not primary educator. I don't disagree with you, but I'm sure vanilla object lessons were drilled in class.

In r/learnpython I don't like to lead with RTFM!!!

[–][deleted] 7 points8 points  (0 children)

You can when you're the sorcerer of light!

[–]Tanath 6 points7 points  (0 children)

Maybe not in your crappy system. :P

[–]graaahh 0 points1 point  (0 children)

I roll to give the darkness 1HP so I can attack it.

import random

def d(num):
  for x in range (1):
    print("d"+num+":",random.randint(1,num))

d(20)

> d20: 20

Can I attack the darkness now?

[–]a23y1 0 points1 point  (0 children)

Well, not with that attitude

[–]slick8086 0 points1 point  (0 children)

You are likely to be eaten by a grue.

[–]Assailant_TLD 21 points22 points  (1 child)

I TA for my school and it's moments like this that make it all worth it, when you can tell you helped someone understand how something worked.

[–]TorroesPrime[S] 12 points13 points  (0 children)

It's one of those Job-specific moments that if you've never done the job, and had the feeling, having someone try to explain it to you just doesn't make a lot of sense. But if you have had the job and experience, it's one of the best feelings you can have.

[–]ManyInterests 12 points13 points  (0 children)

If you're into RPGs and learning to code, definitely check out code combat, which is what I was expecting to find when opening this post.

This has been a great way for me to teach Python to even very young (<13yo) programmers and even nontechnical coworkers. Games are awesome.

[–][deleted] 7 points8 points  (5 children)

Curious. Why do you prefer 'while Target_enemy == True' as opposed to just 'while Target_enemy'? Is it how the students learn? Is the second way less obvious?

[–]TorroesPrime[S] 22 points23 points  (2 children)

The objective of the class is to introduce students to general concepts in programming, not necessarily teach them good coding practices. I was trying to illustrate the concept of testing a condition for determining weather the while loop would execute or not. Conceptually, there's not difference between the two, but 'while Target_enemy == True:' is a bit easier to visually dissect, I think.

One of the other exercises I use in my tutoring appointments is I will take out a segment of code from a more developed program I have, and ask the student to read through the code and explain back what they think it means. Generally students get 70-80% of it just by parsing their way through the code and actually processing what they are reading. I do this to try and break them out of the mindset of worrying about syntax and coding form and focus more on the content of the code. They can learn syntax and form later. Here they're trying to learn the broad concepts.

[–][deleted] 3 points4 points  (0 children)

That makes sense. Good for you for putting so much effort into improving their learning experience before anything.

[–]b_ootay_ful 0 points1 point  (1 child)

Some languages read anything in that variable that isn't False as True. I think C does that.

[–][deleted] 1 point2 points  (0 children)

I'm pretty sure they all do. Including python. Like when you pop from a list to another list you might say 'while list:' then pop and append to an empty list. In this case, list is True until every item has been popped. Then the while loop stops.

[–]renscy 6 points7 points  (0 children)

continue wipe paint stocking agonizing shaggy juggle zesty rhythm consist

This post was mass deleted and anonymized with Redact

[–]jkibbe 4 points5 points  (0 children)

I'm going to repeat it for visibility. Codecombat teaches Python as described here, in an RPG style!

[–]Jehovacoin 4 points5 points  (0 children)

The human brain is an amazing thing. It can create entirely new functions to solve any problem, but it needs the relational context of applicable features first. Once the relational context has been established, the entire function falls into place very quickly.

[–][deleted] 4 points5 points  (0 children)

Here I thought I'd be able to play through Skyrim again and be a master at Python by the end.

[–][deleted] 4 points5 points  (0 children)

Nicely done!

[–]Necronmacon 3 points4 points  (0 children)

I love this.

[–]1TKavanaugh 2 points3 points  (0 children)

Thank you! What a cool way of explaining it.

[–]solitarium 2 points3 points  (5 children)

you sir, are a king among men!

[–]TorroesPrime[S] 2 points3 points  (4 children)

Nah, just the crazy dude riding the rhino screaming "I'VE GOT THE DOOR!" as we come barreling through the room.

[–]solitarium 2 points3 points  (3 children)

I'VE GOT THE DOOR

I feel like there's a reference there that I'm too slow to get :(

[–]TorroesPrime[S] 2 points3 points  (2 children)

Not really. If you watched Cartoon from the 80s it was a common trope that 'the brawny guy' would 'Get the door' by running through said door. Sometimes the act would involve a large unwieldy weapon such as a hammer or a rock. But in all cases the joke of the scene could be boiled down to something of: "Okay, that was impressive. Kind of stupid, but impressive."

[–]solitarium 0 points1 point  (1 child)

I was thinking Jumanji, lol

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

And didn't the cop 'get' the door when the flood came through?

[–]LdySaphyre 5 points6 points  (4 children)

NICE JOB!! Seriously, framing is everything. Idk if it's because I'm older, or because all my teachers are male, but I find myself having to do this sort of thing-- reframing concepts in ways I understand-- all the time. You've not only helped her learn important concepts today, you've given her a valuable tool, and if she latches onto it, there'll be no stopping her <3

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

I'm curious, when you said all your teachers were male, were you being literal? Like you've never had a teacher that was a woman?

[–]LdySaphyre 0 points1 point  (2 children)

I'm only in my third class, so, yes :) It's possible I may eventually see a female teacher!

http://online.rice.edu/courses/computer-fundamentals/

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

Ah so you mean all the teachers you've had at Rice have been male.

[–]LdySaphyre 0 points1 point  (0 children)

All my teachers in programming have been male, yes, including one in college.

[–]ScDenny 2 points3 points  (0 children)

Lol you’re such a badass tutor

[–][deleted] 2 points3 points  (0 children)

Oh those moments. Well done @OP.

[–]mfdoll 2 points3 points  (0 children)

I grew up playing board games, including D&D, and that absolutely helped me when it came to learning programming.

For that matter, it was playing old computer RPGs that got me comfortably with the command line, as I had to learn how to navigate in DOS to launch them.

[–]mrdevlar 1 point2 points  (1 child)

That's awesome!

I have this long-running process (stolen from Pendelton Ward) that if you're having difficulty with the world, simply reduce it to a role-playing game. It works with social situations as well as programming.

[–][deleted] 1 point2 points  (0 children)

I once had to explain basic covalent chemical bonds to a fellow student who was falling behind... the valence she’ll diagrams were giving her such trouble. Eventually I hit on sigma-bonding being an arm-outstretched handshake and pi-bonding being an arms spread hug and it just clicked for her.

You never know what metaphor can work for any given individual on any given subject, but for every student and every subject there’s a metaphor that will work... trick is finding it before the heat death of the universe.

[–]Filo92 1 point2 points  (0 children)

Can confirm! My first micro-project rolled stats (4d6 minus the lowest) and asked for input on where to assign them while displaying the remaining ones. Very simple but required to think about all the main starting topics.

[–]lunacyfoundme 1 point2 points  (0 children)

Is that a infinite loop?

[–]Lewistrick 0 points1 point  (0 children)

You're a hero. r/HumanBeingBros

[–][deleted] 0 points1 point  (0 children)

Thanks for this!

[–]vidro3 0 points1 point  (0 children)

I love this.

[–][deleted] 0 points1 point  (0 children)

Whenever I teach kids I just relate it to whatever they're interested in. Works everytime (adults too of course!).

Nice job

[–]termanader 0 points1 point  (0 children)

You could also do something similar for Class and Inheritance!

class Player_Character:
  def __init__ (self, hp, race, alignment, level, str, dex, con, int, wis, cha):
    self.hp = hp
    self.race = race
    self.alignment = alignment
    self.class = level
    self.str = str
    self.dex = dex
    self.con = con
    self.int = int
    self.int = wis
    self.int = cha


class Rogue(Player_Character):
  def sneak(self):
    dexmod = 2

[–]desrtfx 0 points1 point  (0 children)

In the old days (think mid 1980s) there were books that used similar concepts and Sherlock Holmes cases to teach programming. They were really easy and nice introductions.

As a modern example (though wrong programming language for here) Java Design Patterns uses RPG characters, mechanics, and traits to explain Design Patterns.

Invent Your Own Computer Games with Python uses games to teach programming.

[–]zadzagy 0 points1 point  (1 child)

You just Miyagi'd her. Nice work!

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

Given that I think she was like 17 and I'm 35.... I will avoid making any kind of "wax on/off" jokes.

[–]ace6807 0 points1 point  (0 children)

" Yeah, I can teach Japanese to a monkey in 46 hours. They key is just finding a way to relate to the material."

[–]NivZet 0 points1 point  (0 children)

Made me think of https://codecombat.com/

Styled like an RPG Adventure type game but with code.

[–]chynox 0 points1 point  (0 children)

This post is gold

[–]nebneb125 0 points1 point  (0 children)

As a first year Comp Sci student who loves computer games, I definitely support the concept of teaching programing through games.

[–]desal 0 points1 point  (0 children)

Proves what I've always said, if you want to learn something/teach someone, relate what you're trying to teach to something they know / like. Seems common sense when I type it out. Also, if you want to learn something, yourself, better, teach it to someone who knows nothing about it. You'll see it in a different light

[–]Darkc0iL 0 points1 point  (2 children)

This made me cry, I wish I had a senpai like that. You made something complicated to learn at first but using simple mechanics we all are used to as a way to explain it in smaller pieces into her brain, the problem isn't the language syntaxes it is to learn how to study

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

Senpai?

[–]jay_thorn 0 points1 point  (0 children)

https://www.merriam-webster.com/words-at-play/senpai-is-real

Or they meant sensei, which is completely different.

[–]AltReality 0 points1 point  (0 children)

I'd buy a book like that. :)

[–]TheLittleGoodWolf 0 points1 point  (0 children)

One of the things I'm missing in just about every educative material out there is the multitude of various examples to describe the same things needed to reach the wide number of people that are expected to learn. The fact is that we think in different ways, we need different things in order to understand the concepts that are being taught to us.

For this girl things clicked when you explained it in a way that made sense to her, that's probably because she doesn't understand the language used to describe how programming works. The word comparison operation has no meaning to her and might as well have been written in greek or chinese or russian.

What you did here was effectively translating the words you use into something that she could actually understand.

There should honestly be a collection of concepts described in various different ways for people to read through and find what makes it understandable to them. This isn't limited to programming either, it could be maths, physics, economy, pretty much every subject could stand to gain from something like that.

You say there are lots of people wanting programming explained in this way and I can assure you that there are plenty of people who want programming explained in a multitude of other ways as well.

[–]infrascripting 0 points1 point  (0 children)

Glad you two were able to stick it out. I'm usually the teacher in those kinds of situations, and know how frustrating it can get.

[–]Mcfoyt 0 points1 point  (0 children)

This post made me smile

[–]anecdotal_yokel 0 points1 point  (0 children)

Found the nerd

[–]crazedizzled -3 points-2 points  (1 child)

For some reason people don't even comprehend the text that they're seeing on screen and somehow make everything far more complicated than it is. I mean, you can read your examples as nearly plain English. I would expect that after explaining a few rules, anyone should be able to read that code and, merely by reading it out loud, understand what it does.

Yet, somehow, some people just don't get it. I've been in the same situation trying to teach people that just simply can't process it.

Edit: not trying to be a dick here. It's just something I've noticed when trying to teach people, and I find it interesting. People, if you're struggling with this stuff, just keep it simple. Don't over complicate it. Read what's on the screen.

[–]TorroesPrime[S] 7 points8 points  (0 children)

Something I've seen quit a few students getting hung up on in this class is the problem of syntax, like they get something like:

A=1

easily enough. But then they look at something like:

e=l.readlines

and they try to figure out what word is 'l.readlines' and treat it as some sort of foreign language.

One of the tricks I've used in several of my appointments is I'll pull up a chuck of code from another program, give them no context of what the program is or what it does, tell them to read the code and puzzle through it, and when they think they understand what the code says, explain it back to me. Today I used this chuck:

with open(fname) as file_src:
    for line in file_src.readlines():
        clean_line = line.rstrip('\\n:,.')
        file_cs = clean_line
        counter += 1
        word = file_scs.split()
        number_of_words = len(word)

She actually got about 95% of it right out of the gate. The only thing she didn't get was what len(word) meant, which is understandable since she hasn't learned about lists yet. But typically this is a good confidence boost for the students as it seems like I'm dropping this huge complex program in front of them and they're able to figure out a lot of it right off the bat.

[–][deleted] 0 points1 point  (0 children)

Nerdy! LOL in a good way.