I wanted to add a brief addendum to my last post: https://steemit.com/steemiteducation/@rantar/learning-loops-and-arrays-through-games
In that post, I talked about teaching programming through developing a Roguelikes or a board game. However, that might not resonate with all students, so I thought of another one. Probably every student has played a card game in their life, so they might be able to connect with card games better.
In this example, we'll start with a traditional deck of 52 cards. Students can create their own decks if they have a creative idea, but we'll keep to the most familiar card deck for our examples. One of my goals of these teaching methods is to keep it as relevant to the students as possible, thus increasing their potential interest and engagement. I want to make programming fun.
So the simple way to create a card is to pick randomly from a list of [A,2,3,4,5,6,7,8,9,10,J,Q,K] and from [Hearts,Diamonds,Spades,Clubs]. Hands of cards can be stored as individual arrays. Astute students should quickly realize that simple picking randomly will not simulate a real deck because you could theoretically deal two of the same card. To fix this, they could create a new array of size 52. To populate this array, they would iterate over the suit and number arrays to generate each card. Then when cards are dealt out of the deck, remove them from the array. Thus the same card cannot be dealt twice.
Once we can simulate decks and cards, then we can start simulating games. Simple games like War or Blackjack up to more complex games like Rummy or Poker. If there are advanced students who master these basics, they can then work on a simple AI that will play the game against them. A bit of warning though, some of these games can be complicated to simulate, so make sure that the student's ambition matches up with the amount of time allotted for the assignment.
If you have any other suggestions or ideas, please let me know in the comments.