Skip to content
/ sanuli Public

A finnish version of a popular word guessing game, written in Rust.

License

Notifications You must be signed in to change notification settings

Cadiac/sanuli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sanuli

Sponsored Netlify Status

Sanuli

A finnish version of a popular word guessing game implemented in Rust.

Live version running at sanuli.fi.

Quick start

Follow Rust installation instructions.

To build the WASM based yew UI, further wasm tooling is required

rustup target add wasm32-unknown-unknown
cargo install --locked trunk
cargo install wasm-bindgen-cli

Create word list files and populate them with uppercase words, one per line

touch common-words.txt
touch daily-words.txt
touch full-words.txt
touch profanities.txt
touch easy-words.txt

Start the UI in development mode

trunk serve

Word lists

Four separate word list files in the root of this project containing all the words are required. The lists are not included in this repository.

The lists are:

  • full-words.txt - Full list of all accepted 5 and 6 character words. The checks if a word real or not is done against this list
  • daily-words.txt - List of daily words. The daily word is taken from row equal to the days from 2022-01-07.
  • common-words.txt - Subset of the full words list, intended for the default game mode. Note that all these words must exist on the full-words.txt
  • easy-words.txt - Subset of the full words list, intended for easier game mode. Note that all these words must exist on the full-words.txt
  • profanities.txt - Words filtered out when profanities filter is enabled

Beware that these are included in the release binary, and anyone can obtain the lists!

Generating base word lists

To create a word list, a dictionary like the "nykysuomen sanalista" by Kotus, licensed with CC BY 3.0, can be used as a baseline to build from.

A parser for parsing kotus-sanalista_v1.xml file from Kotus is included:

cargo run --bin parse-kotus-word-list your/path/to/kotus-sanalista_v1.xml

which creates a full-words-generated.txt file in the working directory.

Development

NOTE: Rust flag --cfg=web_sys_unstable_apis is required for copying to clipboard to work. Clipboard API also only works in HTTPS context.

To set the flag manually with environment variables, run:

export RUSTFLAGS=--cfg=web_sys_unstable_apis

You can ignore this at manual development (as the clipboard API won't work without HTTPS anywaays) or run your trunk commands with it set.

For normal development, start the web server with

trunk serve

This should make the UI available at 0.0.0.0:8080 with hot reload on code changes.

To change the default port, use

trunk serve --port=9090

Release build

Pass the rust flags for building clipboard features & strip your home library paths from the binary.

RUSTFLAGS="--cfg=web_sys_unstable_apis --remap-path-prefix $HOME=~" trunk build --release

and copy the produced dist directory to your target server.

Optimizing .wasm binary size

The .wasm binary is quite large, as it includes the full word lists and bunch of code. wasm-opt from binaryen tools can be to optimized to further reduce the size of the binary.

wasm-opt -Os -o output.wasm input.wasm

replacing the input and output files with your binary name, ie. dist/index-fea16a946b74a1d4_bg.wasm.

Some automation for this should be made.

About

A finnish version of a popular word guessing game, written in Rust.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published