]> git.earman.xyz Git - sensor-watch.git/commitdiff
USE_RANDOM_GUESS variable added
authorDavid Volovskiy <devolov@gmail.com>
Sat, 17 Aug 2024 15:50:07 +0000 (11:50 -0400)
committerDavid Volovskiy <devolov@gmail.com>
Tue, 3 Sep 2024 20:08:12 +0000 (16:08 -0400)
movement/watch_faces/complication/wordle_face.c
movement/watch_faces/complication/wordle_face.h

index 32c396bec9ba4615d5c014c8d0adf033cf2c705a..be466cda6a7d6807016fbfb46ce97d6b2ddd7ec5 100644 (file)
@@ -135,8 +135,6 @@ static const char _expanded_words[][WORDLE_LENGTH + 1] = {
 static const char _expanded_words[][WORDLE_LENGTH + 1] = {};
 #endif
 
-static const uint16_t _num_unique_words = 155;  // The _legal_words array begins with this many words where each letter is different.
-
 
 static const uint16_t _num_words = (sizeof(_legal_words) / sizeof(_legal_words[0]));
 static const uint16_t _num_expanded_words = (sizeof(_expanded_words) / sizeof(_expanded_words[0]));
@@ -468,10 +466,12 @@ static void get_result(wordle_state_t *state) {
     return;
 }
 
+#if (USE_RANDOM_GUESS != 0)
+static const uint16_t _num_unique_words = 155;  // The _legal_words array begins with this many words where each letter is different.
 static void insert_random_guess(wordle_state_t *state) {
     uint16_t random_guess;
     do {  // Don't allow the guess to be the same as the answer
-        random_guess = get_random(_num_unique_words);
+        random_guess = get_random(USE_RANDOM_GUESS == 2 ? _num_unique_words : _num_words);
     } while (random_guess == state->curr_answer); 
     for (size_t i = 0; i < WORDLE_LENGTH; i++) {
         for (size_t j = 0; j < _num_valid_letters; j++)
@@ -484,6 +484,7 @@ static void insert_random_guess(wordle_state_t *state) {
     display_all_letters(state);
     state->using_random_guess = true;
 }
+#endif
 
 void wordle_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
     (void) settings;
@@ -552,12 +553,13 @@ bool wordle_face_loop(movement_event_t event, movement_settings_t *settings, voi
             display_letter(state, true);
             if (state->word_elements[state->position] == _num_valid_letters) break;
             state->playing = true;
-
+#if (USE_RANDOM_GUESS != 0)
             if (watch_get_pin_level(BTN_LIGHT) &&
             (state->using_random_guess || (state->attempt == 0 && state->position == 0))) {
                 insert_random_guess(state);
                 break;
             }
+#endif
             state->position = get_next_pos(state->position, state->word_elements_result);
             if (state->position >= WORDLE_LENGTH) {
                 get_result(state);
index 64a1665ce5130e9f2f1a82889cbfedfab1a25e73..97c326169554f03ddeca0f213e08b12e5a537477 100644 (file)
@@ -49,7 +49,7 @@
  *        Else: None
  *
  *    Alarm Press
- *        If Playing: If Light btn held and 
+ *        If Playing: If USE_RANDOM_GUESS is set and Light btn held and 
  *                    (on first letter or already used a random guess) 
  *                    and first attempt: Use a random 5 letter word with all letters that are different.
  *                    Else: Next position
 #define WORDLE_MAX_ATTEMPTS 6
 #define USE_DAILY_STREAK false
 
+/*  USE_RANDOM_GUESS
+ *  0 = Don't allow quickly choosing a random quess
+ *  1 = Allow using a random guess of any value that can be an answer
+ *  2 = Allow using a random guess of any value that can be an answer where all of its letters are unique
+*/
+#define USE_RANDOM_GUESS 2
+
 /*  USE_EXPANDED_DICT
  *  0 = don't use it at all (saves 2.8KB of ROM)
  *  1 = Include the expanded dict in answers