Coder Social home page Coder Social logo

wordle_strategy_evaluation's Introduction

About

This is a Python implementation of wordle designed to make it easy to run multiple games and evaluate different strategies. For examples of how to use the package, see the test files.

Strategies

For this package a strategy is defined as a function which takes in a Game object and returns that object as a solved game. A simple strategy might look like this:

def cheat(game):
    game.guess(game.target_word)
    return game

While it’s not particularly interesting to use the target_word attribute of the game object, there are attributes which you would actually use in game like the greens, yellows, and greys built in arrays. There are also a handful of helpful functions in the strategies.py file. Here’s an example of a slightly more sophisticated strategy.

from wordle_strategy_evaluation.game import DEFAULT_WORDS_LIST
import wordle_strategy_evaluation.strategy as st

def guess_by_freq(game):
    while not game.game_over:
        filtered = st.filter_all(game)
	  rate_words = st.score_words_list(filtered, st.DEFAULT_FREQS)
	  best_word = list(rate_words.keys())[0]
	  game.guess(best_word)
    return game

The st.filter_all function looks at the greens, yellows, and greys from previous guesses and filters the complete word list accordingly. The st.score_words just scores words according to how often a letter appears in a given position. This strategy will solve a wordle in about 3.81 guesses on average.

wordle_strategy_evaluation's People

Contributors

seth-rothschild avatar

Watchers

 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.