Hey guys,
I have been asked to write a program in php which is to play hangman but used in messenger chat. We are using imified to create our "bot".
The game to me sounds backwards to normal but here is the deign brief.
. In your game of hang-man, the user should pick the word and the bot should guess the word. The bot should be allowed 13 wrong guesses before it has lost. A sample game might look like this (user messages in bold, bot response in normal font):
● hangman: __________
● How about E?
● __________
● Oh no! I only have 12 lives left :( How about I?
● ______I__
● Great! How about O?
● _O____I__
● Hmm. Difficult. How about U?
● _O__U_I__
● Interesting. How about P?
● _O_PU_I__
● Wonderful! How about X?
● _O_PU_I__
● Argh! Another life lost. Only 11 to go. How about T?
● _O_PUTI__
● Cool. How about N?
● _O_PUTIN_
● Hmm. Difficult. How about G?
● _O_PUTING
● Wonderful! How about M?
● _OMPUTING
● Interesting. How about C?
● COMPUTING
● I win!
● choose random responses such as “Great!” and “Hmm. Difficult.” from a database of responses.
● give a useful error message if the user does not play the game as expected.
● guess the next letter using an algorithm that works as follows:
a. look at the length of the word that the user has entered
b. find all words in the british-english.txt dictionary of the same length, we’ll call this array of words the search array
c. determine the frequency of all of the letters that appear in words in the search array; guess the most frequent letter
d. if the bot has guessed wrongly, guess the next most frequent letter and repeat until it guesses correctly. If the bot has guessed correctly, then narrow the search array to include only those words with the letter occurring in the right places. Then go to step c. and repeat until the game is over.
● know how often it is likely to win. Write a program to go through each word in the british-english.txt dictionary and determine whether or not your bot could guess the word. Your bot will guess a word correctly if it can correctly guess every letter in the word before it makes 13 wrong guesses. Then the percentage of games which the bot will win is this:
(number of words guessed correctly/number of words in dictionary)*100
I won't lie it is for a uni project, and we have no idea on how to get started.
Help would be very much appreciated. Thank you :)