Skip to content

Commit

Permalink
Argument to specify a word from a given date.
Browse files Browse the repository at this point in the history
  • Loading branch information
archy-bold committed Jan 5, 2022
1 parent ab34421 commit 16e6f77
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Run the command with no arguments to play a game with today's word.
- `-cheat` - Runs in solve mode to work out an existing wordle. Follow the instructions to enter your results and receive suggested words to play.
- `-random` - Choose a random word instead of today's
- `-auto` - Automatically completes the puzzle
- `-date=[2021-12-31]` - Set the winning word from a specific date
- `-word=[answer]` - Set the winning word with this argument.
- `-all` - Runs the auto-solver through every permutation, giving results when complete.
- `-starter=[word]` - Specify the starter word for strategies
16 changes: 12 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func main() {
cheatPtr := flag.Bool("cheat", false, "Whether to run the solver mode")
autoPtr := flag.Bool("auto", false, "Play the game automatically")
randomPtr := flag.Bool("random", false, "Choose a random word, if none specified. Otherwise gets daily word")
datePtr := flag.String("date", "", "If specified, will choose the word for this day")
starterPtr := flag.String("starter", "", "The starter word to use in strategies")
allPtr := flag.Bool("all", false, "Play all permutations")
flag.Parse()
Expand Down Expand Up @@ -153,10 +154,17 @@ func main() {
pos = rand.Intn(len(validWords))
} else {
// Go by date
today := time.Now().UTC()
year, month, day := today.Date()
today = time.Date(year, month, day, 0, 0, 0, 0, time.UTC)
pos = int(today.Sub(startDate).Hours() / 24)
var dt time.Time
if *datePtr != "" {
dt, err = time.Parse("2006-01-02", *datePtr)
check(err)
// TODO check the date isn't before the start date or after the end date
} else {
dt = time.Now().UTC()
year, month, day := dt.Date()
dt = time.Date(year, month, day, 0, 0, 0, 0, time.UTC)
}
pos = int(dt.Sub(startDate).Hours() / 24)
}
answer = validWords[pos]
}
Expand Down
Binary file modified wordle
Binary file not shown.

0 comments on commit 16e6f77

Please sign in to comment.