Week 12: Exercises

1. Victory Line

Modify the Tic-Tac-Toe program from the lecture so that when one player wins, it draws a line through the winning squares.

2. Turn to Play

Modify the Tic-Tac-Toe program from the lecture so that it indicates whose turn it is to move.

3. AI Player

Modify the Tic-Tac-Toe program from the lecture so that a human player plays versus an AI player. The AI should use the following strategy: (1) if possible, make a move that wins immediately; (2) otherwise, if it is possible, make a move that blocks an immediate win by the other player; (3) otherwise, move randomly.

4. Keyboard Synth

Modify the synthesizer program from the lecture so that in addition to clicking keys with the mouse, the user can play notes by pressing certain keys on the keyboard.

5. Dragging Notes

Modify the synthesizer program from the lecture so that the user can play a series of notes by dragging the mouse over them while holding down the mouse button.

6. Sustain Pedal

Modify the synthesizer program from the lecture so that the Shift key acts as a sustain pedal. For as long as Shift is held down, any notes that the user plays should continue to play, even after the user releases the mouse button. When the user releases the Shift key, all playing notes should stop.