wordle

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAlphabet

func GetAlphabet() []rune

GetAlphabet returns all runes in the alphabet

Types

type HintState added in v1.0.1

type HintState int8

HintStatus indicates the state of a character compared to the solution

const (
	HintUnknown           HintState = iota // Character has not been guessed yet
	HintIncorrect         HintState = iota // Character is not in the solution
	HintIncorrectPosition HintState = iota // Character is in the wrong position, but is in the solution
	HintCorrect           HintState = iota // Character is in the correct position
)

type Hints added in v1.0.1

type Hints struct {
	BackgroundColor bool
	AlphabetHintMap map[rune]HintState
}

func NewHints added in v1.0.1

func NewHints(backgroundColor bool) Hints

func (Hints) String added in v1.0.1

func (h Hints) String(r rune, hs HintState) string

String returns the string representation of the Hint for a character

func (Hints) UpdateAlphabetHintMap added in v1.0.1

func (h Hints) UpdateAlphabetHintMap(r rune, new HintState)

UpdateHintMap updates the hint map the given character only if the new hint is better than the current

type Wordle

type Wordle struct {
	Solution   string
	Guesses    int
	MaxGuesses int
	Win        bool
	Hints      Hints
}

Wordle represents a wordle game and the necessary state

func NewWordle

func NewWordle(solution string, maxGuesses int, backgroundColor bool) *Wordle

NewWordle properly initializes a new Wordle game

func (*Wordle) GetAlphabetHints

func (w *Wordle) GetAlphabetHints() string

GetAlphabetHints returns the current games hints for all letters in the alphabet

func (*Wordle) Guess

func (w *Wordle) Guess(guess string) string

Guess validates a guess against the solution and returns the hints for the guess

func (Wordle) IsLose

func (w Wordle) IsLose() bool

IsLose returns true if the game has been lost

func (Wordle) IsWin

func (w Wordle) IsWin() bool

IsWin returns true if the game has been won

type Words

type Words struct {
	// contains filtered or unexported fields
}

Words is a struct to hold the list of words and solutions

func NewWords

func NewWords(wordPath string, solutionsPath string) *Words

NewWords properly initializes a new Words struct

func (*Words) Exists

func (w *Words) Exists(word string) bool

Exists checks if a word exists in the list of words

func (*Words) RandomSolution

func (w *Words) RandomSolution(random *rand.Rand) string

RandomSolution chooses a random word from the solution list

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL