CSC153, Class 26: Randomness and Simulation Overview: * The random procedure * Rolling dice * Lab Notes: * Exam 2 almost ready (should be available this p.m.) + Due Friday the 14th + Four exams total plus optional final * No, I haven't graded homework 2 * Questions on writeup 3? How should we turn in the stuff? One big Scheme file. Did anyone figure out how to make Quicksort do without the same? predicate? ---------------------------------------- Scheme provides an interesting procedure that differs from many other Scheme procedures: (random i) i is a postiive integer returns an integer between 0 and i-1, inclusive (random i) may return different values when it is called different times. > (random 5) 4 > (random 5) 0 Goal: It is "difficult" to predict what value will appear next. Implies: Values are evenly distributed. * How is random different from other Scheme procedures? Most Scheme procedures are intentionally consistent (and should be) random is intentionally inconsistent (and should be) read is also (Things based on read and random might therefore be inconsistent.) * Why would we want this procedure? + Games may require some element of randomness + Simulation of events may require some element of randomness * Most computers use an algorithm to generate random numbers: We call those pseudo-random * We can build devices that generate completely unpredictable numbers. Read the lab. Wait a few minutes before trying to copy files. ---------------------------------------- Why is it that Linda and Larry's code fails to work well in DrScheme but works fine on the Web? (define foo (let (...) (lambda (..)))) Konquerer is too smart for its own good.