# The-Shakespeare-and-Monkey-Problem:进化计算-遗传算法

• c5_422926
了解作者
• 5.5KB
文件大小
• zip
文件格式
• 0
收藏次数
• VIP专享
资源类型
• 0
下载次数
• 2022-06-13 13:38
上传日期

The-Shakespeare-and-Monkey-Problem-master.zip
• The-Shakespeare-and-Monkey-Problem-master
• .gitignore
9B
1.6KB
1KB
• sketch.js
2.5KB
• DNA.js
1.2KB
• Population.js
1.8KB
• index.html
515B
• style.css
216B

# The Shakespeare and Monkey Problem Evolutionary Computing - Genetic Algorithm ![Monkeys](https://blogs.illinois.edu/files/25/14943/268.jpg) ## Why this algorithm is necessary? If you had a monkey typing at a typewriter randomly for an inifinity amount of time, eventually in some moment of the time this monkey would type out the completes works of Shakespeare. Okay, simplifing the problem, let's say the only thing we want from the monkey is ### **to be or not to be** let's imagine a keyboard only with a-z and spacebar character. **likelihood of typing a "t" randomly is 1/27** **likelihood of typing a "to" randomly is 1/27 * 1/27** likelihood of typing the entire phrase: (1/27) ^ 18 1 in **58,149,737,003,040,059,690,390,168** A computer simulation with 100.000 phrases per second would take: ~ 18,439,160,642,770 years Don't forget that the age of universe is 13,750,000,000 years (estimated). So that way is unworkable. ## Solution One way to solve this is with an algorithm that: 1. Starts to generate phrases randomly. 2. After every generation, it autoevolves based in the accurary of phrases giving each phrase a fitness. 3. Select the best ones and mix then based in some rule eg.: as half of one phrase and half of other. 4. After that, we repeat the steps until we get to the target phrase. That concept that we call **Genetic Algorithm** [Try by yourself here](https://jbezerra.github.io/The-Shakespeare-and-Monkey-Problem/index.html) ![Solution](https://media.giphy.com/media/L07I25uEUqkTvVoBe7/giphy.gif) Have some fun and spread the word =P Any questions? josebezerraneto@outlook.com

相关推荐