Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Random Programs

Name: Anonymous 2009-12-08 0:05

You know the saying about monkeys and typewriters? What if one used a random number generator to create a valid binary executable? Sure, most of them would crash, but maybe you'd get something interesting eventually?

Name: Anonymous 2009-12-08 0:14

Yeah, I never believed that saying. I doubt there's enough time available in the universe to type Shakespeare at random. I'm sure some asshole at MIT has already done a paper on how he calculated out how long it would take, factoring in reasonable limitations for a given monkey's wpm, mechanical timings on the typewriter, and likelihood that a given generated word would end up as English.

Name: Anonymous 2009-12-08 0:21

>>2
You don't need to be from MIT.

I had an occasion to work out that 64KB encodes more than the number of nanoseconds since the big bang.

Name: Anonymous 2009-12-08 0:30

If you really had an infinite number of monkeys and typewriters (as the saying goes), you'd get all your results instantly.

Name: Anonymous 2009-12-08 0:38

>>4
Not instantly, just as fast as a monkey could physically type the work in question.

Name: Anonymous 2009-12-08 0:42

>>5
PS: that's assuming you don't have magical monkeys and typewriters. Though if you manage to find an infinite amount of either and get them together you'd need some sort of godhax in the first place.

inb4 GODHAX MY ANUS

Name: Anonymous 2009-12-08 0:45

>>4
The fun part: it still isn't guaranteed to be exhaustive.

Name: Anonymous 2009-12-08 1:19

Imagine how much poo an infinite number of monkeys would create.

Name: Anonymous 2009-12-08 2:30

You wouldn't get aything, because there are far too many failed programs compared to the successful ones. In this case, 99.9999% == 100%.

Name: Anonymous 2009-12-08 2:52

>>3
You don't need nearly that much space to store the number of nanoseconds since the Big Bang. Ten bytes would do just fine.

Name: Anonymous 2009-12-08 3:02

>>10
10 bytes isn't quite enough (2^80 = 1208925819614629174706176, 2 orders of magnitude short, assuming ~15 billion years) but you're right, 64kb is overkill.

Maybe it was Planck seconds? It's been a while and I don't really remember clearly. Planck seconds really would drive the point home that a lot of time is needed to exhaust even a tiny search space.

Name: Anonymous 2009-12-08 3:19

You won't get anything, it's NP-Complete

Name: Anonymous 2009-12-08 3:48

REGRETTETH error caused by null deref'd

Name: Anonymous 2009-12-08 4:00

>>1
About all you can hope for to show up in any reasonable amount of time is one that just exits without doing nothing, as that is a single byte.

Name: Anonymous 2009-12-08 7:17

>>1
Instead of generating random gibberish, you could try to define a set of valid instructions, and have it generate valid, but possibly meaningless code, combine that with some genetic programming, and you might even get something useful, if the fitness function is decent.

Name: Anonymous 2009-12-08 7:35

My /bin/ed is 40260 bytes long. There are only few than 2.53·1036358 possible binaries that long. It's a matter of t*** Stack overflow

Name: Anonymous 2009-12-08 8:09

>>14
without doing nothing
ain't not gonna do nobody no harm no-how!

Name: Anonymous 2009-12-08 9:21

I know what you mean. It's like that time when I piped /dev/urandom to perl, and the resultant program happened to remove my home directory.

Name: Anonymous 2009-12-08 9:52

For ym PhD dissertation I used random bbcode programs generated by an random number generator.

Name: Anonymous 2009-12-08 11:54

>>1
Please read ``Volatiles Are Miscompiled, and What to Do about It,´´ by Eide and Regehr. In it is an application for random programs, and references to other material on random programs.

Name: Anonymous 2009-12-08 12:11

>>19
That reminds me there was a random bbcode generator somebody was using a while ago. Sometimes it did generate interesting patterns.

Name: Anonymous 2009-12-08 12:15

>>21
GENERATE MY ANUS

Name: Anonymous 2009-12-08 13:21

>>20
That paper shows a serious lack of understanding of what they're trying to show.

Name: Anonymous 2009-12-08 13:55

>>23
How do you know they aren't showing exactly what they wanted to show, and you have just misunderstood?

Name: Anonymous 2009-12-08 13:59

>>24
And thus, the student became the master

Name: Anonymous 2009-12-08 14:05

>>25
MASTER MY ANUS

Name: Anonymous 2009-12-08 14:33

>>18
The thing about Perl is that there are more random sequences that represent valid, meaningful (if not useful) programs. Perl is considered extremely dangerous for this reason.

Name: Anonymous 2009-12-08 14:39

Perl is considered extremely dangerous for this reason.
You might even say, Perl considered harmful, amirite?

Name: Anonymous 2009-12-08 14:46

Name: Anonymous 2009-12-08 15:45

>>28
I was trying to avoid that one. Dangerous and harmful are two different things. It doesn't matter; it was a stupid joke anyway.

Name: Anonymous 2009-12-08 16:00

You might even say, stupid jokes considered harmful, n'est pas?

Name: Anonymous 2009-12-08 16:01

>>29
The Goatse Operator =()=

Name: Anonymous 2009-12-08 16:12

>>15

That's what I meant in the first place.

Name: Anonymous 2009-12-08 16:19

Making random brainfuck would be easy,.. in fact i might do that later for some EPIC LULZ

Name: Anonymous 2009-12-08 16:27

>>34
Get a random character source and just filter out all ]s that have no matching [, and close all remaining [s. Then use an implementation that ignores non-BF ops. Done.

Name: Anonymous 2009-12-08 16:41

guys, just to reafirm are the monkeys we're talking about here are monkeys as in monachus or niggers? Why is it important? You can train monkeys to work with the typewritter but niggers will just lay all day eating bananas.

Name: Anonymous 2009-12-08 16:46

>>36
niggers

Black to /b/, please.

Name: Anonymous 2009-12-08 16:56

>>34
I was bored, so here's my implementation

(defun pick-random (sequence)
  (let ((length (length sequence)))
    (elt sequence (random length))))

(defun make-random-list (source times)
  (loop repeat times collect (pick-random source)))

(defconstant +BRAINFUCK-COMMANDS+ '#(< > + - |.| |,| [ ]))

(defun make-random-valid-brainfuck (size)
  (let* ((bf
          (make-random-list +BRAINFUCK-COMMANDS+ size))
         ([-count (count '[ bf))
         (]-count (count '] bf))
         (count-diff (- [-count ]-count)))
    (cond
      ((> count-diff 0)
       (append bf (make-list count-diff :initial-element '])))
      ((< count-diff 0)
       (append (make-list (- count-diff) :initial-element '[) bf))
      (t bf))))

;CL-USER> (mapcar #'princ (make-random-valid-brainfuck 50))
;->>+[<,<.<<,.-.,+[++>.+.,+>..[+[><,>+]>]],<>-->[<<]]

Name: Anonymous 2009-12-09 0:21

>>38
Could be the basis of a genetic algorithm to grow brainfuck programs to solve problems.

Name: Anonymous 2009-12-09 3:08

Surprised no one has mentioned Core Wars yet. This is how the majority of the top competitors work; they are bred genetically.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List