|
difficulty |
summary |
specification |
medium |
Add simple "physics" to motion.htm |
motion.htm supports very rudimentary motion, just
some digits moving around randomly. You should add inertia (a body in motion
stays in motion) to each digit, and make them bounce of the edges of the
windows. For example, randomly start "1" moving to the left, and have it
bounce of the left edge and return heading to the right. If you randomly
started "7" moving down and right, when it strikes an edge have it bounce
off the edge correctly (i.e., up and to the the right).
|
medium |
Towers of Hanoi |
Three pegs, A, B, and C are protruding vertically from a
board. There are N disks, number 1, 2, ..., N, stacked on peg
A. N is on the bottom, N-1 is on top of N, ..., 1 is on top of
2. Disk N is the largest, and each subsequent disk is smaller, with
1 the smallest. Write a program that generates the list of
individual moves required to move the entire stack of disks from peg A to
C, with these restrictions: a) you can only move one disk at a time from
one peg to another, b) a disk may only be placed on top of a smaller disk,
c) any disk can be placed on an empty peg. Your web page should
provide an input field to allow the user to specifiy N.
BONUS: provide a visual image of the disks and animate them moving between
the pegs. |
medium |
Remove duplicates from a sorted array of numbers |
Implement function unique(a), where a is an Array of zero
or more numbers, which are sorted. unique() is to remove duplicate
values from the Array and return the list of unique numbers. |
medium |
Guess an integer between 1 and 100 |
Provide buttons for "new game",
"guess", and "I give
up". Loading the page and pressing the "new game"
button both cause the program to pick a secret random number between 1 and
100 and ask the human player to try and guess it. The player enters
his guess on the web page, and presses "guess". If the
guess is correct, display "correct". If the guess is
higher than the secret number, display "too high".
Otherwise display "too low". Permit the player to guess
until he enters the secret number or presses the "I give up"
button.
BONUS: What is the worst-case number of guesses
that an experienced player needs to identify the secret number? |
hard |
Largest and smallest positive numbers |
JavaScript cannot store every number. Write a
program to automatically determine the largest positive number that
JavaScript can represent (before overflowing). Same for the smallest
positive number (before underflowing). Same for the number of
decimal digits of numeric precision (i.e., how many decimal digits can
JavaScript remember for any specific number, ignoring trailing zeros?) |
hard |
Tic-Tac-Toe |
Display an empty Tic-Tac-Toe board. Permit the player to move first, and
moves are accomplished by clicking on a square. The computer responds.
First one to complete three in a row horizontally, vertically, or diagonally
wins. |
|
|
|
For subsequent weeks!
difficulty |
summary |
specification |
hard+ |
solitaire card game |
Clone the Windows Solitaire program. Need to find
card face images and design your own card back. Need to figure out
scoring algorithm [look up in Hoyle.] Need to figure out a
non-Drag&Drop user interface for moving cards [hover over card
produces options to click on: pick, ???] |
hard+ |
Connect Four |
Rack of 6 rows, 7 columns. Computer and player take turns dropping
checkers. First to get 4 in a row vertically, horizontally, or
diagonally wins. Need to learn about
MINIMAX algorithm with ALPHA-BETA pruning
algorithm.
Play a Java implementation. |
hard |
Konane (Hawaiian Checkers) |
See
the specification
at Bryn Mawr. |
hard |
Star Trek BASIC port |
Port BASIC (or C) version of
classic Star Trek game
to JavaScript + DHTML |
??? |
Port a 101 BASIC Games program |
Pick one, figure out the UI, and go! |
Lecture Topics
a) Name scope
b) functions, recursion
c) Objects, arrays, "memory allocation", properties, methods, etc.
d) Object lifetime
e) DHTML animation primitives, user interface
==> Illustrate utility of above JavaScript object features by showing
alternate C/C++ code?
Some of my early programs, NU assignments, Lisa's programs
Biorhythm (three waves, based on birthday and current date) //** How to draw
vectors? Could do a bar graph to simulate three curves?
Racing game //** Do simply physics for accelerate, brake, and turn?
Infinite precision math routines //** I never coded these
Class scheduling //** pre-requisites, max number of students per class,
Evaluate an algebraic expression //** postfix to infix, stacks; start of code
generation [NU: EECS B03 ??]
Reversi //** Peter Frey wrote killer version of this
| | |
Last updated Tuesday, January 7th, 2003. © 1997-2024 slivka.com. All rights reserved.
|