Coder Social home page Coder Social logo

wordle's Introduction

Wordle

tests codecov GitHub

Python implementation of a Wordle player. The source code provides a structure to easily create Wordle players, and some built-in strategies:

  • heuristic: a simple heuristic strategy that priorities words that contain letters with the highest frequency. Linear time complexity $O(W)$.
  • minmax: minmax strategy that minimize the maximum number of candidates on the next move. Quadratic time complexity $O(W^2)$.
  • precomputed: decorator strategy that precomputes the full decision tree. Constant time complexity $O(1)$ at runtime. Precomputation complexity is the same as the targeted strategy, as it is repeated for each step of the decision tree which has a constant number of nodes.

Installation

Clone the repository and run the following command from the project root to install the required dependencies (use a virtual environment if you wish, or don't, I'm not your mother):

pip install -r requirments.txt

Usage

The package provides a CLI interface to play with the different functions. Check the help for more information in this way:

$ python cli.py --help

The main subcommand is play, that let you play with the different strategies:

$ python cli.py play

Here an example of a game with the minmax strategy:

$ python cli.py play -S minmax -p
hint: arise
$ python cli.py play -S minmax -p arise .____
hint: candy
$ python cli.py play -S minmax -p arise .____ candy _X__.
hint: bayou

-S let you choose the strategy to use. The default strategy is heuristic.

-p grabs the strategy from the precomputed tree named data/strategies/<strategy-name>.json.

Finally you need to provide the sequence of guess/feedback pairs, where the feedback is encoded as a string of the following characters:

  • _: incorrect letter
  • .: correct letter, wrong position
  • X: correct letter, correct position

Acknowledgments

Thanks to @lostella for the always constructive conversations (that I'm missing), and to @davideboschetto and @albertoguiggiani for the laughs.

wordle's People

Contributors

marcotinacci avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.