Skip to main content

The Designing Strategy

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 set
Print 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

Image result for hangman game
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

Comments

Post a Comment

Popular posts from this blog

The output!

So here we arrive at the OUTPUT ! When you run the code in any Python IDE you will get results as follows: We are planning to put a video explaining each part of the source code in the next and final post for this blog. So, do visit again! Happy Learning!                                                             -Kartik Mehetre

Project Documentation

Course Project Title: HANGMAN GAME in Python Description: An interactive game of Hangman developed using python(an object programming language).The project consists of a number of functions used in the game by making use of inbuilt Python libraries.The game offers the user to choose number of attempts and also shows a graphical output. Link for project report: here Final Code File :  Python Code Topic 1: Hangman graphic function Presentor's info:  Name: Siddhesh Ramajgol Div: TY-L Roll no: 57 GR.no : 1710081 Video Link:   Hangman Graphic Function Topic 2: Get no.of attempts and word length Presentor's info:  Name:  Kartik Mehetre Div: TY-L Roll no: 47 GR.no :  1710382 Video Link:  No.of attempts and word length Topic 3: Get next letter and display words Presentor's info:  Name: Shreya Uttarwar Div: TY-L Roll no: 69 GR.no :  1710360 Video Link:  Get next letter and display ...

Getting started with coding

It's been while since we posted! So,let's continue our project. One of the essential data structures that we'll be using extensively is "SETS" in python. Just for the essence,here's a quick look at it: ******** CODE *********       my_list = [] my_set = set() my_list.append('a') my_set.add('a') print(my_list)  # Output: ['a'] print(my_set)  # Output: {'a'} my_list.append('b') my_set.add('b') print(my_list)  # Output: ['a', 'b'] print(my_set)  # Output: {'b', 'a'} my_list.append('a') my_set.add('a') print(my_list)  # Output: ['a', 'b', 'a'] print(my_set)  # Output: {'b', 'a'} ******** END ********** The reason behind using SETS over LISTS is elements in a set are unique and unordered. By using this data structure,we can build our vocabulary for the application. Learn more about SETS in python : https://...