one slide summary l system
play

One-Slide Summary L-System Recursive transition networks and - PDF document

One-Slide Summary L-System Recursive transition networks and Backus-Naur Form context-free grammars are equivalent formalisms for Fractals specifying formal languages. find-closest is quite powerful. Problem sets? & L-system


  1. One-Slide Summary L-System • Recursive transition networks and Backus-Naur Form context-free grammars are equivalent formalisms for Fractals specifying formal languages. • find-closest is quite powerful. Problem sets? & • L-system fractals are based on a rewriting system that Procedure is very similar to BNF grammars. Practice • We can practice our CS knowledge up to this point to solve problems by writing recursive procedures . (It won't take too long.) #1 #2 Outline Recursive Transition Networks • Briefly: Recursive Transition Networks ORNATE NOUN – vs. Backus-Naur Form Grammars • Playing Poker – Revenge of find-closest NOUN end ARTICLE ADJECTIVE begin • PS3 L-System Fractals ORNATE NOUN ::= OPTARTICLE ADJECTIVES NOUN • Solving Problems ADJECTIVES ::= ADJECTIVE ADJECTIVES – Problem Representation ADJECTIVES ::= ε – Important Functions OPTARTICLE ::= ARTICLE Recall: the two notations OPTARTICLE ::= ε are equivalent. #3 #4 Problem Sets PS2: Question 1 • Not just meant to review stuff you should • 1.i. (list-length (list-append (list 1 2 3) 4)) already know – Get you to explore new ideas > (list-append (list 1 2 3) 4) – Motivate what is coming up in the class (1 2 3 . 4) ;; this is not a list! • The main point of the PSs is learning , not evaluation > (list-length (list-append (list 1 2 3) 4)) – Don’t give up if you can’t find the answer in the book (you won’t solve many problems this way) length: expects argument of type <proper list>; – Do discuss with other students given (1 2 3 . 4) – (This is why they are difficult.) #5 #6

  2. PS2: Question 4 PS2: Question 8 • 8. How long is analyze-flop-situation ? Why is (let ((current-deck (remove-cards (append hole1 (define (higher-card? card1 card2) hole2 community) full-deck))) (> ( card-rank card1) ( card-rank card2) (map (lambda (turn-card) better than (map (lambda (outs) (cons turn-card outs)) (define (higher-card? card1 card2) (analyze-turn-situation hole1 hole2 (cons turn- (> ( car card1) ( car card2)) card community)))) current-deck) )) ? – Current-deck is the initial deck of 52 cards with 7 already dealt, leaving 45. – We call analyze-turn 45 times (slow!), each time we putting the answer in a list (fast!), so 45x. #7 #8 PS2: Question 9, 10 Can we do better? • Predict how long it will take • Identify ways to make it faster This is what we used in PS2 for our Poker-Bot: (define (find-best-hand hole-cards community-cards) (car ( sort (possible-hands hole-cards Most of next week and much of many later community-cards)) classes will be focused on how computer higher-hand?)) scientists predict how long programs will take, and on how to make them faster . But didn't we learn something in the last class for finding the “closest” or “best” element in a list? #9 #10 Recall From Last Time find-bestest (define ( find-closest goal lst closeness) (define ( find-bestiest lst bestiness) (if (= 1 (length lst)) (if (= 1 (length lst)) (car lst) (car lst) (pick-closest closeness goal (car lst) (pick-bestier bestiness (find-closest goal (cdr lst) closeness)))) (car lst) (find-bestiest (cdr lst) bestiness)))) (define ( pick-closest closeness goal num1 num2) (define ( pick-bestier bestiness num1 num2) (if (< (closeness goal num1) (if ( bestiness num1 num2) (closeness goal num2)) num1 num1 We could num2)) use these num2)) to find the This used to be best hand! (< (dist num1 goal) (dist num2 goal)) #11 #12

  3. Liberal Arts Trivia: find-best-hand Latin American Studies (define ( find-bestiest lst bestiness) • This important leader of Spanish America's (if (= 1 (length lst)) (car lst) successful struggle for independence is (pick-bestier bestiness (car lst) credited with decisively contributing to the (find-bestiest (cdr lst) bestiness)))) independence of the present-day countries of (define ( pick-bestier bestiness num1 num2) Venezuela, Colombia, Ecuador, Peru, Panama, (if (bestiness num1 num2) num1 num2)) and Bolivia. He defeated the Spanish Monarchy (define (find-best-hand lst) and was in turn defeated by tuberculosis. (find-bestest lst higher-hand?)) Next week: how much better is this? At home: convince yourself that they get the same answer. #13 #14 Liberal Arts Trivia: Media Studies PS3: • This 1988 book by Herman and Chomsky presented the seminal Lindenmayer System Fractals “propaganda model”, arguing that as news media outlets are run by corporations, they are under competitive pressure. Consider the dependency of mass media news outlets upon major sources of news, particularly the government. If a particular outlet is in disfavor with a government, it can be subtly 'shut out', and other outlets given preferential treatment. Since this results in a loss in news leadership, it can also result in a loss of viewership. That can itself result in a loss of advertising revenue, which is the primary income for most of the mass media (newspapers, magazines, television). To minimize the possibilities of lost revenue, therefore, outlets will tend to report news in a tone more favorable to government and business, and giving unfavorable news about government and business less emphasis. #15 #16 CommandSequence ::= ( CommandList ) L-Systems CommandList ::= Command CommandList L-System CommandList ::= Command ::= F Rewriting CommandSequence ::= ( CommandList ) Command ::= R Angle Command ::= O CommandSequence CommandList ::= Command CommandList Start: (F) CommandList ::= Rewrite Rule: Command ::= F F → (F O(R30 F) F O(R-60 F) F) Command ::= R Angle Work like BNF replacement rules, Command ::= O CommandSequence except replace all instances at once! Why is this a better model for biological systems? #17 #18

  4. Level 1 Level 0 Start: (F) F → (F O(R30 F) F O(R-60 F) F) Level 2 Level 3 (F) (F O(R30 F) F O(R-60 F) F) #20 Previous CS 1120 Students: The Great Lambda Tree of Ultimate Knowledge and Infinite Power Tie Dye by Bill Ingram (Level 5 with color) Rose Bush by Jacintha Henry and Rachel Kay #21 #22 Previous CS 1120 Students: PS3 - Fractals • In addition to completing the problem set, each time will submit their prettiest fractal. • The class will then vote for favorites, and the authors of the favorites will receive extra credit. • No Photoshop, etc. All PS3. – You just change the rules: •F → (F O(R30 F) F O(R-60 F) F) ;; one fractal Tree Outside My Window •F → (O(R60 F) F F O(R45 F)) ;; a new one! A Heart #23 #24

  5. Procedure Practice Hints • Remember our strategy! • For the rest of this class, we will be practicing • Be optimistic! writing recursive procedures together. – Assume that you can write “count-fives” • Write a procedure count-fives that takes as – So the recursive case will work out input a list of numbers. It returns the number • Identify the smallest input you can solve of fives contained in its input list. – The base case – (count-fives (list 1 2 3 4 5)) -> 1 • How would you combine answers – (count-fives (list 5 -5 5 7)) -> 2 – From the current call (usually the car of the list) – (count-fives (list )) -> 0 – And the result of the recursive call – (count-fives (list 8 6 7 5 3 0 9)) -> 1 • Be creative! There are usually many solutions. #25 #26 Two versions of count-fives Liberal Arts Trivia: Medicine (define ( count-fives lst) • This vector-borne infectious disease is caused (if (null? lst) by protozoan parasites. It is widespread in 0 tropical regions, such as sub-Saharan African. (if (eq? (car lst) 5) Each year there are about 515 million cases of (+ 1 (count-fives (cdr lst))) it, killing between one and three million (count-fives (cdr lst))))) people. No formal vaccine is available. Classic symptoms include sudden coldness followed by Both work fine! (define ( count-fives lst) How are they rigor and then fever and sweating. different? (if (null? lst) 0 (+ (if (eq? (car lst) 5) 1 0) (count-fives (cdr lst))))) #27 #28 Liberal Arts Trivia: Cognitive Liberal Arts Trivia: Accounting Psychology • This American psychologist coined the term • In this bookkeeping system, each transaction is Cognitive Psychology in his late 1960's book of recorded in at least two accounts. Each the same name. He was critical of linear transaction results in one account being programming models of psychology, felt that debited and another account being credited, psychology should address everyday concerns, with the total debits equal to the total credits. and respected the direct perception theories Luca Pacioli, a monk and collaborator of of J.J. And Eleanor Gibson. He headed the APA Leonardo da Vinci, is called the “father of task force that reviewed The Bell Curve . accounting” because he published a usable, detailed description of this system. #29 #30

Recommend


More recommend