Added documentation for Wordle face

This commit is contained in:
David Volovskiy
2024-08-17 02:13:26 -04:00
parent 3e327eb7fd
commit 02f6a3256c
3 changed files with 119 additions and 40 deletions

View File

@@ -29,33 +29,8 @@
#include "watch_utility.h"
#endif
#define FREQ 2
/*
TODO:
* Add a way to recount previous attempts
*/
// From: https://gist.github.com/shmookey/b28e342e1b1756c4700f42f17102c2ff
/*
Letter | Usage
_______|______
E | 1519
S | 1490
A | 1213
R | 1026
O | 852
L | 850
I | 843
T | 819 But looks bad across all positions
N | 681
D | 619 lowercase d looks like a in certain positions
C | 525
U | 514 P has more words with the other letters here (281 vs 198)
P | 448
*/
static const char _valid_letters[] = {'A', 'C', 'E', 'I', 'L', 'N', 'O', 'P', 'R', 'S'};
// Number of words found: 281
@@ -253,7 +228,10 @@ static void display_streak(wordle_state_t *state) {
char buf[12];
state->curr_screen = SCREEN_STREAK;
#if USE_DAILY_STREAK
sprintf(buf, "WO St%2ddy", state->streak);
if (state->streak > 99)
sprintf(buf, "WO St--dy");
else
sprintf(buf, "WO St%2ddy", state->streak);
#else
sprintf(buf, "WO St%4d", state->streak);
#endif
@@ -392,7 +370,8 @@ static void get_result(wordle_state_t *state) {
if (exact_match) {
state->playing = false;
state->curr_screen = SCREEN_WIN;
state->streak++;
if (state->streak < 0x7F)
state->streak++;
#if USE_DAILY_STREAK
state->prev_day = get_day_unix_time();
#endif
@@ -428,7 +407,7 @@ void wordle_face_activate(movement_settings_t *settings, void *context) {
if (state->prev_day <= (now + (60 *60 * 24))) state->streak = 0;
if (state->curr_day != now) state->playing = false;
#endif
movement_request_tick_frequency(FREQ);
movement_request_tick_frequency(2);
display_title(state);
}
@@ -485,7 +464,10 @@ bool wordle_face_loop(movement_event_t event, movement_settings_t *settings, voi
break;
case EVENT_LIGHT_BUTTON_DOWN:
case EVENT_ACTIVATE:
break;
case EVENT_TIMEOUT:
if (state->curr_screen >= SCREEN_WIN)
display_title(state);
break;
case EVENT_LOW_ENERGY_UPDATE:
if (state->curr_screen == SCREEN_TITLE)

View File

@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2024 <#author_name#>
* Copyright (c) 2024 <David Volovskiy>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -28,15 +28,37 @@
#include "movement.h"
/*
* A DESCRIPTION OF YOUR WATCH FACE
*
* and a description of how use it
* Wordle Face
* A port of NY Times' Wordle game (https://www.nytimes.com/games/wordle/index.html)
* A random 5 letter word is chosen and you have WORDLE_MAX_ATTEMPTS attempts to guess it.
* Each guess must be a valid 5-letter word found in _legal_words in the C file.
* The only letters used are _valid_letters, also found in the C file.
* After a guess, the letters in the correct spot will remain,
* and the letters found in the word, but in the incorrect spot will blink.
* The screen after the title screen if a new game is started shows the streak of games won in a row.
*
* If USE_DAILY_STREAK is set to True, then the game can only be played once per day,
* and the streak resets to 0 if a day goes by without playing the game.
*
* Controls:
* Light Press
* If Playing: Next letter
* Else: Next screen
* Light Hold
* If Playing: Previous letter
* Else: None
*
* Alarm Press
* If Playing: Next position
* Else: Next screen
* Alarm Hold
* If Playing: Previous position
* Else: None
*/
#define WORDLE_LENGTH 5
#define WORDLE_MAX_ATTEMPTS 6
#define USE_DAILY_STREAK true
#define USE_DAILY_STREAK false
typedef enum {
WORDLE_LETTER_WRONG = 0,