CSCI 102T

The Socio-Techno Web

Home | Schedule | Labs | CS@Williams

Lab 10: Memory!

In this lab (your final lab of the semester!), you will get one last chance to practice your new programming skills. Specifically, you will use Javascript to implement a simple Memory game.

Memory

You all probably have some prior experience with the game of Memory (or Concentration). As a refresher, the game involves some number of cards that are placed facedown (often in a grid pattern). Players take turns flipping over 2 cards at a time. The goal is to find matching cards. If a match is found, the cards either remain face up or are removed from the playing area. Here is a screenshot from an incomplete game:

memory

Your job is to implement this game. You do not need to worry about taking turns. You only want to find the matches in the least number of clicks. I have set up the framework for you, and handled most of the functionality. You simply have to fill in some of the logic.

You should start by save memory.html to your www directory. You'll also need memory-imgs.zip. Download it to your www directory, and unzip it. (Check the permissions on everything to make sure its accessible from the browser!) Go through the code and make sure you understand what's happening. I have added comments to help you.

Your main task is to fill in the checkMatch() function. Look for the lines that begin with TODO. You only have to type a few lines!

Tasks for lab

  1. Complete the Memory game described above.
  2. If you get everything working, go back and think about how you would add the ability to keep track of the total number of guesses.
  3. Be creative and have fun!