Solving simple word ciphers with probabilistic Natural Language Processing and search algorithms, in C#.
This was the optional final exercise for the original Stanford "massive open online course" ai-class.com.
Two ciphers are solved: a rotation and a column swap one.
Solvers are implemented as separate classes, and all are run from Program.Main()
.
For the (more complex) column ciphers, two strategies are implemented: greedy (ColumCipherGreedy
class) and A* search (ColumCipherSearch
).
For the sample input provided, both succeed fully, and the greedy algorithm is quite faster.
The rotation ciphers solver is implemented in the class RotationCipher
.
The program requires a word dictionary to calculate word probabilities.
It must be a text file with one word in each line.
One is provided as WordDictionary.txt
.
Input (text of both ciphers) is taken from the .config
XML file
-- probably not the handiest thing.
Ouput of the column swap ciphers shown below, from sample input. The program outputs an animation of the search onto the console, which surely slows the whole thing some orders of magnitude, so the measured times are not actually boasting just informative.