Simple Card Comparison Language
Let's continue with our game and formalize it a little more. Let's assume you can use only the below words to tell your friend. You have a stack of cards in front of you.
Commands:
- PICK: PICK the card at the top. The next card becomes the top card. You hold the picked card.
- TOP_CARD: This is the top card.
- PICKED_CARD: This is the card picked in your hand.
- IS LARGER: Tells if the item is larger
- TOSS card: Keep the specified card out
- IF condition: Used to check condition and do action
- ELSE condition: Used to specify action when if condition fails
Step-by-step instructions:
- PICK
- IF PICKED_CARD IS LARGER TOSS
- ELSE TOSS
AND PICK - IF PICKED_CARD LARGER TOSS
- ELSE TOSS
AND PICK - IF PICKED_CARD IS LARGER TOSS
- ELSE TOSS
AND PICK - IF PICKED_CARD IS LARGER TOSS
- ELSE TOSS
AND PICK
As you can see, we are repeating steps. Can we do something to reduce writing the repeating statements? We will learn about this later.
Try out the steps from before and see if you get the largest card.
Card Game
Commands:
Deck
Picked Card
Tossed Cards
Game Log:
Good. You have understood the basics of programming. Time to take a rest. Come back tomorrow and you can start interacting with your computer using Python.