#wordle #dictionary #game

bin+lib wordler

Library and cli for Wordle

6 releases

0.3.0 Feb 7, 2022
0.2.4 Feb 7, 2022

#632 in Games

MIT license

675KB
430 lines

Wordle in Rust

A Rust library and cli for Wordle. Inspired by Wordle in Bash

Install

cargo install wordler

Play

wordler

Play Demo

Basic Usage

use wordler::dictionary::EnglishDictionary;
use wordler::wordle::{Wordle, PlayResult};

let dictionary = EnglishDictionary::new().unwrap();
let mut wordle = Wordle::new(&dictionary);
let play_result = wordle.play("dream");
match play_result {
  Ok(play_result) => {
    println!("{}", play_result);
    match play_result {
        PlayResult::YouWon(_) => std::process::exit(0),
        PlayResult::YouLost(_, _) => std::process::exit(1),
        PlayResult::TurnResult(_) => {}
    }
  }
  Err(e) => println!("{}", e),
}

lib.rs:

A library for Wordle and Dictionary to use with Wordle.

Play

wordler

Example

Basic usage:

use wordler::dictionary::EnglishDictionary;
use wordler::wordle::{Wordle, PlayResult};

let dictionary = EnglishDictionary::new().unwrap();
let mut wordle = Wordle::new(&dictionary);
let play_result = wordle.play("dream");
match play_result {
  Ok(play_result) => {
    println!("{}", play_result);
    match play_result {
        PlayResult::YouWon(_) => std::process::exit(0),
        PlayResult::YouLost(_, _) => std::process::exit(1),
        PlayResult::TurnResult(_) => {}
    }
  }
  Err(e) => println!("{}", e),
}

Dependencies

~1.5MB
~24K SLoC