Last active
December 11, 2016 20:50
-
-
Save ambethia/e9bd1760f78fe36dcd7e03a1c2a4edc1 to your computer and use it in GitHub Desktop.
Pseudocode to describe a game of memory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| faces = [π€, π’, πΌ, π, πΎ, πΉ, π’, πΎ, π±, π€, π², π, π±, πΉ, πΌ, π²] | |
| matched = [] | |
| picks = [] | |
| choose(positionOfCard) function: | |
| If the number of picks is 2: | |
| Do nothing (stop the player from choosing 3 cards). | |
| Add positionOfCard to picks. | |
| If the number of picks is now 2: | |
| check() | |
| check() function: | |
| If faces[picks[0]] is equal to faces[picks[1]]: | |
| Add positionOfCard to matched. | |
| If all matches found (i.e. matched is the same length as faces): | |
| Game over. | |
| Empty picks after a short delay. | |
| render() function: | |
| For each card in faces: | |
| When the card is clicked: choose(positionOfCard) | |
| If picks inclues positionOfCard: | |
| Show card face (faces[positionOfCard]). | |
| Else: | |
| Show card back. | |
| If matched includes card: | |
| Your Choice: Show Card face or do not show card (i.e. It has been removed from the board). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment