Image Map Image Map
Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Looking for 'Travesty' program

  1. #11

    Default

    There are some variations mentioned at Dissociated press wiki

    for example, Quick Basic looks like:
    Code:
    CLS
    DEFINT F-N      'FLAG.B, FLAG.E, FLAGV, I, K, L,
    		'LETTER(), MAX.IN, MAX.OUT MAX.PAT,
    		'N.OUT, N.PAT
    
    DEFSTR O-Z       'PASS, PATTERN, SOURCE, STRING,
    		'OUTCHAR
    DIM letter(124)
    ON ERROR GOTO 5000
    
    
    
    'Default values:
    LET MAX.IN = 30000'Maximum input-string length
    LET MAX.PAT = 9'Maximum scan-order length
    
    ' User input data:
    RANDOMIZE 'Get randomizing seed
    
    INPUT "Number of characters to be output"; MAX.OUT
    
    100 PRINT "Scan order ( 2 - "; MAX.PAT; ")"; 'Simulated repeat
     INPUT N.PAT
    IF N.PAT < 2 OR N.PAT > 9 THEN GOTO 100 'until
    
    LET N.PAT = N.PAT - 1'Convenience correction
    
    200 INPUT "Name of input file"; SOURCE  'Error RESUME point
    
    OPEN SOURCE FOR INPUT AS #1
    INPUT "Prose or verse"; PASS
    IF LEFT$(PASS, 1) = "V" OR LEFT$(PASS, 1) = "v" THEN LET FLAG.V = -1'set verse flag
    
    ' Scan input text, deleting unwanted symbols:
    ' (NOTE: If in verse mode, <SP>'s following line end will be deleted)
    PRINT
    WHILE NOT EOF(1)
    
    LET PASS = INPUT$(1, #1)'Read input file one
    IF PASS <> CHR$(13) THEN PRINT PASS;         'display input
    IF PASS = CHR$(13) THEN LET PASS = ""         ' to <NUL>
    IF PASS = CHR$(10) THEN LET PASS = " ": IF FLAG.V THEN LET PASS = "|"      ' to special line end
    
    IF PASS = CHR$(9) THEN LET PASS = " "        'change any <HT> to <SP>
    
    IF PASS <> "" AND PASS <> " " THEN LET FLAG.B = 0       ' reset blank flag
    
    IF NOT FLAG.B THEN LET S = S + PASS' add to string
    
    IF (FLAG.V AND PASS = "|") OR (PASS = " ") THEN LET FLAG.B = -1' <SP> characters
    
    IF LEN(S) >= MAX.IN THEN GOTO 300 ' break out of loop
    
    WEND 'End of input loop
    
    300 LET S = S + LEFT$(S, N.PAT)  'End around
    ' Report string space usage and force garbage collection:
    
    PRINT : PRINT
    
    PRINT "Input string contains"; LEN(S); "bytes"
    
    PRINT "There are"; FRE(" "); "bytes remaining in string space"
    
    CLOSE #1
    
    PRINT : PRINT
    
    ' Open output file:
    OPEN "TRAVESTY.DOC" FOR OUTPUT AS #2
    ' Initial pattern:
    
    LET PATTERN = LEFT$(S, N.PAT)
    
    PRINT PATTERN;
    
    PRINT #2, PATTERN;
    
    LET N.OUT = N.PAT
    
    400  'Start of major "repeat until" loop
    
    ' Clear letter array (this compiler doesn't have ERASE):
    
    FOR K = 0 TO 124
    LET letter(K) = 0
    NEXT K
    
    ' Match current pattern:
    
    LET I = INSTR(S, PATTERN)
    
    WHILE I > 0 AND I <= LEN(S) - N.PAT'Don't run off end
    
    LET PASS = MID$(S, I + N.PAT, 1)'Next character
    LET letter(0) = letter(0) + 1
    LET K = ASC(PASS)
    LET letter(K) = letter(K) + 1 'Update total count
    
    LET I = INSTR(I + 1, S, PATTERN)'For next match
    
    WEND
    
    ' Choose next output letter based on use frequency:
    '100
    LET L = INT(1 + letter(0) * RND) 'Random-choice index
    
    FOR K = 32 TO 124 'Scan the letter array
    
    LET L = L - letter(K)
    
    IF L <= 0 THEN LET OUT.CHAR = CHR$(K): GOTO 500'Break out of loop
    NEXT K
    
    500  'Housekeeping for output character:
    
    LET N.OUT = N.OUT + 1 'Increment count
    IF N.OUT MOD 50 = 0 THEN LET FLAG.E = -1 ' set "line-end" flag
    
    ' Establish next pattern:
    LET PATTERN = MID$(PATTERN, 2) + OUT.CHAR
    
    ' Display and store character found:
    IF NOT (FLAG.V AND OUT.CHAR = "|") THEN PRINT OUT.CHAR; : PRINT #2, OUT.CHAR;
    
    ' Check for line break:
    IF (FLAG.V AND OUT.CHAR = "|") OR (FLAG.E AND OUT.CHAR = " ") THEN PRINT : PRINT #2, : LET FLAG.E = 0: IF FLAG.V AND OUT.CHAR = " " THEN PRINT SPACE$(5); : PRINT #2, SPACE$(5);
    
    IF INKEY$ = CHR$(3) THEN END 'Emergency exit
    ' Check for end of output:
    
    IF N.OUT < MAX.OUT OR OUT.CHAR <> " " THEN GOTO 400'End of major loop
    END
    
    5000 'Error trap (on "File not found" or "Bad filename"):
    
    IF ERR = 53 OR ERR = 64 THEN PRINT CHR$(34); SOURCE; CHR$(34); " does not exist. "; : PRINT "Try again": RESUME 200
    ON ERROR GOTO 0
    ' End of source code

  2. #12

    Default

    Curious to know what the program actually does...

  3. #13

    Default

    Quote Originally Posted by JonB View Post
    Curious to know what the program actually does...
    It's surprisingly simple: it tracks (on a letter-by-letter or word-by-word basis, depending on the implementation) which symbols in a given body of text are statistically more likely to follow a given symbol or symbol sequence, then uses that information to compose a random output sequence following that distribution pattern. The result is something that bears about the same relation to the source material as Timecube does to coherent English.
    Computers: Amiga 1200, DEC VAXStation 4000/60, DEC MicroPDP-11/73
    Synthesizers: Roland JX-10/SH-09/MT-32/D-50, Yamaha DX7-II/V50/TX7/TG33/FB-01, Korg MS-20 Mini/ARP Odyssey/DW-8000/X5DR, Ensoniq SQ-80, E-mu Proteus/2, Moog Satellite, Oberheim SEM
    "'Legacy code' often differs from its suggested alternative by actually working and scaling." - Bjarne Stroustrup

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •