6 个版本
0.3.0 | 2022年2月7日 |
---|---|
0.2.4 | 2022年2月7日 |
#719 in 游戏
675KB
430 代码行
Rust 中的 Wordle
一个用于 Wordle 的 Rust 库和命令行工具。灵感来自 Bash 中的 Wordle
安装
cargo install wordler
玩法
wordler
基本用法
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
:
Wordle 和词典的库,可用于与 Wordle 一起使用。
玩法
wordler
示例
基本用法
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),
}
依赖项
~1.5MB
~25K SLoC