Compare commits
10
Commits
4ed16d404f
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1f14a5bba
|
||
|
|
0cad77fb39
|
||
|
|
14e22db8ec
|
||
|
|
a827bd5eef
|
||
|
|
911ae77516
|
||
|
|
6707364251
|
||
|
|
9b34a045fa
|
||
|
|
5ea156c181
|
||
|
|
46e977acf5
|
||
|
|
6e6e1b67ec
|
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REGISTRY="${REGISTRY#https://}"
|
||||
REGISTRY="${REGISTRY#http://}"
|
||||
REGISTRY="${REGISTRY%/}"
|
||||
|
||||
IMAGE="${REGISTRY}/${REPOSITORY}:${TAG}"
|
||||
|
||||
echo "Pushing ${IMAGE}"
|
||||
|
||||
skopeo copy \
|
||||
--dest-creds "${USERNAME}:${PASSWORD}" \
|
||||
"docker-archive:result" \
|
||||
"docker://${IMAGE}"
|
||||
|
||||
if [ "${REF_NAME:-}" = "main" ]; then
|
||||
skopeo copy \
|
||||
--dest-creds "${USERNAME}:${PASSWORD}" \
|
||||
"docker-archive:result" \
|
||||
"docker://${REGISTRY}/${REPOSITORY}:latest"
|
||||
fi
|
||||
@@ -0,0 +1,47 @@
|
||||
name: Build docker images.
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
build-wordle-solver-image:
|
||||
runs-on: nixos
|
||||
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build wordle-solver image
|
||||
run: |
|
||||
nix build .#wordle-solver-docker
|
||||
|
||||
- name: Push image
|
||||
env:
|
||||
REGISTRY: "${{ gitea.server_url }}"
|
||||
REPOSITORY: "${{ gitea.repository }}"
|
||||
USERNAME: "${{ secrets.REGISTRY_USER }}"
|
||||
PASSWORD: "${{ secrets.REGISTRY_TOKEN }}"
|
||||
REF_NAME: "${{ gitea.ref_name }}"
|
||||
TAG: "${{ gitea.sha }}"
|
||||
run: bash .gitea/scripts/push-image.sh
|
||||
|
||||
build-wordle-solver-web-image:
|
||||
runs-on: nixos
|
||||
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build wordle-solver-web image
|
||||
run: |
|
||||
nix build .#wordle-solver-web-docker
|
||||
|
||||
- name: Push image
|
||||
env:
|
||||
REGISTRY: "${{ gitea.server_url }}"
|
||||
REPOSITORY: "${{ gitea.repository }}-web"
|
||||
USERNAME: "${{ secrets.REGISTRY_USER }}"
|
||||
PASSWORD: "${{ secrets.REGISTRY_TOKEN }}"
|
||||
REF_NAME: "${{ gitea.ref_name }}"
|
||||
TAG: "${{ gitea.sha }}"
|
||||
run: bash .gitea/scripts/push-image.sh
|
||||
@@ -0,0 +1,60 @@
|
||||
# Wordle Solver
|
||||
|
||||
This wordle solver uses an information theory based approach to evaluate the next-best-guess. It's heavily inspired by [3b1b's approach](https://www.youtube.com/watch?v=v68zYyaEmEA) on solving wordle.
|
||||
|
||||
There are two ways to use the wordle-solver.
|
||||
|
||||
1. a CLI tool
|
||||
2. a web interface
|
||||
|
||||
|
||||
# Docker
|
||||
|
||||
#### CLI
|
||||
```sh
|
||||
docker run --rm -it git.jroeger.de/jonas/wordle-solver-rs
|
||||
```
|
||||
|
||||
#### web
|
||||
``` sh
|
||||
docker run -p 8080:80 --rm -it git.jroeger.de/jonas/wordle-solver-rs-web
|
||||
```
|
||||
|
||||
# Nix
|
||||
|
||||
#### CLI
|
||||
|
||||
``` sh
|
||||
nix run .
|
||||
```
|
||||
|
||||
#### Static web site
|
||||
|
||||
``` sh
|
||||
nix build git+http://git.jroeger.de/jonas/wordle-solver-rs#wordle-solver-web
|
||||
```
|
||||
|
||||
# Native
|
||||
|
||||
#### CLI
|
||||
|
||||
you will need to have `cargo` installed.
|
||||
|
||||
```sh
|
||||
cargo run --profile release
|
||||
```
|
||||
|
||||
#### web
|
||||
|
||||
you need the following tools:
|
||||
- `wasm-pack`
|
||||
- `wasm-bindgen`
|
||||
- `cargo`
|
||||
- `nodejs`
|
||||
- `yarn`
|
||||
|
||||
``` sh
|
||||
cd web
|
||||
yarn install
|
||||
yarn serve # or yarn build
|
||||
```
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
outputs = inputs @ {
|
||||
flake-parts,
|
||||
crate2nix,
|
||||
rust-overlay,
|
||||
...
|
||||
}:
|
||||
@@ -28,33 +27,24 @@
|
||||
"x86_64-linux"
|
||||
];
|
||||
|
||||
imports = [
|
||||
./nix/wasm-bindgen.nix
|
||||
./nix/wordle-solver-docker.nix
|
||||
./nix/wordle-solver-wasm-pkg.nix
|
||||
./nix/wordle-solver-wasm.nix
|
||||
./nix/wordle-solver-web-docker.nix
|
||||
./nix/wordle-solver-web.nix
|
||||
./nix/wordle-solver.nix
|
||||
];
|
||||
|
||||
perSystem = {
|
||||
pkgs,
|
||||
system,
|
||||
self',
|
||||
...
|
||||
}: let
|
||||
# Use rust-bin to generate the toolchain from rust-toolchain.toml
|
||||
rust-toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
|
||||
cross-pkgs = pkgs.pkgsCross.wasm32-unknown-none;
|
||||
|
||||
toolchain = pkgs.callPackage ./nix/with-toolchain.nix {
|
||||
cargo = rust-toolchain;
|
||||
rustc = rust-toolchain;
|
||||
};
|
||||
crossToolchain = cross-pkgs.callPackage ./nix/with-toolchain.nix {
|
||||
cargo = rust-toolchain;
|
||||
rustc = rust-toolchain;
|
||||
};
|
||||
|
||||
wasm-bindgen = toolchain.pkgs.callPackage ./nix/wasm-bindgen.nix {};
|
||||
|
||||
root-crate = pkgs.callPackage ./nix/root-crate.nix {
|
||||
cargo = rust-toolchain;
|
||||
rustc = rust-toolchain;
|
||||
inherit crate2nix;
|
||||
};
|
||||
utils = import ./nix/utils.nix;
|
||||
rust-toolchain = utils.rust-toolchain pkgs;
|
||||
in {
|
||||
# Overlay pkgs with rust-bin
|
||||
_module.args.pkgs = import inputs.nixpkgs {
|
||||
@@ -63,22 +53,13 @@
|
||||
config.allowUnsupportedSystem = true;
|
||||
};
|
||||
|
||||
packages = {
|
||||
wordle-solver-web = pkgs.callPackage ./nix/wordle-solver-web.nix {inherit (self'.packages) wordle-solver-wasm-pkg;};
|
||||
wordle-solver-wasm = crossToolchain.pkgs.callPackage ./nix/wordle-solver-wasm.nix {};
|
||||
wordle-solver-wasm-pkg = pkgs.callPackage ./nix/wordle-solver-wasm-pkg.nix {
|
||||
inherit wasm-bindgen root-crate;
|
||||
inherit (self'.packages) wordle-solver-wasm;
|
||||
};
|
||||
wordle-solver = root-crate.build;
|
||||
default = self'.packages.wordle-solver;
|
||||
};
|
||||
packages.default = self'.packages.wordle-solver;
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
RA_LOG = "rust_analyzer=info";
|
||||
buildInputs = [
|
||||
rust-toolchain
|
||||
wasm-bindgen
|
||||
self'.packages.wasm-bindgen
|
||||
pkgs.nodejs
|
||||
pkgs.svelte-language-server
|
||||
pkgs.typescript-language-server
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
crate2nix,
|
||||
rustc,
|
||||
cargo,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
buildRustCrateForPkgs = _:
|
||||
pkgs.buildRustCrate.override {
|
||||
inherit cargo rustc;
|
||||
};
|
||||
|
||||
# Cargo.nix for IFD
|
||||
generatedCargoNix = crate2nix.tools.${pkgs.hostPlatform.system}.generatedCargoNix {
|
||||
name = "rustnix";
|
||||
src = ../.;
|
||||
};
|
||||
|
||||
cargoNix = import generatedCargoNix {
|
||||
inherit pkgs buildRustCrateForPkgs;
|
||||
};
|
||||
in
|
||||
cargoNix.rootCrate
|
||||
@@ -0,0 +1,21 @@
|
||||
rec {
|
||||
rust-toolchain = pkgs: pkgs.rust-bin.fromRustupToolchainFile ../rust-toolchain.toml;
|
||||
|
||||
toolchain-pkgs = pkgs:
|
||||
pkgs.extend (_: _: {
|
||||
rustPlatform = pkgs.makeRustPlatform {
|
||||
cargo = rust-toolchain pkgs;
|
||||
rustc = rust-toolchain pkgs;
|
||||
};
|
||||
});
|
||||
|
||||
toolchain-crosspkgs = pkgs: let
|
||||
crossPkgs = pkgs.pkgsCross.wasm32-unknown-none;
|
||||
in
|
||||
crossPkgs.extend (_: _: {
|
||||
rustPlatform = crossPkgs.makeRustPlatform {
|
||||
cargo = rust-toolchain pkgs;
|
||||
rustc = rust-toolchain pkgs;
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
let
|
||||
drv = {
|
||||
fetchCrate,
|
||||
buildWasmBindgenCli,
|
||||
rustPlatform,
|
||||
@@ -16,4 +17,11 @@ buildWasmBindgenCli rec {
|
||||
inherit (src) pname version;
|
||||
hash = "sha256-FTv2GZIAQs0ePdIZXIXil7JbZ6kIT05VG6vqC1qNFxQ=";
|
||||
};
|
||||
};
|
||||
|
||||
utils = import ./utils.nix;
|
||||
in {
|
||||
perSystem = {pkgs, ...}: {
|
||||
packages.wasm-bindgen = (utils.toolchain-pkgs pkgs).callPackage drv {};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
makeRustPlatform,
|
||||
cargo,
|
||||
rustc,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
p = pkgs;
|
||||
in rec {
|
||||
rustPlatform = makeRustPlatform {
|
||||
inherit cargo rustc;
|
||||
};
|
||||
pkgs = p.extend (_: _: {
|
||||
inherit rustPlatform;
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
let
|
||||
drv = {
|
||||
buildEnv,
|
||||
dockerTools,
|
||||
wordle-solver,
|
||||
runCommand,
|
||||
...
|
||||
}:
|
||||
dockerTools.buildImage {
|
||||
name = "wordle-solver";
|
||||
created = "now";
|
||||
copyToRoot = buildEnv {
|
||||
name = "image-root";
|
||||
paths = [
|
||||
wordle-solver
|
||||
(runCommand "wordle-data" {} ''
|
||||
mkdir -p $out/pwd
|
||||
cp ${../valid-words.txt} $out/pwd/valid-words.txt
|
||||
cp ${../answers.txt} $out/pwd/answers.txt
|
||||
'')
|
||||
];
|
||||
pathsToLink = ["/bin" "/pwd"];
|
||||
};
|
||||
config = {
|
||||
Cmd = ["/bin/wordle-solver"];
|
||||
WorkingDir = "/pwd";
|
||||
};
|
||||
};
|
||||
in {
|
||||
perSystem = {
|
||||
pkgs,
|
||||
self',
|
||||
...
|
||||
}: {
|
||||
packages.wordle-solver-docker = pkgs.callPackage drv {
|
||||
inherit (self'.packages) wordle-solver;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
{
|
||||
perSystem = {
|
||||
pkgs,
|
||||
self',
|
||||
...
|
||||
}: let
|
||||
drv = {
|
||||
stdenvNoCC,
|
||||
wasm-bindgen,
|
||||
wordle-solver-wasm,
|
||||
root-crate,
|
||||
...
|
||||
}: let
|
||||
snake_name = "wordle_solver";
|
||||
@@ -10,7 +15,7 @@
|
||||
name = "wordle-solver";
|
||||
type = "module";
|
||||
description = "module";
|
||||
version = root-crate.build.crateVersion;
|
||||
version = "0.1.0";
|
||||
files = [
|
||||
"${snake_name}_bg.wasm"
|
||||
"${snake_name}.js"
|
||||
@@ -36,4 +41,10 @@ in
|
||||
${package-json}
|
||||
EOF
|
||||
'';
|
||||
};
|
||||
in {
|
||||
packages.wordle-solver-wasm-pkg = pkgs.callPackage drv {
|
||||
inherit (self'.packages) wordle-solver-wasm wasm-bindgen;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
{
|
||||
perSystem = {pkgs, ...}: let
|
||||
utils = import ./utils.nix;
|
||||
rust-toolchain = utils.rust-toolchain pkgs;
|
||||
toolchain-crosspkgs = utils.toolchain-crosspkgs pkgs;
|
||||
drv = {
|
||||
rustPlatform,
|
||||
buildPackages,
|
||||
lld,
|
||||
name ? "wordle-solver",
|
||||
removeReferencesTo,
|
||||
...
|
||||
}:
|
||||
rustPlatform.buildRustPackage {
|
||||
@@ -19,6 +25,7 @@ rustPlatform.buildRustPackage {
|
||||
buildPackages.stdenv.cc
|
||||
lld # Needed for wasm-ld
|
||||
];
|
||||
nativeBuildInputs = [removeReferencesTo];
|
||||
|
||||
cargoBuildFlags = [
|
||||
"--lib"
|
||||
@@ -27,13 +34,23 @@ rustPlatform.buildRustPackage {
|
||||
];
|
||||
|
||||
# Configure rustc for WASM
|
||||
env = {
|
||||
RUSTFLAGS = ''--cfg=web_sys_unstable_apis -C linker=wasm-ld'';
|
||||
};
|
||||
RUSTFLAGS = ''--cfg=web_sys_unstable_apis -C linker=wasm-ld -C strip=debuginfo -C debuginfo=0'';
|
||||
|
||||
# Copy the WASM file to the output
|
||||
installPhase = ''
|
||||
mkdir -p $out/lib
|
||||
cp target/wasm32-unknown-unknown/release/*.wasm $out/lib/
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
# Remove toolchain from closure (store paths are debug artifacts)
|
||||
postInstall = ''
|
||||
remove-references-to -t ${rust-toolchain} $out/lib/*.wasm
|
||||
'';
|
||||
};
|
||||
in {
|
||||
packages.toolchain = rust-toolchain;
|
||||
packages.wordle-solver-wasm = toolchain-crosspkgs.callPackage drv {};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
let
|
||||
drv = {
|
||||
buildEnv,
|
||||
dockerTools,
|
||||
fakeNss,
|
||||
nginx,
|
||||
runCommand,
|
||||
wordle-solver-web,
|
||||
...
|
||||
}:
|
||||
dockerTools.buildImage {
|
||||
name = "wordle-solver-web";
|
||||
created = "now";
|
||||
copyToRoot = buildEnv {
|
||||
name = "image-root";
|
||||
paths = [
|
||||
nginx
|
||||
(fakeNss.override {
|
||||
extraGroupLines = [
|
||||
"nogroup:x:65534:"
|
||||
];
|
||||
})
|
||||
(runCommand "nginx-conf" {} ''
|
||||
mkdir -p $out/etc
|
||||
|
||||
cat <<EOF > $out/etc/nginx.conf
|
||||
events {}
|
||||
|
||||
error_log /dev/stderr;
|
||||
|
||||
http {
|
||||
include ${nginx}/conf/mime.types;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
root ${wordle-solver-web};
|
||||
access_log /dev/stdout;
|
||||
}
|
||||
}
|
||||
|
||||
daemon off;
|
||||
EOF
|
||||
'')
|
||||
];
|
||||
pathsToLink = ["/etc"];
|
||||
};
|
||||
runAsRoot = ''
|
||||
mkdir -p /var/log/nginx
|
||||
'';
|
||||
config = {
|
||||
Cmd = ["${nginx}/bin/nginx" "-c" "/etc/nginx.conf"];
|
||||
};
|
||||
};
|
||||
in {
|
||||
perSystem = {
|
||||
pkgs,
|
||||
self',
|
||||
...
|
||||
}: {
|
||||
packages.wordle-solver-web-docker = pkgs.callPackage drv {
|
||||
inherit (self'.packages) wordle-solver-web;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,10 @@
|
||||
{
|
||||
perSystem = {
|
||||
pkgs,
|
||||
self',
|
||||
...
|
||||
}: let
|
||||
drv = {
|
||||
stdenv,
|
||||
fetchYarnDeps,
|
||||
yarnConfigHook,
|
||||
@@ -14,7 +20,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
|
||||
yarnOfflineCache = fetchYarnDeps {
|
||||
yarnLock = finalAttrs.src + "/yarn.lock";
|
||||
hash = "sha256-okhACATsv6jqUrbvoRN+PTTc3FbqDT7iocnL6lr7R70=";
|
||||
hash = "sha256-MTyHX2+/U7jRB1SJWbK9Td43zq+nclQwx7oDZbX0DqA=";
|
||||
};
|
||||
|
||||
yarnBuildScript = "build-no-wasm";
|
||||
@@ -34,4 +40,10 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
# Needed for executing package.json scripts
|
||||
nodejs
|
||||
];
|
||||
})
|
||||
});
|
||||
in {
|
||||
packages.wordle-solver-web = pkgs.callPackage drv {
|
||||
inherit (self'.packages) wordle-solver-wasm-pkg;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
{inputs, ...}: {
|
||||
perSystem = {pkgs, ...}: let
|
||||
# Cargo.nix for IFD
|
||||
generatedCargoNix = inputs.crate2nix.tools.${pkgs.hostPlatform.system}.generatedCargoNix {
|
||||
name = "rustnix";
|
||||
src = ../.;
|
||||
};
|
||||
|
||||
utils = import ./utils.nix;
|
||||
|
||||
rust-toolchain = utils.rust-toolchain pkgs;
|
||||
toolchain-pkgs = utils.toolchain-pkgs pkgs;
|
||||
|
||||
buildRustCrateForPkgs = _:
|
||||
pkgs.buildRustCrate.override {
|
||||
cargo = rust-toolchain;
|
||||
rustc = rust-toolchain;
|
||||
};
|
||||
|
||||
cargoNix = import generatedCargoNix {
|
||||
pkgs = toolchain-pkgs;
|
||||
inherit buildRustCrateForPkgs;
|
||||
};
|
||||
in {
|
||||
packages.wordle-solver = cargoNix.rootCrate.build;
|
||||
};
|
||||
}
|
||||
+4
-1
@@ -4,18 +4,20 @@
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"serve": "run-s wasm-pack:release vite:serve",
|
||||
"build-no-wasm": "run-s tsc vite:build",
|
||||
"build": "run-s wasm-pack:release tsc vite:build",
|
||||
"dev": "run-s wasm-pack:dev vite:dev",
|
||||
"tsc": "tsc",
|
||||
"vite:build": "vite build",
|
||||
"vite:dev": "vite -c vite.config.dev.ts",
|
||||
"vite:preview": "vite preview",
|
||||
"vite:serve": "vite -c vite.config.ts",
|
||||
"wasm-pack:dev": "rm -rf pkg; wasm-pack build --dev --features wasm-bindgen --manifest-path ../Cargo.toml; mv ../pkg .",
|
||||
"wasm-pack:release": "rm -rf pkg; wasm-pack build --features wasm-bindgen --manifest-path ../Cargo.toml; mv ../pkg ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^7.3.0",
|
||||
"@tailwindcss/typography": "^0.5.20",
|
||||
"@tailwindcss/vite": "^4.3.3",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"tailwindcss": "^4.3.3",
|
||||
@@ -26,6 +28,7 @@
|
||||
"vite-plugin-wasm-pack-watcher": "^1.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@humanspeak/svelte-markdown": "^1.8.7",
|
||||
"@lucide/svelte": "^1.33.0",
|
||||
"esbuild": "^0.28.2",
|
||||
"katex": "^0.18.4",
|
||||
|
||||
+58
-1
@@ -13,9 +13,11 @@
|
||||
EvaluateWordsResult,
|
||||
EvaluateWordsProgress,
|
||||
} from "./solver/types.ts";
|
||||
import info_md from "./assets/info.md?raw";
|
||||
import SolverOutput from "./components/SolverOutput.svelte";
|
||||
import { FolderGit2 } from "@lucide/svelte";
|
||||
import { CircleX, FolderGit2, Info } from "@lucide/svelte";
|
||||
import { tick, onMount } from "svelte";
|
||||
import SvelteMarkdown from "@humanspeak/svelte-markdown";
|
||||
|
||||
let guesses = $state([
|
||||
{
|
||||
@@ -30,6 +32,8 @@
|
||||
},
|
||||
]);
|
||||
|
||||
let show_info = $state(false);
|
||||
|
||||
let infos_gained: (Promise<GuessResult> | null)[] = $state([null]);
|
||||
|
||||
let use_default_wordle_answers: boolean = $state(true);
|
||||
@@ -166,6 +170,15 @@
|
||||
>
|
||||
<FolderGit2 />
|
||||
</a>
|
||||
<a
|
||||
class="fixed top-4 left-4"
|
||||
onclick={() => {
|
||||
show_info = true;
|
||||
}}
|
||||
>
|
||||
<Info />
|
||||
</a>
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="mb-4 text-3xl font-bold">Wordle Solver</h1>
|
||||
|
||||
@@ -244,6 +257,50 @@
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if show_info}
|
||||
<div
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-black/60"
|
||||
tabindex="-1"
|
||||
role="button"
|
||||
onclick={() => (show_info = false)}
|
||||
onkeydown={() => (show_info = false)}
|
||||
>
|
||||
<div
|
||||
class="relative flex flex-col
|
||||
rounded-lg
|
||||
bg-zinc-900
|
||||
p-6 shadow-xl
|
||||
md:max-w-[75vw]
|
||||
md:max-h-[75vh]
|
||||
max-w-[calc(100vw-3rem)]
|
||||
max-h-[calc(100vh-3rem)]
|
||||
overflow-hidden"
|
||||
tabindex="0"
|
||||
role="dialog"
|
||||
onclick={(e) => e.stopPropagation()}
|
||||
onkeydown={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div
|
||||
class="absolute top-4 right-4"
|
||||
tabindex="-1"
|
||||
role="button"
|
||||
onclick={() => (show_info = false)}
|
||||
onkeydown={() => (show_info = false)}
|
||||
>
|
||||
<CircleX />
|
||||
</div>
|
||||
<div
|
||||
class="prose prose-invert max-w-none
|
||||
h-full
|
||||
overflow-y-auto
|
||||
overflow-x-hidden"
|
||||
>
|
||||
<SvelteMarkdown source={info_md} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@import "tailwindcss";
|
||||
@plugin "@tailwindcss/typography";
|
||||
|
||||
html,
|
||||
body {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
# Wordle Solver
|
||||
|
||||
This wordle solver uses an information theory based approach to
|
||||
evaluate the next-best-guess. It's heavily inspired by [3b1b's approach](https://www.youtube.com/watch?v=v68zYyaEmEA)
|
||||
on solving wordle.
|
||||
|
||||
## How to use?
|
||||
|
||||
You can run the solver at any time to tell you five best next guesses (ranked).
|
||||
However when the solver has no information this can take quite some time. So it's
|
||||
best to make your first guess (e.g. "CRANE", "SALES", ...):
|
||||
|
||||
1. Once your wordle game gave you an answer, type it into the interface:
|
||||
|
||||
- type letters to input them
|
||||
- click a cell to change it's color (or cycle it with <Space>)
|
||||
|
||||
2. To give the solver the information of your guess press enter (or the little enter icon next to the line)
|
||||
|
||||
3. The solver will tell you the amount of information gained by this guess.
|
||||
|
||||
4. Run the solver to get a new next-best-guess and repeat until you found the answer
|
||||
|
||||
## Solution Space
|
||||
|
||||
The solution space is by default the list of possible wordle-answers (uncheck the box to use all valid words as possible answers).
|
||||
Above your inputs you can see how many possible answers are still left given your guesses with a value of
|
||||
remaining uncertainty in bits (how many yes-no questions are required to identify an item in the equally distributed set).
|
||||
The goal is to reach 0bits of uncertainty, meaning one word left.
|
||||
|
||||
Sometimes when adding a guess there may appear an error symbol. This occurrs when the guess would empty
|
||||
the solution space. This can only happen if the solution space did not contain the solution of your wordle game (or there some inconsistencies in the guesses).
|
||||
In this case you might wanna allow all valid words as possible answers.
|
||||
|
||||
|
||||
## The Solver's output
|
||||
|
||||
- p(x) is the probability, that the word is actually the solution.
|
||||
Often it will be 0, because the word is not a possible solution anymore.
|
||||
If so, the expected information of guessing this that high, that it is worth guessing it.
|
||||
|
||||
- E\[Inf.\] The expected information to gain when guessing this word. (I.e. by how much do we expect to shrink the solution space?)
|
||||
|
||||
- E\[Score.\] The expected number of guesses required to solve the wordle when you guess this word now. It's based on a heuristic combination
|
||||
of the current score, p(x) and E\[Inf.\].
|
||||
@@ -24,7 +24,20 @@
|
||||
on_guess_pressed: (() => void) | null;
|
||||
} = $props();
|
||||
|
||||
let invalid: boolean = $state(false);
|
||||
let inputs: HTMLInputElement[] = $state([]);
|
||||
let info_gained_wrapped: Promise<GuessResult> | null = $state(null);
|
||||
|
||||
$effect(() => {
|
||||
if (info_gained) {
|
||||
info_gained_wrapped = info_gained.catch((e) => {
|
||||
invalid = true;
|
||||
throw e;
|
||||
});
|
||||
} else {
|
||||
info_gained_wrapped = null;
|
||||
}
|
||||
});
|
||||
|
||||
export function focus() {
|
||||
inputs[cursor].focus();
|
||||
@@ -86,6 +99,7 @@
|
||||
class:bg-green-600={colors[i] === Color.GREEN}
|
||||
class:bg-yellow-600={colors[i] === Color.YELLOW}
|
||||
class:bg-grey-600={colors[i] === Color.GREY}
|
||||
class:opacity-20={invalid}
|
||||
onblur={() => {
|
||||
cursor = -1;
|
||||
}}
|
||||
@@ -123,10 +137,10 @@
|
||||
class="max-w-14 w-1/6 text-sm text-zinc-500 self-center flex items-center justify-center"
|
||||
onclick={info_gained === null ? on_guess_pressed : null}
|
||||
>
|
||||
{#if info_gained === null}
|
||||
{#if info_gained_wrapped === null}
|
||||
↵
|
||||
{:else}
|
||||
{#await info_gained}
|
||||
{#await info_gained_wrapped}
|
||||
<div
|
||||
class="size-3 animate-spin rounded-full border-2 border-gray-300 border-t-gray-700"
|
||||
></div>
|
||||
|
||||
@@ -154,6 +154,21 @@
|
||||
resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz#b21affb804cc167c133d95f45b3a1dc1323b9a87"
|
||||
integrity sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==
|
||||
|
||||
"@humanspeak/memory-cache@^1.1.2":
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@humanspeak/memory-cache/-/memory-cache-1.1.2.tgz#2bd14a51782b30232fb544dab54fc20efb0171a8"
|
||||
integrity sha512-6kmeqrCVThw4RYZsJ74l9cOdZQ84XHnGIzrv+Po49CZBNNVDEzi0CGsTx+KKmr/Hb6hY6yDGxeWTiz4VHkdsEg==
|
||||
|
||||
"@humanspeak/svelte-markdown@^1.8.7":
|
||||
version "1.8.7"
|
||||
resolved "https://registry.yarnpkg.com/@humanspeak/svelte-markdown/-/svelte-markdown-1.8.7.tgz#30f21678adf8434ac35f22c8cdd4ddf0666ee08c"
|
||||
integrity sha512-IJFFF7QuKytGBIDy/fp8xeAxMjuFfV1rt3H8t6kjDlIckVTwCTD6WPFIbirlgeingOdD6j4U6Ox8aHu0YTe2Xw==
|
||||
dependencies:
|
||||
"@humanspeak/memory-cache" "^1.1.2"
|
||||
github-slugger "^2.0.0"
|
||||
htmlparser2 "^12.0.0"
|
||||
marked "^18.0.9"
|
||||
|
||||
"@jridgewell/gen-mapping@^0.3.5":
|
||||
version "0.3.13"
|
||||
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz#6342a19f44347518c93e43b1ac69deb3c4656a1f"
|
||||
@@ -626,6 +641,13 @@
|
||||
"@tailwindcss/oxide-win32-arm64-msvc" "4.3.3"
|
||||
"@tailwindcss/oxide-win32-x64-msvc" "4.3.3"
|
||||
|
||||
"@tailwindcss/typography@^0.5.20":
|
||||
version "0.5.20"
|
||||
resolved "https://registry.yarnpkg.com/@tailwindcss/typography/-/typography-0.5.20.tgz#9feb7fb1d5f2f7b5360c22e24651210db74c34df"
|
||||
integrity sha512-hwbzQuNUfcPvbegQFatVPl/MY/tcM9KLl963hQ5laJKPh81TEZ1+dNG9PirGvcaDBkp+BCshExAyKVPW91dozw==
|
||||
dependencies:
|
||||
postcss-selector-parser "6.0.10"
|
||||
|
||||
"@tailwindcss/vite@^4.3.3":
|
||||
version "4.3.3"
|
||||
resolved "https://registry.yarnpkg.com/@tailwindcss/vite/-/vite-4.3.3.tgz#1f4037badcb5e6c6bb574d3d8a0172c83f26b97f"
|
||||
@@ -793,6 +815,11 @@ cross-spawn@^6.0.5:
|
||||
shebang-command "^1.2.0"
|
||||
which "^1.2.9"
|
||||
|
||||
cssesc@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-3.0.0.tgz#37741919903b868565e1c09ea747445cd18983ee"
|
||||
integrity sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==
|
||||
|
||||
data-view-buffer@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/data-view-buffer/-/data-view-buffer-1.0.2.tgz#211a03ba95ecaf7798a8c7198d79536211f88570"
|
||||
@@ -853,6 +880,36 @@ devalue@^5.8.1:
|
||||
resolved "https://registry.yarnpkg.com/devalue/-/devalue-5.9.0.tgz#5d30db41a0db9171cf4ee9dbf6617e0b77cd7c2a"
|
||||
integrity sha512-RWrqdArjvPbsATEhOPUo6Wndc/iWnkWKlhIrdlF3zMMYo/c3CVtoaVAyLtWxz5h8nSlkHzxnzV2uLydPXmtF+A==
|
||||
|
||||
dom-serializer@^3.0.0:
|
||||
version "3.1.1"
|
||||
resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-3.1.1.tgz#54be70ee4fcc2da010f488165e62294798dc57d3"
|
||||
integrity sha512-4MEa38/QexBob6gFNwu+EGdWvhJ1OKuNwdYY3Y3NyeWDQfnGeDYQUDfIRzWu5B5gsv03so2Uxd28YC6zrsx3Lw==
|
||||
dependencies:
|
||||
domelementtype "^3.0.0"
|
||||
domhandler "^6.0.0"
|
||||
entities "^8.0.0"
|
||||
|
||||
domelementtype@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-3.0.0.tgz#e6c0a24bd39ca5eb7ea67a98d2f699497d7bcc55"
|
||||
integrity sha512-umCQid3jKbDmVjx8jGaW7uUykm4DEUeyV21hPxNMo2nV955DhUThwqyOIDtreepP31hl84X7G5U9ZfsWvIB3Pg==
|
||||
|
||||
domhandler@^6.0.0:
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-6.0.1.tgz#75f351a03a6e10c35e08418f9cf0d287e00797cf"
|
||||
integrity sha512-gYzvtM72ZtxQO0T048kd6HWSbbGCNOUwcnfQ01cqIJ4X2IYKFFHZ5mKvrQETcFXxsRObZulDaKmy//R7TPtsBg==
|
||||
dependencies:
|
||||
domelementtype "^3.0.0"
|
||||
|
||||
domutils@^4.0.2:
|
||||
version "4.0.2"
|
||||
resolved "https://registry.yarnpkg.com/domutils/-/domutils-4.0.2.tgz#0c1ac1fdbe8f554a60a6f5eb143ee85630327c94"
|
||||
integrity sha512-qI4JLRKnSzqFqr7hAlS5xQDusBCjKSEG4t4+7aNrIQMHBcsC2TGEhuyABJdYkgSewL57PNLYEiibY2iPKhKpaA==
|
||||
dependencies:
|
||||
dom-serializer "^3.0.0"
|
||||
domelementtype "^3.0.0"
|
||||
domhandler "^6.0.0"
|
||||
|
||||
dunder-proto@^1.0.0, dunder-proto@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/dunder-proto/-/dunder-proto-1.0.1.tgz#d7ae667e1dc83482f8b70fd0f6eefc50da30f58a"
|
||||
@@ -870,6 +927,11 @@ enhanced-resolve@^5.24.1:
|
||||
graceful-fs "^4.2.4"
|
||||
tapable "^2.3.3"
|
||||
|
||||
entities@^8.0.0:
|
||||
version "8.0.0"
|
||||
resolved "https://registry.yarnpkg.com/entities/-/entities-8.0.0.tgz#c1df5fe3602429747fa233d0dd26f142f0ce4743"
|
||||
integrity sha512-zwfzJecQ/Uej6tusMqwAqU/6KL2XaB2VZ2Jg54Je6ahNBGNH6Ek6g3jjNCF0fG9EWQKGZNddNjU5F1ZQn/sBnA==
|
||||
|
||||
error-ex@^1.3.1:
|
||||
version "1.3.4"
|
||||
resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.4.tgz#b3a8d8bb6f92eecc1629e3e27d3c8607a8a32414"
|
||||
@@ -1115,6 +1177,11 @@ get-symbol-description@^1.1.0:
|
||||
es-errors "^1.3.0"
|
||||
get-intrinsic "^1.2.6"
|
||||
|
||||
github-slugger@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/github-slugger/-/github-slugger-2.0.0.tgz#52cf2f9279a21eb6c59dd385b410f0c0adda8f1a"
|
||||
integrity sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw==
|
||||
|
||||
globalthis@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/globalthis/-/globalthis-1.0.4.tgz#7430ed3a975d97bfb59bcce41f5cabbafa651236"
|
||||
@@ -1181,6 +1248,16 @@ hosted-git-info@^2.1.4:
|
||||
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"
|
||||
integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==
|
||||
|
||||
htmlparser2@^12.0.0:
|
||||
version "12.0.0"
|
||||
resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-12.0.0.tgz#6a679d0f57c525990f9cbad8a585b320ecc6d198"
|
||||
integrity sha512-Tz7u1i95/g2x2jz81+x0FBVhBhY5aRTvD3tXXdFaljuNdzDLJ8UGNRrTcj2cgQvAg3iW/h77Fz15nLW0L0CrZw==
|
||||
dependencies:
|
||||
domelementtype "^3.0.0"
|
||||
domhandler "^6.0.0"
|
||||
domutils "^4.0.2"
|
||||
entities "^8.0.0"
|
||||
|
||||
internal-slot@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.1.0.tgz#1eac91762947d2f7056bc838d93e13b2e9604961"
|
||||
@@ -1579,6 +1656,11 @@ magic-string@^1.0.0:
|
||||
dependencies:
|
||||
"@jridgewell/sourcemap-codec" "^1.5.5"
|
||||
|
||||
marked@^18.0.9:
|
||||
version "18.0.10"
|
||||
resolved "https://registry.yarnpkg.com/marked/-/marked-18.0.10.tgz#a09ac1f54e378b9efc8b31707adc188fdc047d2e"
|
||||
integrity sha512-FJeH4bRpYoXiggcgriCGItKCSv3xkngJc4QCZ/rkQCogU3VYaLxYJoZl8Nw/b4+x7iij/pd+09mZ6A1dXzpL0A==
|
||||
|
||||
math-intrinsics@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz#a0dd74be81e2aa5c2f27e65ce283605ee4e2b7f9"
|
||||
@@ -1718,6 +1800,14 @@ possible-typed-array-names@^1.0.0, possible-typed-array-names@^1.1.0:
|
||||
resolved "https://registry.yarnpkg.com/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz#93e3582bc0e5426586d9d07b79ee40fc841de4ae"
|
||||
integrity sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==
|
||||
|
||||
postcss-selector-parser@6.0.10:
|
||||
version "6.0.10"
|
||||
resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz#79b61e2c0d1bfc2602d549e11d0876256f8df88d"
|
||||
integrity sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==
|
||||
dependencies:
|
||||
cssesc "^3.0.0"
|
||||
util-deprecate "^1.0.2"
|
||||
|
||||
postcss@^8.5.25:
|
||||
version "8.5.26"
|
||||
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.5.26.tgz#6e75135780c7e10df3433bf2266c552d35c8c620"
|
||||
@@ -2155,6 +2245,11 @@ unbox-primitive@^1.1.0:
|
||||
has-symbols "^1.1.0"
|
||||
which-boxed-primitive "^1.1.1"
|
||||
|
||||
util-deprecate@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
|
||||
integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==
|
||||
|
||||
uuid@10.0.0:
|
||||
version "10.0.0"
|
||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-10.0.0.tgz#5a95aa454e6e002725c79055fd42aaba30ca6294"
|
||||
|
||||
Reference in New Issue
Block a user