Compare commits

..

No commits in common. "main" and "v0.1.0" have entirely different histories.
main ... v0.1.0

2 changed files with 5 additions and 16 deletions

View File

@ -14,11 +14,8 @@ go build .
## Running instructions
```bash
% ./gordle --help
% ./gordle --help
Usage of ./gordle:
-f string
Path to dictionary file with words of length -n. If specified, -n must be specified too (if the latter must not be equal to default value (default "./dictionary/5.txt")
-n int
Word size (default 5)
```
@ -31,4 +28,4 @@ go test # [-cover]
## Dictionaries
To run game you also need dictionary files. By default gordle searches for them in `./dictionary/<n>.txt` file, where `<n>` - number of characters, specified by `-n` flag. If want to use custom one, provide in `-f` flag path to txt file with strings separated by new line characters
To run game you also need dictionary files. By default gordle searches for them in `./dictionary/<n>.txt` file, where `<n>` - number of characters, specified by `-n` flag

View File

@ -26,17 +26,13 @@ func main() {
containsOutput := color.New(color.BgYellow, color.FgBlack)
wrongOutput := color.New(color.BgWhite, color.FgBlack)
nFlag := flag.Int("n", 5, "Word size")
fFlag := flag.String("f", "./dictionary/5.txt", "Path to dictionary file with words of length -n. If specified, -n must be specified too (if the latter must not be equal to default value")
var nFlag = flag.Int("n", 5, "Word size")
flag.Parse()
nChar := *nFlag
fmt.Println("Welcome to Gordle - go implementation of Wordle game")
nChar := *nFlag
filePath := *fFlag
file, err := os.Open(filePath)
file, err := os.Open(fmt.Sprintf("./dictionary/%d.txt", nChar))
if err != nil {
log.Fatal("There is no dictionary with such amount of letters")
@ -52,10 +48,6 @@ func main() {
words = append(words, scanner.Text())
}
if len(words[0]) != nChar {
log.Fatal("Words in dictionary must be of size", nChar)
}
fmt.Printf("You are going to guess a %d letter word in %d tries from %d dictionary\n", nChar, nChar+1, len(words))
rand.Seed(time.Now().Unix())