| Return to Contents | Return to Project Reports |
Here is pseudocode for the cryptoquote solving program, the MASTER part:
CRYPTO (cryptoquote filename) (dictionary name)
read in cryptoquote
for (n words in cryptoquote)
spawn task "crypto_slave"
pass message with a word to task
while not(problem solved) and not(problem halted)
wait for message in buffer
case (messagetype)
"word solved":
update all slaves with new info
reduce list of words left to solve
print to screen the solution of the word
"task halted": note the fact in an array of n booleans
if (wordsleft unsolved) = 0
problem solved
if all positions in (is a given slave halted)and
(no messages in any slave's buffer)
problem halted
if (problem solved)
print solution
else
print knowledge so far
end CRYPTO
Here is psudocode for the SLAVE part:
CRYPTO_SLAVE (cryptoquote filename) (dictionary name)
read in the dictionary
while not(word solved)
while not(wordsleft less than 2) and not(time to check buffer)
if (first pass)
if (pattern of word = pattern of dictionary word)
if (word possible considering letters eliminated)
accept word
else
reject word
else
if (word possible considering letters eliminated)
accept word
else
reject word
if (word accepted)
add appropriate letters to "canbe" array
if not(end of list)
check buffer
if (message present)
get message
update local version of letter list
else
from list of "canbe" letters, calculate "cannotbe"
if (current "cannotbe" better than from start of pass)
send global update
else
indicate process halted to master
wait for update