Giter VIP home page Giter VIP logo

wordlepy's Introduction

Wordle

This is a Python terminal game of Wordle and is deployed on Heroku using the Code Institutes mock terminal template.

Users are greeted by a main menu which has 3 different options to choose from, they can start a game, read the rules or if they decide they don't want to play they can exit. After choosing to start the game they have six attempts to correctly guess a random five letter word which is pulled in from a long list of five letter words. If they run out of attempts it is game over and they can try again, and every time the word is random so its very rare that they will get the same word twice in a row.

The live application can be found at WordlePy.

UX & Design

User Stories

  • As a user, I want to play a guesing game.
  • As a user, I want to be able to view the rules of the game.
  • As a user, I want to see how many letters I have guessed.
  • As a user, I want to be able to visually see what letters I have already guessed.
  • As a user, I want to be able to see how many attempts I have left.
  • As a user, I want to be able to restart the game upon completion without having to exit the program and come back.

Features

  • Home Screen/Main Menu

    • From this menu, users can, play the game, view the rules or exit the program.
    • Main Menu
  • Rules

    • This displays the rules of the games and what is required of the users to play the game, also from here users can play the game by entering the correct input.

    • Rules

  • Wordle

    • This is the main feature of this program. The user is prompted to enter their guess and from there the program works the same as wordle, a right letter in the correct postion will be coloured green, a letter in the word but in the wrong postion will be coloured yellow, and finally a letter that is not in the word an underscore will be printed and that will be coloured red.

    • Game Start

    • Letters

    • Incorrect

  • Invalid Input

    • To the best of my knowledge all invalid inputs are handled and the user is prompted to try again, mainly what is tested is, is there a special character in their guess, is their guess blank/empty, if any of these are true then they are prompted to try again and no attempts are deducted if this is the case.

    • Data Validation

    • Data Validation

    • Data Validation

  • Game Over - Win

    • You Win
  • Game Over - Lost

    • You Lose

Future Implementations

  • I would like to do all the data validation in one function instead of how I do it at the moment but I tried and ran out of time and was not able to get it to work.
  • I would also like to add multiple difficulties for example you can choose between 5 letter words, 6 letter words and so on.
  • Add a proper GUI as it currently just runs in the terminal.

Technologies Used

The following is a list of technologies that I used to create this project.

  • Python

  • HTML

  • JavaScript

  • GitHub

    • Github was used to store the projects code.
  • Gitpod

    • Gitpod was used to code this project and to push commits to GitHub.
  • Git

    • Git was used to handle version control of this project via the gitpod terminal.

Imported Libraries and Packages

  • random was used to select a random word from the list of words.
  • os was used to create the clear_screen function to reduce clutter and enhance the overall experience for the user.
  • Colorama was used to add colour for functionality of the game and to make the program slightly prettier.

Testing and Validation

  • At various stages PEP8 validation was done, I am getting one warning that I cant seem to get rid of but it does not effect the program from what I can tell PEP8

Bugs

No Bug How I solved the issue
1 After the user guesses the word the loop would keep going instead of stopping. I fixed it by adding a loop inside the game_logic function that asks would they like to play again or quit and that solved the issue.
2 The Congratulations message was printing the incorrect number of attempts taken to complete the game. I changed the while loop within the game_logic function from attempts > 0 to attempts < 6 and added a new variable called "turns" to get the right output.
3 When entering a blank string it exits the program. Changed the condition of the if statement where the data validation is done and now users can enter a blank string without it breaking the program.
4 When the users guess contained special characters and/or numbers it was taking a turn away from the user I added a check and within that check I just negated the taking a turn away from the user

A bug that I found that I don't have time to fix is when the users guess contains a special character or number it is still printed out as if they are playing the game but it does not take a turn away from them.

Another bug I found also is that if you enter a word with with the same letter occuring sometimes it won't print them out properly but I do not have time to fix it.

Deployment & Local Development

Deployment

The site is deployed using Heroku. To deploy to Heroku:

  1. To deploy on Heroku successfully you first have to create some files: requirements.txt and a procfile.

  2. The requirements.txt file contains the dependencies required to run the program successfully. To create a requirements.txt file do the following

    pip3 freeze --local > requirements.txt
  3. The procfile lets Heroku know which files actually run the app and where they can be found. To create this file run the following command in the terminal:

    echo web: python app.py > Profile
  4. If the Procfile has been created successfully it will have the Heroku logo next to it. Make sure to save both of these files (Procile and requirements.txt) then add, commit and push them go GitHub.

  5. Login to Heroku (sign up if you do not have an account).

  6. Click on the new button then click create new app.

  7. From here you will be asked to name your app and select a region. Once these are completed click create app.

  8. You will need to connect Heroku to the Github repo where the project code is located. Select Github in the deployment section, find the correct repo and then click connect.

  9. Once the repo is connected, you will need to provide Heroku with some config variables it needs to build the app if necessary, if not then you can ignore this step.

  10. You're now ready to enable automatic deployment and the create button. Now Heroku will start building your app. Once this done your app is ready to be viewed by the world!

Local Development

How to Fork

To fork the repo:

  1. Log in or sign up to Github.

  2. Go to the repo for this project, WordlePy

  3. Click the fork button in the top right corner.

How to Clone

To clone the repo:

  1. Log in or sign up to Github.

  2. Go to the repo for this project, WordlePy

  3. Click on the code button, select whether you would like to clone the repo with HTTPS, SSH or Github CLI and copy the link shown.

  4. Open the terminal in your IDE of choice and change the currect working directory to the location you want to use for the cloned directory.

  5. Type the following command into the terminal (after the clone you will need to paste the link you copied in step 3):

    git clone {Link from step 3 goes here}
  6. Set up a virtual environment.

  7. Install the dependencies from the requirements.txt file, you can do this via running the following command in the terminal:

    pip3 install -r requirements.txt

Credits

Code Used

  • Stack Overflow was used throughout this project especially with the regex patterns.
  • For the wordle algorithm itself I read a ton of different articles and kind of mashed how they did it together.
  • This video also helped me for creating the wordle logic and I built upon it and expanded it out.

Acknowledgements

I would like to thank:

  • The slack community.

wordlepy's People

Contributors

shanecdev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.