diff --git a/wordle.htm b/wordle.htm index 62a4f11..9c9ef96 100644 --- a/wordle.htm +++ b/wordle.htm @@ -55,11 +55,12 @@ var valid_words = null; }) req.send() -})(); +})() -const cur_status = [0, 0, 0, 0, 0]; -var cur_guess = null; -var num_guess = 0; +const cur_status = [0, 0, 0, 0, 0] +var cur_guess = null +var num_guess = 0 +var chosen_words = []; (() => { inited = false @@ -70,9 +71,33 @@ var num_guess = 0; } }) + document.getElementById('reset').addEventListener('click', e => { + cur_guess = null + num_guess = 0 + chosen_words.length = 0 + valid_words = gen_all_words_list() + + const history_elem = document.getElementById('history') + while (history_elem.firstChild) { + history_elem.removeChild(history_elem.lastChild) + } + + const cur_word_elem = document.getElementById('cur-word') + while (cur_word_elem.firstChild) { + cur_word_elem.removeChild(cur_word_elem.lastChild) + } + + const log_elem = document.getElementById('log') + while (log_elem.firstChild) { + log_elem.removeChild(log_elem.lastChild) + } + }) + document.getElementById('find').addEventListener('click', e => { if (words_len(valid_words) == 1) { status("the word is " + words[valid_words[0]]) + log("the word is " + words[valid_words[0]]) + return } const [idx, entropy] = calc_best_word(valid_words) status("best word is " + words[idx] + " , " + entropy) @@ -162,6 +187,7 @@ var num_guess = 0; } } if (guess_idx == -1) return + chosen_words.push([guess_idx, [...cur_status]]) invalidate_words(valid_words, guess_idx, undump_match(cur_status)) log("guessed " + cur_guess + " " + words_len(valid_words) + " words left") status("guessed " + cur_guess + " " + words_len(valid_words) + " words left") @@ -174,31 +200,22 @@ var num_guess = 0; -
- -
+

- - + + +

-
+
loading words...
log: