This post is about the step by step algorithm or we can also call it as pseudo code that we are going to implement to design the game...
•Ask for number of attempts
•Ask for minimum word length
• Open the word list file & select a random word
•Create a set of remaining letters and initialize it to contain the 26 ASCII lowercase character
•While there are attempts remaining OR there are unguessed letters in the word remaining
Print the word with the unguessed letters censored
•Ask for the next letter and make it lowercase
If the "letter" has multiple characters
Notify the player that the "letter" has multiple characters
Else if the letter is not an ASCII lowercase character
Notify the player that the letter is not an ASCII lowercase character
Else if the letter is not in the remaining letter set (i.e. has been guessed before)
Notify the player that the letter has been guessed before
Else
If letter is in the word
Notify the player that the letter is in the word
Else
Decrement attempt counter
•Notify the player that the letter is not in the word
Remove guessed letter from the remaining letters setPrint the word with the unguessed letters censored
•Ask for the next letter and make it lowercaseIf the "letter" has multiple characters
Notify the player that the "letter" has multiple characters
Else if
the letter is not an ASCII lowercase characterNotify the player that the letter is not an ASCII lowercase character
Else if
the letter is not in the remaining letter set (i.e. has been guessed before)Notify the player that the letter has been guessed before
ElseIf
letter is in the wordNotify the player that the letter is in the wordElse
Decrement attempt counter
•setReveal the word
If the word is solved
Notify the player of victory
Else
Notify the player of defeat
Give the player the option to try again

The game will be developed using the algorithm referred from a blog visit here and we will be following the same line. Thanks to the creator of the blog!
Thank you ,
Siddhesh Ramajgol
•Ask for number of attempts
•Ask for minimum word length
• Open the word list file & select a random word
•Create a set of remaining letters and initialize it to contain the 26 ASCII lowercase character
•While there are attempts remaining OR there are unguessed letters in the word remaining
Print the word with the unguessed letters censored
•Ask for the next letter and make it lowercase
If the "letter" has multiple characters
Notify the player that the "letter" has multiple characters
Else if the letter is not an ASCII lowercase character
Notify the player that the letter is not an ASCII lowercase character
Else if the letter is not in the remaining letter set (i.e. has been guessed before)
Notify the player that the letter has been guessed before
Else
If letter is in the word
Notify the player that the letter is in the word
Else
Decrement attempt counter
•Notify the player that the letter is not in the word
Remove guessed letter from the remaining letters setPrint the word with the unguessed letters censored
•Ask for the next letter and make it lowercaseIf the "letter" has multiple characters
Notify the player that the "letter" has multiple characters
Else if
the letter is not an ASCII lowercase characterNotify the player that the letter is not an ASCII lowercase character
Else if
the letter is not in the remaining letter set (i.e. has been guessed before)Notify the player that the letter has been guessed before
ElseIf
letter is in the wordNotify the player that the letter is in the wordElse
Decrement attempt counter
•setReveal the word
If the word is solved
Notify the player of victory
Else
Notify the player of defeat
Give the player the option to try again
The game will be developed using the algorithm referred from a blog visit here and we will be following the same line. Thanks to the creator of the blog!
Thank you ,
Siddhesh Ramajgol
Very helpful article..Keep posting similar articles...Thank you!!
ReplyDeleteVery nice!
ReplyDelete