Instructor:
Nelly Fazio
Back to class webpage
[ Introduction | Design Guidelines | Collaboration Policy | Hand-in Procedure]
The UnicastCount MIDlet that is bundled in
the EmulatorDemo shows how two SPOTs can be paired using
the radio antenna and their SPOTs addresses. Once the connection has
been established, the two switches are programmed to light up the LEDs
in a binary pattern and/or change their color.
In this lab, you will work with two SPOTs: SPOT1 and SPOT2. On each of these devices, you will program the right switch SW2 to cycle through the three possible selections (Rock, Paper, or Scissors) of the device itself, and the left switch SW1 to confirm the selection and reveal the other SPOT's move. More specifically, on device SPOT1, the three rightmost LEDs (L5, L6 and L7) shall display the SPOT1's selection, while the three leftmost LEDs (L0, L1 and L2) shall display the SPOT2's selection. The two central LEDs (L3 and L4) will be used to display the winner. Similarly, on device SPOT2, the three rightmost LEDs (L5, L6 and L7) shall display SPOT2's selection, while the three leftmost LEDs (L0, L1 and L2) shall display SPOT1's selection. Again, the two central LEDs (L3 and L4) will be used to display the winner.
On each device, we will use different colors to display the SPOT's own selection and the other SPOT's choice. More precisely, on SPOT1, we use green for SPOT1's selection and red for SPOT2's selection. Similarly, on SPOT2, we use green for SPOT2's selection and red for SPOT1's selection.
The two central LEDs shall be solid blue while the SPOTs make their selections, and turn to flushing green, red, or blue depending on whether SPOT1 won, lost, or tied the game. The initial LEDs configuration is as in Lab 1 and is depicted below:
Let's now discuss in more details the functionalities of the two switches. We will take the point of view of SPOT1, but the discussion is analogous on SPOT2.
SPOT1 uses switch SW2 to make its choice: one click for Rock, two clicks for Paper, and three clicks for Scissors. Further clicks shall cycle back through Rock, Paper, etc. When SPOT1 confirms its selection by pressing the SW1 switch, it sends its selection to SPOT2. At this point we need to distinguish two cases, depending on whether SPOT2 has already made its selection or not:
When the two SPOTs have both made their selections, the Rock-Paper-Scissors rules are applied to declare the winner. Here is a pictorial representation of the rules of the game:

The two middle switches (L3 and L4) of the two SPOTs will then blink for five times. On each device, we use the color green if this device won; we use the color red if the other device won, and we use color blue if there is no winner (SPOT1 and SPOT2 made the same selection). After blinking five times, the LEDs on the two SPOTs return to their initial configuration, ready for a new game.
You must write all the code you hand in for the programming
assignments, except for code that is part of
the EmulatorDemo. You are not allowed to look at anyone
else's solution. You may discuss the assignments with other students,
but you may not look at or copy each others' code.
To turn in your lab, e-mail your Rock-Paper-Scissors MIDLet
application as a .zip file (your.name-lab2.zip) at
Copyright © Nelly Fazio