-
Notifications
You must be signed in to change notification settings - Fork 242
feature / Changes to make easier levels [44] #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,5 @@ | ||||||
| import "./App.css"; | ||||||
| import { maxGuesses, seed } from "./util"; | ||||||
| import { Difficulty, maxGuesses, seed } from "./util"; | ||||||
| import Game from "./Game"; | ||||||
| import { useEffect, useState } from "react"; | ||||||
| import { About } from "./About"; | ||||||
|
|
@@ -33,14 +33,35 @@ function App() { | |||||
| window.matchMedia && | ||||||
| window.matchMedia("(prefers-color-scheme: dark)").matches; | ||||||
| const [dark, setDark] = useSetting<boolean>("dark", prefersDark); | ||||||
| const [difficulty, setDifficulty] = useSetting<number>("difficulty", 2); | ||||||
| const [titleFormat, setTitleFormat] = useState<string>("inherit"); | ||||||
| const [colorBlind, setColorBlind] = useSetting<boolean>("colorblind", false); | ||||||
| const [difficulty, setDifficulty] = useSetting<number>("difficulty", 0); | ||||||
| const [keyboard, setKeyboard] = useSetting<string>( | ||||||
| "keyboard", | ||||||
| "qwertyuiop-asdfghjkl-BzxcvbnmE" | ||||||
| ); | ||||||
| const [enterLeft, setEnterLeft] = useSetting<boolean>("enter-left", false); | ||||||
|
|
||||||
| useEffect(() => { | ||||||
| switch (difficulty) { | ||||||
| case 0: | ||||||
| setTitleFormat("#23eb2a"); | ||||||
| break; | ||||||
| case 1: | ||||||
| setTitleFormat("#94eb97"); | ||||||
| break; | ||||||
| case 2: | ||||||
| setTitleFormat("inherit"); | ||||||
| break; | ||||||
| case 3: | ||||||
| case 4: | ||||||
| setTitleFormat("#e66"); | ||||||
| break; | ||||||
| default: | ||||||
| setTitleFormat("inherit"); | ||||||
| } | ||||||
| }, [difficulty]); | ||||||
|
|
||||||
| useEffect(() => { | ||||||
| document.body.className = dark ? "dark" : ""; | ||||||
| setTimeout(() => { | ||||||
|
|
@@ -66,8 +87,9 @@ function App() { | |||||
| <h1> | ||||||
| <span | ||||||
| style={{ | ||||||
| color: difficulty > 0 ? "#e66" : "inherit", | ||||||
| fontStyle: difficulty > 1 ? "italic" : "inherit", | ||||||
| color: titleFormat, | ||||||
| fontStyle: | ||||||
| difficulty === Difficulty.UltraHard ? "italic" : "inherit", | ||||||
| }} | ||||||
| > | ||||||
| hell | ||||||
|
|
@@ -130,12 +152,16 @@ function App() { | |||||
| id="difficulty-setting" | ||||||
| type="range" | ||||||
| min="0" | ||||||
| max="2" | ||||||
| max="4" | ||||||
| value={difficulty} | ||||||
| onChange={(e) => setDifficulty(+e.target.value)} | ||||||
| /> | ||||||
| <div> | ||||||
| <label htmlFor="difficulty-setting">Difficulty:</label> | ||||||
| | ||||||
| <strong> | ||||||
| {["Baby", "Easy", "Normal", "Hard", "Ultra Hard"][difficulty]} | ||||||
| </strong> | ||||||
| <strong>{["Normal", "Hard", "Ultra Hard"][difficulty]}</strong> | ||||||
| <div | ||||||
| style={{ | ||||||
|
|
@@ -147,6 +173,8 @@ function App() { | |||||
| > | ||||||
| { | ||||||
| [ | ||||||
| `Guesses don't even need to be real words.`, | ||||||
| `Guesses must be valid dictionary words. Easy mode.`, | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let’s describe what exactly makes this “easy mode”.
Suggested change
|
||||||
| `Guesses must be valid dictionary words.`, | ||||||
| `Wordle's "Hard Mode". Green letters must stay fixed, and yellow letters must be reused.`, | ||||||
| `An even stricter Hard Mode. Yellow letters must move away from where they were clued, and gray clues must be obeyed.`, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,12 +29,14 @@ interface GameProps { | |
| keyboardLayout: string; | ||
| } | ||
|
|
||
| const easyTargets = targetList.slice(0, targetList.indexOf("revel") + 1); // Slightly more frequent word on the list | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. “revel” is currently on line 14279 of the wordlist, while “murky” is on line 14502. I don’t think removing 223 possible words out of 14501 will produce a noticeable difference in difficulty. How about halving the search space by splitting on a word around line 7000? |
||
| const targets = targetList.slice(0, targetList.indexOf("murky") + 1); // Words no rarer than this one | ||
| const minWordLength = 4; | ||
| const maxWordLength = 11; | ||
|
|
||
| function randomTarget(wordLength: number): string { | ||
| const eligible = targets.filter((word) => word.length === wordLength); | ||
| function randomTarget(wordLength: number, difficulty: number): string { | ||
| const target = difficulty < Difficulty.Normal ? easyTargets : targets; | ||
| const eligible = target.filter((word) => word.length === wordLength); | ||
| let candidate: string; | ||
| do { | ||
| candidate = pick(eligible); | ||
|
|
@@ -79,7 +81,7 @@ function Game(props: GameProps) { | |
| ); | ||
| const [target, setTarget] = useState(() => { | ||
| resetRng(); | ||
| return challenge || randomTarget(wordLength); | ||
| return challenge || randomTarget(wordLength, props.difficulty); | ||
| }); | ||
| const [gameNumber, setGameNumber] = useState(1); | ||
| const tableRef = useRef<HTMLTableElement>(null); | ||
|
|
@@ -92,7 +94,7 @@ function Game(props: GameProps) { | |
| const newWordLength = | ||
| wordLength < minWordLength || wordLength > maxWordLength ? 5 : wordLength; | ||
| setWordLength(newWordLength); | ||
| setTarget(randomTarget(newWordLength)); | ||
| setTarget(randomTarget(newWordLength, props.difficulty)); | ||
| setGuesses([]); | ||
| setCurrentGuess(""); | ||
| setHint(""); | ||
|
|
@@ -145,7 +147,9 @@ function Game(props: GameProps) { | |
| setHint("Too short"); | ||
| return; | ||
| } | ||
| if (!dictionary.includes(currentGuess)) { | ||
|
|
||
| // Baby will short circuit to false | ||
| if (props.difficulty && !dictionary.includes(currentGuess)) { | ||
|
dskunkler marked this conversation as resolved.
Outdated
|
||
| setHint("Not a valid word"); | ||
| return; | ||
| } | ||
|
|
@@ -246,7 +250,7 @@ function Game(props: GameProps) { | |
| setGameState(GameState.Playing); | ||
| setGuesses([]); | ||
| setCurrentGuess(""); | ||
| setTarget(randomTarget(length)); | ||
| setTarget(randomTarget(length, props.difficulty)); | ||
| setWordLength(length); | ||
| setHint(`${length} letters`); | ||
| }} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| import dictionary from "./dictionary.json"; | ||
|
|
||
| export enum Difficulty { | ||
| Baby, | ||
| Easy, | ||
| Normal, | ||
| Hard, | ||
| UltraHard, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tried this, but I think this line with the 3 old difficulty values is probably a mistake. As the line above has the new 5. So I guess this line will show them twice in the modes > Easy.
By the way, I guess the
4 lines above was not needed before, and I guess is still not needed. Or does this solve a separate issue?