Randomness
From Maze
(Difference between revisions)
(/ I have edited the first half of the randomness_in_the_arts, combined it with a few paragraphs about random music and pasted them here.* II. Randomness and Aesthetics, Pre-Computing */) | (→V. The C64 and RND) | ||
| Line 77: | Line 77: | ||
===V. The C64 and RND=== | ===V. The C64 and RND=== | ||
| − | In this section we finally discuss the RND function in the context of the C64. How the number is actually generated, the reliability of the randomness, and alternative methods of finding randomness within the C64. | + | With so many variables in the real world like late buses, misdialed numbers, and slippery fingers dropping grilled cheese sandwiches into french fry oil (the origin of the Monte Cristo sandwich!), one of random's opposites, order, becomes a valued commodity. Clocks, calendars, safety standards, and style guides suffuse our culture to protect us. |
| − | We also synthesize some of the previous sections, and discuss the aesthetic qualities of the 10 PRINT pattern in terms of randomness. | + | Yet, in a computer, it is quite the opposite. Computer chips differ greatly from the outer world in their orderliness. Unlike our beaches or the bumpy landmasses with weather on which we build our houses, the world inside chips is meticulously fabricated, symmetrical, isolated and predictable. In fact, its basis is one massive crystal grown from purified silicon. It is so perfect that it is difficult to create unanticipated behavior. |
| + | |||
| + | The internal orderliness is at least true for the chip (MOS6510) running the Commodore 64’s BASIC interpreter, as well as the chip running the original BASIC interpreter at Dartmouth. As randomness transitioned from the sublime concept it once possessed to the practical application of security, sections of chips were designed to encourage random amounts heat energy to influence their silicon junctions to hasten the creation of unpredictable data. This is part of the essence of encryption - the production of obscurata. Patterns in these data are way behind the abilities of humans to predict in our heads, and are even difficult for many computers to suss out. | ||
* Prg in User guide demo of biasing randomness | * Prg in User guide demo of biasing randomness | ||
| − | * Use to explin to reader how randomness orks, what it's good for | + | intrestingly enough, they thought this would be a good idea to teach. |
| + | |||
| + | * Use to explain to reader how randomness works, what it's good for | ||
| + | |||
| + | In my own memories from 1984 and beyond, RND was most often used to improve the quality of games. For example, in my endless clones of Breakout!, RND chose where the ball would drop into the game, how much it would wiggle through the air, and helped make the sound of the bricks exploding. It made the game a little bit different each time and more challenging | ||
| + | |||
| + | |||
| + | In this section we finally discuss the RND function in the context of the C64. | ||
| + | |||
| + | * How the number is actually generated, | ||
| + | |||
| + | Rnd(0) Uses the timer as the random number generator | ||
| + | |||
| + | rnd(1) is a deterministic sequence of random numbers | ||
| + | it is a linear congruential generator with some extra byte-swapping taking place. | ||
| + | |||
| + | |||
| + | The original BASIC manual shows that Dartmouth Basic (the first BASIC), had a similar specification for the RND(x) function. It generated a single stream of pseudorandom numbers. Interestingly, it recommends throwing away the first "115" or so numbers. (reference: BASIC_Oct64.pdf, page 45 of PDF, page -39- of original document) | ||
| + | |||
| + | |||
| + | * reliability of the randomness, | ||
| + | The linear congruential generator (LCG) was proposed by Lehmer in 1949. | ||
| + | |||
| + | * Point Out that psuedo randomness is not bad or inferior | ||
| + | |||
| + | |||
| + | * alternative methods of finding randomness within the C64. | ||
| + | |||
| + | Assembly routine (Ian) | ||
| + | |||
| + | <pre> | ||
| + | Rand8 | ||
| + | lda random ; get seed (must be non-zero) | ||
| + | asl ; shift byte | ||
| + | bcc Rand8.no_eor ; branch if carry flag not set after left shift | ||
| + | eor #$CF ; otherwise EOR with literal $CF | ||
| + | Rand8.no_eor | ||
| + | sta random ; save number as next seed | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | |||
| + | It was possible on the C64 to get random values from the Sound Interface Device (SID) chip. Reading from register 27 (decimal) returns the current value of oscillator 3. If it's set to noise, you get a random number generator. | ||
| + | |||
| + | <pre> | ||
| + | 5 rem init sid for noise | ||
| + | 6 poke 54272+wave, noise | ||
| + | 10 print chr$(209.5+peek(54272+osc3read));goto 10 | ||
| + | </pre> | ||
| + | |||
| + | |||
| + | |||
| + | |||
* Use multiple seeds, then SID register random | * Use multiple seeds, then SID register random | ||
| + | |||
| + | |||
| + | * How it could be used to teach someone randomness/probability | ||
| + | |||
| + | |||
* Is this similar to how it sounds? Visual equivalence | * Is this similar to how it sounds? Visual equivalence | ||
| − | |||
* Develop three or four one-liners | * Develop three or four one-liners | ||
| − | |||
* User/programmer side | * User/programmer side | ||
| − | |||
* Two note example | * Two note example | ||
| − | * Point Out that psuedo randomness is not bad or inferior | ||
| − | * How it could be used to teach someone randomness/probability | + | We also synthesize some of the previous sections, and discuss the aesthetic qualities of the 10 PRINT pattern in terms of randomness. |
===A Working Bibliography=== | ===A Working Bibliography=== | ||
