vgip/wordle

此包的最新版本(1.1.1)没有可用的许可证信息。

根据条件从目录中选择单词

1.1.1 2023-03-27 00:29 UTC

This package is auto-updated.

Last update: 2024-09-27 03:27:04 UTC


README

根据条件从目录中选择单词

  • 字母位于定义位置的单词中;
  • 字母位于未定义位置的单词中;
  • 单词中缺少字母。
use Vgip\Wordle\Pick\Pick;
use Vgip\Wordle\Pick\LetterConfigFactory;

/** Get directory of words as array - see example/words_en_5_letter.txt for example */
$pathWords = join(DIRECTORY_SEPARATOR, [__DIR__, 'words_en_5_letter.txt']);
$wordList = file($pathWords);

/** Set conditions to pick of words */
$letterList = [];
$letterList['x'] = false; // The letter "x" is missing from a word.
$letterList['a'] = LetterConfigFactory::factory('defined', [2]); // Set that the letter "a" is in the word in 2nd place
$letterList['n'] = LetterConfigFactory::factory('undefined', [3, 5]); // Set that the letter "n" is not in the word in 3nd and 5nd places

$pick = new Pick();
$candidateList = $pick->getCandidate($wordList, $letterList);
$resultLog = $pick->getResultLog(); 
    
print_r($candidateList);

setSkipWordDoubleLetter()

如果设置为True,将跳过所有包含重复字母的单词。默认设置为False。

$pick->setSkipWordDoubleLetter(true);

setResultLogOn()

如果设置为true,所有单词选择操作将被记录。默认设置为False。

$pick->setResultLogOn(true);
$candidateList = $pick->getCandidate($wordList, $letterList);
$resultLog = $pick->getResultLog();
print_r($resultLog);