RE: RE: Be a monkey!
by gumpu (Friar) on Aug 31, 2000 at 12:13 UTC
|
Better yet, how about having it try to create a perl script and periodically
eval'ing the result? *grin* "It's not obfuscated, it's written by my
monkey!
They actually use a technique a bit similar to the
monkeys system to breed programs.
It's called genetic programming.
It can be used to breed program that are good at a certain
task. Say for instance sorting a file or solving some
math problem, or writing shakespeare :)
Applied to perl it would go something like this:
You have a population of 1000 individuals.
Each individual is a program of say 100 lines of perl code. These lines are chosen randomly at the begin.
Each population goes through a number of generations.
During each generation the fitness of each individual
(perl program) is tested.
It is tested by running the program and evaluating how
well it perform the target task. In the case of sorting
it is tested of the file was sorted correctly and how
fast the program sorted. Or how well it writes literature
in case of the Shakespeare problem.
The 500 best programs are allowed to mate and produce
two childern. For this a pair of programs is chosen at
random. A random line number is chosen. Say n.
Child 1 is created out of the first n lines of parent 1
and the remaining 100-n lines of parent 2. Child two is
made out of the first n lines of parent 2 and the remaining
100-n lines of parent 1. Sometimes a line of code
is also mutated, (changed a bit), this introduces more
diversity.
Now all the parents die. What remains is a population
of 1000 childern, a new generation. Which are hopefully
better addapted to solving the given problem.
The process is repeated.
With each generation the individuals will become better
and better (on average) at solving the given problem.
It works much like evolution works,
survival of the fittest, with a bit of mutation.
The only thing you have to do solve a problem is
specifiy is a function that defines how good a program
is at solving the given
problem.
Which is easy in most cases, though in case of
the Shakespeare problem finding
such a function is probably more difficult, cause
how do you define good literature :)
Have Fun
GalaxyNG
| [reply] |
RE: RE: Be a monkey!
by KM (Priest) on Aug 30, 2000 at 22:02 UTC
|
More like a few days, assuming a fairly regular typing rate. :)
You should take a look at all the mathematical theories on this. The question is when would one monkey type it, not the collection of monkeys. Another fun read on this (which does give a number of monkeys if you wanted a 50% chance of them typing it within 24 hours) is here (not for mathaphobics!). If it could be done in a few days, I say we start cloning some simians!
One other point, ispell might not have a lot of Shakespeare's words. Perhaps a program to create a list of only those words from a Shakespeare play? :)
Yes, I thought of that. There must be a dictionary around which he used. But, lines like 'To be or not to be' could be from ispell. I simply wonder how much computing time would be needed for one of the monkeys to type any cohesive sentence :)
create a perl script and periodically eval'ing the result?
I simply use grep on my log file.
Cheers,
KM | [reply] |
|
"The theory is that if you had an infinite number of monkeys typing at random"
See, there is an infinite number of monkeys, and he is right, in that it would only take as long as it takes a monkey to type enough characters to be shakespere.
However, on another subject, can the shakespeare be in the middle of gibberish. Or does the monkey have to stop typing eventually? or can it be:
fjkjdfjdsk
<the entire hamlet script>
fjkjdsljdsk
(of course that question would only matter if there were a finite number of monkeys>
However, back to my question as to when do the monkeys STOP typing?
Does each monkey just keep going?
| [reply] |
|
If we learned anything from Alan Turing it was that determining whether or not a monkey would ever stop typing is a problem for which there is no general solution ;)
| [reply] |
|
can the shakespeare be in the middle of gibberish
Well, it could be "kjasdad to be or not to be asdadad", but not "to sdsdsds be or sasdad not asdasd to asdaere be".
Does each monkey just keep going?
You need to figure that the monkeys have an unlimited supply of Jolt Cola, Penguin mints and do not sleep. Hey, that is sounding strangely familiar to my life!
Cheers,
KM
| [reply] |
|
> > create a perl script and periodically eval'ing the result?
> I simply use grep on my log file.
I meant how long for a monkey script to create a
valid perl file...
| [reply] |
|
| [reply] |
|
| [reply] |
|
| [reply] |
A Shakespeare-only wordlist...
by myocom (Deacon) on Aug 30, 2000 at 22:09 UTC
|
It should be fairly trivial to generate a wordlist from Shakespeare's works (q.v. Project Gutenberg). Perhaps I'll whip a little something up later to do just that.
Monkey #495827598
| [reply] |
|
| [reply] |