Aktionen

Beatnik

Aus exmediawiki

Beatnik ist eine einfache stapelorientierte von Cliff L. Biffle (ca. 2001).

Ein Beatnik-Programm besteht aus einer beliebigen Folge englischer (oder auch deutscher) Wörter; jedem Wort wird eine numerische Punktzahl zugewiesen, die es in einem Scrabble-Spiel dafür erhalten würde. Der Wert der Punktzahl bestimmt, welche Funktion ausgeführt wird. Zu den Funktionen gehören das Schieben der Punktzahl des nächsten Wortes auf den Stapel, das Testen des Stapels und das Vorwärts- oder Rückwärtsspringen im Programm, sowie noch weitere Stapeloperationen.

Der Interpreter liest die Wörter im Gedicht und ignoriert dabei Interpunktion, Leerzeichen und Zeilenumbrüche; einige Funktionen sind ein Wort, andere Funktionen haben ein Argument (es handelt sich um Zwei-Wort-Funktionen). Zwei-Wort-Funktionen werden nachstehend in der Form "5,n" beschrieben. Das bedeutet, dass sowohl das Wort, dessen Wert 5 ist, als auch das nächste Wort (dessen Wert 'n' ist) gelesen wird.



Scrabble Character Values

--- ABCDEFGHIJKLMNOPQRSTUVWXYZ ---
 1: A   E   I  L NO  RSTU
 2:    D  G
 3:  BC         M  P
 4:      F H             VW Y
 5:           K
 6:
 7:
 8:          J             X
 9:
10:                 Q        Z
--- ABCDEFGHIJKLMNOPQRSTUVWXYZ ---

A=1 B=3 C=3 D=2 E=1 F=4 G=2 H=4 I=1 J=8 K=5 L=1 M=3 N=1 O=1 P=3 Q=10 R=1 S=1 T=1 U=1 V=4 W=4 X=8 Y=4 Z=10


Stack

see: https://en.wikipedia.org/wiki/Stack-oriented_programming


ein stack ist ein Stapel/Speicher der Nummern zur späteren Nutzung für uns speichert...
zahlen können dem stack hinzugefügt werden < Push
zahlen können vom Stack weggenommen werden < Pop


....Beatnik interpretiert Zahlen von 0-255.

Commands

Score Pseudo-Code Description German Translation
<5 NOOP Does nothing. The Beatnik Interpreter may mock you for your poor scoring, at its discretion. Tut nichts. Der Beatnik-Dolmetscher kann Sie nach eigenem Ermessen wegen Ihrer schlechten Punktzahl verspotten.
5,n push(n) Finds the score of the next word and push it onto the stack. the actual word with 5 is then skipped. Schiebe den Wert des nächsten Wortes in den Stack.
6 pop() Pops the top number off the stack and discards it. Lösche (Pop) die oberste Zahl vom Stapel.
7 push(pop()+pop()) Adds the top two values on the stack together Addiert die obersten zwei Werte miteinander. Nimmt (Pop) die 2 dann vom Stapel und legt (Push) das Ergebnis dann oben auf den Stapel
8 push(input()) Input a character from the user and push its value on the stack. Waits for a keypress. Wartet auf UserEingabe eines Zeichens und legt (Push) diese dann oben auf den Stapel
9 print(pop()) Pop a number off the stack and output the corresponding ASCII character to the screen. Nimmt den obersten Wert vom Stapel und gibt dann den dazugehörigen ASCII-Wert aus.
10 push(pop()-pop()) Pop two numbers from the stack, subtract the first one popped from the second one popped, and push the result. Nehme die obersten 2 zahlen vom stack und subtrahiere die erste von der zweiten. Das Ergebnis wird zurück in den Stack gelegt.
11 a = pop(); b = pop(); push(a); push(b) Swap the top two values on the stack. Die obersten 2 Zahlen miteinander vertauschen
12 a = pop(); push(a); push(a) Duplicate the top value and pushes the value on top of the stack. Den obersten Wert kopieren und mit oben auf den Stapel legen.
13,n if(top()==0) jump(+n) Pop a number from the stack, and figure out the score of the next word. If the number from the stack is zero, skip ahead by n words, where n is the score of the next word. (The skipping is actually n+1 words, because the word scored to give us n is also skipped.) Nimmt (Pop) den obersten Wert vom Stapel und ermittel die Punktzahl des nächsten Wortes. Wenn die oberste Zahl eine 0 ist, dann nimm sie (Pop) vom Stabel. Gehe zum nächsten Wert in deinem Satz und zähle diesen Wert (beginnend am Wert selbst) dann nach vorne.
14,n if(top()!=0) jump(+n) Same as above, except skip if the value on the stack isn't zero. Nimmt (Pop) den obersten Wert vom Stapel und ermittel die Punktzahl des nächsten Wortes. Wenn die oberste Zahl keine 0 ist, dann nimm sie (Pop) vom Stabel. Gehe zum nächsten Wert in deinem Satz und zähle diesen Wert (beginnend am Wert selbst) dann nach vorne.
15,n if(top()==0) jump(-n) Skip back n words, if the value on the stack is zero. Wenn die oberste Zahl eine 0 ist, dann nehme sie (Pop) vom Stabel. Gehe zum nächsten Wert in deinem Satz und zähle diesen Wert (beginnend am Wert selbst) dann zurück.
16 if(top()!=0) jump(-n) Skip back if it's not zero. Wenn die oberste Zahl keine 0 ist, dann nehme sie (Pop) vom Stabel. Gehe zum nächsten Wert in deinem Satz und zähle diesen Wert (beginnend am Wert selbst) dann zurück.
17 exit() Stop the program. Das Programm enden
18-23 NOOP Does nothing. However, the score is high enough that the Beatnik Interpreter will not mock you, unless it's had a really bad day. Tut nix
>23 Generates "Beatnik applause" for the programmer. Beatnik-Applaus für den Programmierer
  • Jeder andere Scrabble-Wert, der als Befehl interpretiert wird, ist ein NOOP.
  • Beachte, dass die Befehle, die den Werten 5, 13, 14, 15 und 16 entsprechen, jeweils ein zusätzliches Wort einlesen, den Wortwert als Parameter verwenden und ihn dann überspringen.
  • Ein Wert von weniger als 5 kann dazu führen, dass der Interpreter Dich wegen Deiner schlechten Scrabble-Fähigkeiten verspottet.
  • Bei einem Wert über 23 erhältst Du einen "Beatnik-Applaus".


Legende
Pseudo-code Meaning
NOOP Do nothing
pop() remove the value off the top of the stack, and return it
push(x) place x on the stack
print(x) print the character x
input() read a character from the user. Blocks until character is read.
; separates multiple statements. They are run in order.
if(expression) statement if and only if the expression is true, execute the statement
jump(x) move the reading location forward or backwards by x words.

Code-Examples

simple example

Foo Bar Baz

  • Foo hat den Scrabble-Wert 6
  • Bar hat den Scrabble-Wert 5
  • Baz hat den Scrabble-Wert 14

Das Programm macht folgendes...:

Lege (Push) 14 auf den Stapel

simple example #2

Ho humbuzz, Dionysus. | orgasm if I feel altruistic & alone...
Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch?! Ha!
Monarchies spoil; language intermediates everyone!

Dieses Programm iteriert von 32 bis 127 und druckt das Zeichen an diesem Index aus. Auf diese Weise zeigt es die "druckbare" Teilmenge der ASCII-Tabelle an, von 0x20 (Leerzeichen) bis 0x7E (~).

another very simple & stupid example

...with only 2 characters to print out only one stupid sign

der Text/Code liest sich wie folgt:
ah aha ahaha ahaa hhh hhh ahaa ahaa hah

dies macht folgende Werte + Funktionen:

  • [5:PUSH/ah] < Schiebt den Wert 6 in den Stack
  • [6:DISCARD/aha] < 6 macht dann nix, weil es als operant von 5 ja schon aufgerufen wurde
  • [5:PUSH/ah] < Schiebt den Wert 6 in den Stack
  • [6:DISCARD/aha] < 6 macht dann nix, weil es als operant von 5 ja schon aufgerufen wurde

das heißt im Stapel liegen nun 6 und 6

  • [7:ADD/ahaa] < addiert die zwei zahlen im Stack = 12
  • [12:DUP/hhh] < dupliziert die oberste Zahl, also 12 und legt sie oben drauf
  • [12:DUP/hhh] < dupliziert die oberste Zahl, also 12 und legt sie oben drauf
  • [7:ADD/ahaa] < addiert die zwei obersten zahlen im Stack, also 12 + 12 = 24

im Stack liegen nun also an oberster Stelle die 24 und darunter ein 12

  • [7:ADD/ahaa] < addiert die zwei obersten zahlen im Stack noch einmal, also 24 + 12 = 36
  • [9:OUTPUT/hah] < gibt den ASCII-Wert der Zahl 36 in der Konsole aus: $

der [[ASCII-Tabelle|ASCII]-Code für das $-Zeichen in Dezimal is der Wert 36...

"Hello World!"

Soars, larkspurs, rains.
Indistinctness.
Mario snarl (nurses, natures, rules...) sensuously retries goal.
Agribusinesses' costs par lain ropes (mopes) autos' cores.
Tuner ambitiousness.
Flit.
Dour entombment.
Legals' saner kinking lapse.
Nests glint.
Dread, tied futures, dourer usual tumor grunts alter atonal
  garb tries shouldered coins.
Taste a vast lustiness.
Stile stuns gad subgroup gram lanes.
Draftee insurer road: cuckold blunt, strut sunnier.
Rely enure pantheism: arty gain groups (genies, pan) titters, tattles, nears.
Bluffer tapes?  Idle diatom stooge!
Feted antes anklets ague?  Remit goiter gout!
Doubtless teared toed alohas will dull gangs' aerials' tails' sluices;
Gusset ends!  Gawkier halo!

Enter abstruse rested loser beer guy louts.
Curtain roams lasso weir lupus stunt.
Truant bears animate talon.  Entire torte originally timer.
Redo stilt gobs.

Utter centaurs;
Urgent stars;
Usurers (dilute);
Noses;
Bones;
Brig sonar graders;
Utensil silts;
Lazies.
Fret arson veterinary rows.

Atlas grunted: "Pates, slues, sulfuric manor liaising tines,
  trailers, rep... unfair!  Instant snots!"

Sled rested until eatery fail.
Ergs fortitude
  Indent spotter
Euros enter egg.
Curious tenures.
Torus cutlasses.
Sarong torso earns cruel lags it reeled.

Engineer: "Erase handbag -- unite ratification!"

oaring oaten donkeys unsold, surer rapid saltest tags
BUTTERED TIBIA LUGS REWIRING TOILETS
anion festers raring edit epilogues.
DIRGE ROTOR.
linnet oaring.
GORE BOOTIES.
Ironed goon lists tallest sublets --
Riots,
Raucous onset.

Ignobly, runners' diet anguishes sunrise loner.
Erode mob, slier switcher!
Loaners stilt drudge pearl atoll, risking hats' ends.

Rebind sitters.

Toga epistles -- crud lard.  (Pager purse dons souls.)

glob title a curio hired rites shed suds lade grease strut arctic revs toad
unless idlers rind stilt region land GERMICIDES SULTANA GUTS gill siting leans
nice spurs
tests gloves
roused asp

Holes!  Moles!  (Sores!)
Hygienists!  Scars!  (Asses!)
Smells spell rares.

Cubs instant sing in parse goodies.
Rosin.  Unhelpful sisal acres.  Slope told.
MALENESS PASTA LAB.  "Infirmary vine," rang illiterates (beans).
Rosin sours, insults truss abalones, nailed rules, helical atlases.
Dear remodeling stings mar rents.
Sunless shiner orb (silly idol.)
Clarity disses senna.
Vagabonds sauted; sloes performed gelds.
Alter post radial lip sectioning gums.
Saint Towellings.
Larger aeons telephone stolid char, pal!
Boats Dean forsook, rosters, tunas, terrariums -- united, traced.
Nude pagoda careens.

I LOVE YOU

He arrived.

He arrived at my door extremely late one day.

If you only did uninteresting, idle things in your life, always acting as if nothing he does will change your opinion ... can go well.

But one awful dilemma I face, is that growing emotion ruins my serious, careful way of thinking. If a love flame is forced and futile, why bother kindling another one?

Yet, you think, it might not be a bad idea. Relationships always work out, and this can be an escape from a tense, complex life. Unmarried at home, lost in a loud, irregular reality ... maybe sometime, just maybe, it's time I found the one.

If he's a guy who is faithful, kind, and will be mine joyously to the end, I will prove to him I shall cherish and treasure him just as much. But how do I say it? I can't place the words...

"You absolutely need to know", I say, nervously, "that I...I...I..."

arbeiten mit dem Beatnik-Interpreter auf unseren Rechnern im Lab

Beispielworkflow

1. Scrabble-Werte + Funktionen abrufen:

./beatnik.py --tokenize --eval 'Soars, larkspurs, rains. Indistinctness. Mario snarl nurses, natures, rules... sensuously retries goal. Agribusinesses costs par lain ropes mopes'

[5:PUSH/Soars]
[15:SKIP_BACK_ZERO/larkspurs]
[5:PUSH/rains]
[17:STOP/Indistinctness]
[7:ADD/Mario]
[5:PUSH/snarl]
[6:DISCARD/nurses]
[7:ADD/natures]
[5:PUSH/rules]
[13:SKIP_AHEAD_ZERO/sensuously]
[7:ADD/retries]
[5:PUSH/goal]
[17:STOP/Agribusinesses]
[7:ADD/costs]
[5:PUSH/par]
[4:NOP/lain]
[7:ADD/ropes]
[9:OUTPUT/mopes]

2. den Satz/Code in eine Beatnik-Datei schreiben, z.b. so: echo "Soars, larkspurs, rains. Indistinctness. Mario snarl nurses, natures, rules... sensuously retries goal. Agribusinesses costs par lain ropes mopes" > one-letter.beatnik

3. das Beatnik-Programm ausführen ./beatnik.py (one-letter.beatnik|--eval 'Beatnik program source')

H

notes/links

Interpreter

online:

Lokal:

scrabble-werte finden