Git Product home page Git Product logo

sanuli's Introduction

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.

sanuli's People

Contributors

cadiac avatar androidkotlindev avatar jtakalai avatar peritpatrio avatar ple21108 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.