Giter VIP home page Giter VIP logo

wordle's Introduction


Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. License
  6. Contact
  7. Acknowledgments

About The Project

This project started out as a simple console based clone of the Wordle game. The console application has no graphics, just keyboard input and the console window to output the result of each guess. It is written in C++20 and I used it as a test bed for some of the C++20 features. I was particularly interested in creating a constexpr game. This mostly worked except for the random number generation.

I then decided that it might be nice to add a UI to the project. So, I refactored the original console project into a static library WordleLib, the console application WordleConsole and a test harness WordleTest:

  • WordleLib: contains the core game functionality (i.e. checking the user's guess in terms of the letters and their positions) and the collection of words.
  • WordleConsole: contains the main game loop.
  • WordleTest: contains unit tests for the game functions. It is based on GTest and provides a simple way to check the API.

Finally, on top of WordleLib, I built a WordleWinUI project. This is a Windows Desktop application written in C++/WinRT. It consists of a single page which displays a board of tiles and a keyboard for selecting letters.

This project demonstrates:

  • XAML:

    • Using the ItemsRepeater to display the keyboard rows and keys.
    • Using a nested DataTemplate with an ItemsRepeater to display the grid.
    • Using DataTemplate's to simplify applying styles to controls.
  • MVVM

    • The MainPage code behind handles the construction of the view model and the keyboard 'tapped' event.
    • Separation of the MainPage (the view) from the model (Letters, WordRow) using the model view (MainViewModel) as the intermediary.
    • The MainViewModel handles initialising the game and processing the game turns. The underlying WordleLib handles the selection of the target word, retrieving results and checking if the game is won/lost.
  • C++/WinRT:

    • Resizing the main application window; setting an application icon.
    • Using Package.appxmanifest to generate icons for the taskbar.
    • Defining models using MIDL3.0, and providing implementations and type conversions.
    • ContentDialog and a custom MessageBox (this is still a work in progress).
    • Support for Light/Dark mode via a toggle button on the MainPage.
    • Support for persisting and retrieving the LightTheme setting from local application settings.

(back to top)

Built With

  • Visual Studio 2022
  • C++20
  • C++/WinRT
  • WinUI 3.0

(back to top)

Getting Started

The project can be downloaded from the GitHub repository in the usual way.

Prerequisites

Installation

(back to top)

Usage

WordleConsole

The console application (and the static WordleLib) is small: only ~200 lines of code. It has a small set of possible words (463). The game begins by the code choosing one word at random (see below). The user then proceeds to make guesses (up to a maximum of 5) using the report from each word to refine his/her guess. The 'report' basically says, for each letter whether the letter is correct in the position (Green), correct but not in that position (Orange) and incorrect (Grey). There are only two outcomes: you guess the word (in up to 5 guesses) or you lose.

The console application allows you to play the game.

Product Name Screen Shot

Of course, there is a 'cheat' mode that allows you to display the target word.

WordleWinUI

The intention of WordleWinUI was to use both WinUI 3.0 and XAML for the UI, but more importantly to write a Windows Desktop application in C++/WinRT. A more natural choice may have been to use C# (and I'm certain the development would have been easier). However, the underlying WordleLib is written in C++20 and I did not want to wrap this with a Windows Runtime Component in order to use C# (as I have done in the past in the Software Interoperability project).

The screenshots below show a couple of typical game turns.

WordleWinUI

WordleWinUI

(back to top)

Roadmap

See the open issues for a full list of proposed features (and known issues).

(back to top)

License

Distributed under the GPL-3.0 License. See LICENSE.md for more information.

(back to top)

Contact

Adam Gladstone - (https://www.linkedin.com/in/adam-gladstone-b6458b156/)

Project Link: https://github.com/Adam-Gladstone/Wordle

(back to top)

Acknowledgments

Helpful resources

(back to top)

Issues GPL-3 License LinkedIn

wordle's People

Contributors

adam-gladstone avatar

Watchers

 avatar  avatar

Forkers

linneon

wordle's Issues

Improve initialisation of the rows and keyboard.

Refactor the initialisation of the 'single_threaded_observable_vector' collections to take advantage of construction semantics (following a series of articles on Microsoft Developer Blog: https://devblogs.microsoft.com/oldnewthing/20240522-00/?p=109795).

  • In the case of the rows, we can use the initialisation list constructor rather than append.
  • In the case of the 'keyboard' rows, we create a std::vector of IInspectable values that is moved into the collection.

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.