guess

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Calculate

func Calculate(state *GuessState) (err error)

calculate word on hitting enter 1. Enter is hit before word is complete 2. Enter is hit after word is complete

func ClearLetter

func ClearLetter(state *GuessState) (row int, col int, err error)

clear word on backspace return row, col to clear the letter error if letter is not be cleared

func GetSize added in v1.0.0

func GetSize() (x int, y int)

grid dimensions wordle letter dimension

func GetTotalTries added in v1.0.0

func GetTotalTries() int

total tries

func GetWordLength added in v1.0.0

func GetWordLength() int

guess word length

func HandleLetter

func HandleLetter(letter rune, state *GuessState) (row int, col int, err error)

handle incoming letter if the current word is not complete, append the letter and notify the ui that ui has to be updated if the current word is full, just ignore the incoming letters

Types

type GuessState added in v1.0.0

type GuessState struct {
	// active guess index
	ActiveIndex int
	// flag to indicate if word is guessed
	IsOver bool
	// flag to decide if the user has correctly guessed
	IsSuccess bool
	// valid final list
	ValidList []string
	// tried guesses
	Tries [6]string
	// wordle for the game
	Wordle string
}

guess state

func GetInitialState added in v1.0.0

func GetInitialState() GuessState

initial guess state

type LetterPosition

type LetterPosition string

letter position related stuffs

const (
	// letter is in correct position
	LetterPositionCorrect LetterPosition = "correct"
	// letter is NOT in correct position
	LetterPositionInCorrect LetterPosition = "incorrect"
	// letter is not in word
	LetterPositionMissing LetterPosition = "missing"
	// neutral state; we have not yet calculated letter position
	LetterPositionBlank LetterPosition = "blank"
)

func FindLetterPosition

func FindLetterPosition(wordle string, col int, letter string) (pos LetterPosition)

helper function to calculate letter color takes in index and letter we will compare the letter at specified index of the wordle returns LetterPosition

Jump to

Keyboard shortcuts

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