Netskrafl - an Icelandic crossword game website

Overview

Netskrafl - an Icelandic crossword game website

Join the chat at https://gitter.im/Netskrafl/Lobby

English summary

This repository contains the implementation of an Icelandic crossword game in the genre of SCRABBLE(tm). The game, which is free-to-play, is accessible on the web at https://netskrafl.is.

Screenshot from mobile UI

The game backend is implemented in Python 3.8 for the Google App Engine Standard Environment.

The frontend is a tablet- and smartphone-friendly web client in HTML5 and JavaScript connecting via Ajax to a Flask-based web server on the backend.

The game contains a robot crossword player written in Python. The algorithm is based on Appel & Jacobson's classic paper "The World's Fastest Scrabble Program". At maximum strength level, the robot always plays the highest-scoring move possible but additional and alternative strategies can be plugged in relatively easily. At the lowest strength level, the robot is limited to a set of common words, about a quarter of the size of the entire word database.

The software has a range of features such as immediate tile-by-tile feedback on word validity and score, real-time synchronized games with clocks, Elo scoring of players, an online chat window, and the ability to view player track records.

The game uses a word database encoded in a Directed Acyclic Word Graph (DAWG). For Icelandic, the graph contains almost 2.3 million word forms. Further information about the DAWG implementation can be found in README.md in the Skrafl repository on GitHub.

The game mechanics are mostly found in skraflmechanics.py.

The robot player is implemented in skraflplayer.py.

The DAWG navigation code is in dawgdictionary.py.

Language-specific tile sets, bags and vocabularies are handled in languages.py.

The main Flask web server is in netskrafl.py.

The Game and User classes are found in skraflgame.py and skrafluser.py, respectively.

The persistence layer, using the schemaless App Engine NDB database, is in skrafldb.py.

The client JavaScript code is in static/netskrafl.js.

The various Flask HTML templates are found in templates/*.html.

The DAWG-compressed vocabularies are stored in resources/*.bin.dawg.

To build and run locally

Follow these steps:

  1. Install Python 3.8, possibly in a virtualenv.

  2. Download the Google App Engine SDK (GAE) for Python and follow the installation instructions.

  3. git clone https://github.com/mideind/Netskrafl to your GAE application directory.

  4. Run pip install -r requirements.txt in your virtualenv to install required Python packages so that they are accessible to GAE.

  5. Run python dawgbuilder.py to generate the DAWG *.bin.dawg files. This may take a couple of minutes.

  6. Create a secret session key for Flask in resources/secret_key.bin (see How to generate good secret keys, you need to scroll down to find the heading).

  7. Install Node.js if you haven't already. Run npm install to install Node dependencies.

  8. In a separate terminal window, but in the Netskrafl directory, run grunt make. Then run grunt to start watching changes of js and css files.

  9. Run either runserver.bat or runserver.sh.

Or, alternatively:

Run ./setup-dev.sh (tested on Debian based Linux and OS X).

Generating a new vocabulary file

To generate a new vocabulary file (ordalisti.full.sorted.txt), assuming you already have the BÍN database in PostgreSQL (here in table sigrunarsnid - remember to use the is_IS collation locale!), invoke psql, log in to your database and create the following view:

create or replace view skrafl as
   select stofn, utg, ordfl, fl, ordmynd, beyging from sigrunarsnid
   where ordmynd ~ '^[aábdðeéfghiíjklmnoóprstuúvxyýþæö]{3,15}$'
   and fl <> 'bibl'
   and not ((beyging like 'SP-%-FT') or (beyging like 'SP-%-FT2'))
   order by ordmynd;

To explain, this extracts all 3-15 letter word forms containing only Icelandic lowercase alphabetic characters, omitting the bibl (Biblical) category (which contains mostly obscure proper names and derivations thereof), and also omitting plural question forms (spurnarmyndir í fleirtölu).

Then, to generate the vocabulary file from the psql command line:

\copy (select distinct ordmynd from skrafl) to '/home/username/github/Netskrafl/resources/ordalisti.full.sorted.txt';

To extract only the subset of BÍN used by the robot Miðlungur, use the following view, assuming you have the Kristínarsnið form of BÍN in the table kristinarsnid containing the malsnid and einkunn columns:

create or replace view skrafl_midlungur as
	select stofn, utg, ordfl, fl, ordmynd, beyging
	from kristinarsnid
	where (malsnid is null or (malsnid <> ALL (ARRAY['SKALD', 'FORN', 'URE', 'STAD'])))
		and einkunn > 0;

You can then use the skrafl_midlungur view as the underlying table for the previous (vocabulary) query, replacing sigrunarsnid with skrafl_midlungur.

Original Author

Vilhjálmur Þorsteinsson, Reykjavík, Iceland.

Contact me via GitHub for queries or information regarding Netskrafl.

Please contact me if you have plans for using Netskrafl as a basis for your own game website and prefer not to operate under the conditions of the CC-BY-NC 4.0 license (see below).

License

Netskrafl - an Icelandic crossword game website

Copyright © 2021 Miðeind ehf.

This set of programs is licensed under the Creative Commons Attribution-NonCommercial 4.0 International Public License (CC-BY-NC 4.0).

The full text of the license is available here: https://creativecommons.org/licenses/by-nc/4.0/legalcode.

Included third party software

Netskrafl contains the DragDropTouch.js module by Bernardo Castilho, which is licensed under the MIT license as follows:

Copyright © 2016 Bernardo Castilho

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Netskrafl contains the jQuery UI Touch Punch library by David Furfero, which is licensed under the MIT license.

Copyright © 2011 David Furfero

The MIT license, as spelled out above, applies to this library.

Trademarks

SCRABBLE is a registered trademark. This software or its author are in no way affiliated with or endorsed by the owners or licensees of the SCRABBLE trademark.

Comments
  • Útreikningur á refsingu fyrir ónýtta stafi virðist vera rangur

    Útreikningur á refsingu fyrir ónýtta stafi virðist vera rangur

    2 * KNVN = 18 en á, að ég held að vera 2 * KNVN = 20.

    Sjá mynd: http://www.tiikoni.com/tis/view/?id=b73dc7c

    Ég er voða ánægður með að hafa sloppið við ósigur :)

    invalid 
    opened by acmeguy 4
  • Dawgbuilder virkar ekki á OS X

    Dawgbuilder virkar ekki á OS X

    Þegar ég keyri python dawgbuilder.py á OS X fæ ég viðvaranir um að röðun sé ekki rétt. Hér virðist vera um að ræða sérstakt vandamál á OS X sem leysist ekki við að skipta um locale.

    Ath: Ég er með lausn á þessu og mun senda pull request bráðlega.

    Fyrst taldi ég að villan væri vegna þess að ég hefði ekki valið rétt locale, en það virðist hreinlega ekki vera rétt röðun á stýrikerfinu, a.m.k. með þeim pökkum sem ég er með núna.

    Hér má sjá raðanir á "abbadísunum,abbaðist,abbast" notandi allar mögulegar is_IS stillingar á mínu kerfi:

    Locale: is_IS
    abbadísunum,abbast,abbaðist - NOK
    Locale: is_IS.ISO8859-1
    abbaðist,abbadísunum,abbast - NOK
    Locale: is_IS.ISO8859-15
    abbaðist,abbadísunum,abbast - NOK
    Locale: is_IS.UTF-8
    abbadísunum,abbast,abbaðist - NOK
    

    Hér er umræða um þetta vandamál: http://stackoverflow.com/questions/3412933/python-not-sorting-unicode-properly-strcoll-doesnt-help

    Þar er rætt um að nota PyICU í staðinn. Lausnin sem ég er með núna gerir það raunar ekki, en ég mun prófa það áður en ég sendi pull request, þar sem það myndi virka fyrir önnur tungumál en íslensku.

    Forritið virkaði raunar ekki heldur á Ubuntu, en þar leystist það við að velja locale=is_IS.utf8. Almennt getur verið bölvað vesen að fá locale til að virka í almenna tilfellinu svo pull requestið bætir við aukalegu villutékki og boðið er upp á möguleg locale á skipanalínunni.

    opened by withrocks 4
  • Modularize the javascript files

    Modularize the javascript files

    • The files main.js, netskrafl.js and watch.js are using duplicated code
    • Use grunt concat to concatenate different modules
    • Add grunt-contrib-concat, provides the concat task
    • Update the gruntfile accordingly
    • Move code from e.g. static/netskrafl.js to static/js/netskrafl.js, then separate common code to separate files
    • Order changes in some cases, should not matter, but needs testing
    • Not fully tested yet, needs to be tested by project owner
    opened by withrocks 3
  • Sýna í leik og í leikjalista hvort andstæðingur skraflar án hjálpartækja

    Sýna í leik og í leikjalista hvort andstæðingur skraflar án hjálpartækja

    Það sést ekki í leik hvort andstæðingurinn sver af sér hjálpartæki eður ei. Ég stundaði það því að fara út í leikjalistann til að gá, en með síðustu uppfærslu hætti það að sjást þar líka. Mér sýnist að það sjáist núna hvergi nema með því að fara í „Andstæðingar“ og hafa þar uppi á nafni andstæðingsins (og þar er engin leit, bara listar í stafrófsröð þar sem greint er á milli hástafa og lágstafa).

    Þetta er til baga fyrir miðjumoðara eins og mig sem hafa þann háttinn á að banna sér hjálpartæki bara í leikjum á móti öðrum sem banna sér þau, en leyfa sér þau á móti öðrum sem leyfa sér þau. (Og raunar mætti alveg vera til sú yfirlýsing líka — eða þá að yfirlýsingin geti átt við um einstaka leiki.)

    Best væri að gefa þetta til kynna bæði í leik og í leikjalista.

    invalid 
    opened by gthb 3
  • ELO-stigakerfi eða sambærilegt; sjálfvirk pörun leikmanna

    ELO-stigakerfi eða sambærilegt; sjálfvirk pörun leikmanna

    Nota ELO-kerfið eða annað sambærilegt kerfi til að reikna út stig leikmanna. Sýna lista yfir leikmenn í lækkandi ELO-röð. Bjóða upp á sjálfvirka áskorun þar sem kerfið parar leikmann við annan leikmann í svipuðum styrkleikaflokki sem er álínis og til í slíkt (merktur þannig í notendaupplýsingum).

    enhancement 
    opened by vthorsteinsson 2
  • Meira áberandi tilkynning um ný spjallskilaboð

    Meira áberandi tilkynning um ný spjallskilaboð

    Ný spjallskilaboð eru nú gefin til kynna með litabreytingu á spjallteikni úr svörtu í rautt. Fyrir litblinda eða sjóndapra getur verið erfitt að sjá þessa breytingu.

    enhancement 
    opened by vthorsteinsson 1
  • Sýna bestu orð og stigahæstu viðureignir í ferils-gluggum

    Sýna bestu orð og stigahæstu viðureignir í ferils-gluggum

    Sýna bæði besta orð og hæsta skor leikmannsins sjálfs í ferilsflipa, og andstæðinga í ferilsglugga þeirra. Innifela tengil (krækju) í viðkomandi viðureign.

    enhancement 
    opened by vthorsteinsson 1
  • Skoða feril andstæðings beint frá viðureign

    Skoða feril andstæðings beint frá viðureign

    Geta skoðað feril andstæðings með auðveldum hætti beint frá viðureignarborði, í stað þess að þurfa að leita að honum í andstæðingalistum. Gæti einnig tengst möguleika á að sjá yfirlit um fyrri viðureignir við sama andstæðing.

    enhancement 
    opened by vthorsteinsson 1
  • Geyma stöðu borðs milli innlita

    Geyma stöðu borðs milli innlita

    Geyma flísar á sínum stað á borði (og í réttri röð í rekka) milli þess sem viðureignir eru opnaðar í board.html. Hjálpar leikmönnum að muna hugmyndir að leikjum. Væntanlega yrði að leysa þetta með localStorage sem þýðir að kerfið man stöðuna aðeins á sama vefrápara á sömu tölvu eða tæki. Hugsanlegt að bæta einnig við "minnisblaði" - nýjum flipa við borðið - þar sem unnt yrði að geyma hugrenningar og hugmyndir um lagnir.

    enhancement 
    opened by vthorsteinsson 1
  • Sjá útistandandi viðureignir og skipta á milli þeirra beint frá borði

    Sjá útistandandi viðureignir og skipta á milli þeirra beint frá borði

    Geta frá borðinu (board.html) séð einhvers konar fellilista yfir viðureignir þar sem leikmaður á leik og geta skipt beint á milli þeirra án þess að fara út í main.html og til baka.

    enhancement 
    opened by vthorsteinsson 1
  • Leikur andstæðings færi hvorki flísar aftur í rekka né rugli rekkanum

    Leikur andstæðings færi hvorki flísar aftur í rekka né rugli rekkanum

    Leikmaður hefur e.t.v. lagt tíma og vinnu í að finna möguleg orð og staðsetningar sem sárt er að sjá verða að engu þegar leikur andstæðings birtist, sérstaklega í tímaleik. Þó yrði augljóslega að senda nýjar flísar sem eru fyrir á reitum sem andstæðingur leggur á niður í rekkann.

    enhancement 
    opened by vthorsteinsson 1
  • Calculate and display player point averages over last N games

    Calculate and display player point averages over last N games

    Currently player point averages are calculated over the player's entire game history. A useful complement to this would be an average over only the last N games, where N is perhaps 100.

    enhancement 
    opened by vthorsteinsson 0
  • Allow double click on blank tile to set a new meaning

    Allow double click on blank tile to set a new meaning

    When composing a word on the board using a blank tile, allow the user to double click on the tile to modify its meaning, instead of having to return it to the rack and then back again to the original location.

    enhancement 
    opened by vthorsteinsson 0
  • Rangur hjálpartexti: „Flísar sem eftir eru í pokanum“

    Rangur hjálpartexti: „Flísar sem eftir eru í pokanum“

    Þegar músin vokir yfir stafaflísunum neðst til hægri stendur í hjálpartexta „Flísar sem eftir eru í pokanum“. En flísarnar sem þegar eru komnar á rekka andstæðingsins eru þarna á meðal, og þær flísar munu ekki koma úr pokanum. Raunin er því önnur en textinn heldur fram. (Og það er eins gott, því að annars væri alltaf hægt að þefa uppi hvaða flísar andstæðingurinn dregur með því að fylgjast vel með þessum lista breytast!)

    Réttari texti væri því „Flísar í pokanum eða á rekka andstæðingsins”, eða bara „Flísar sem eftir eru“.

    opened by gthb 0
  • Merkja leikmenn sem eru andstæðingar í viðureignum sem standa yfir

    Merkja leikmenn sem eru andstæðingar í viðureignum sem standa yfir

    Leikmenn með útistandandi áskorun eru merktir með rauðum fingri. Bæta mætti við grænum fingri (eða álíka merki) á þá leikmenn sem eru andstæðingar í viðureignum sem standa yfir.

    enhancement 
    opened by vthorsteinsson 0
  • Merking áskorana frá leikmönnum sem nota hjálpartæki

    Merking áskorana frá leikmönnum sem nota hjálpartæki

    Sumir leikmenn vilja helst eða alls ekki taka áskorunum frá leikmönnum sem nota hjálpartæki. Viðmótið mætti vera skýrara til að aðgreina slíkar áskoranir. Jafnvel mætti hafa sérstakan rabbglugga til staðfestingar þegar leikmaður tekur slíkri áskorun.

    enhancement 
    opened by vthorsteinsson 0
Releases(mfix3)
  • mfix3(Sep 5, 2022)

    Mfix2 + patches including updated word lists and cherry picked bug fixes, plus updated copyright info and a fix to the SalesCloud wrapper div style

    Source code(tar.gz)
    Source code(zip)
  • BeforeExplo(Jul 9, 2021)

    This is a release that encompasses Netskrafl before a large merge with the Explo codebase, where code has been moved to the /src directory, the backend endpoints split into web.py and api.py, and the UI migrated to a single-page UI written in TypeScript.

    Source code(tar.gz)
    Source code(zip)
  • mfix(Jan 25, 2021)

    • Vocabulary fixes
    • Fixed code for reading games from the database. ResponseMoves were being read in such a manner that word validity at the time of reading was used as the ground truth, not the word validity as it was when the original move was made. This affected manual wordcheck games that were in progress while the vocabulary was being changed to be more restrictive - and then back again to being more permissive.
    Source code(tar.gz)
    Source code(zip)
  • median(Jan 20, 2021)

    • Backtracked change in main dictionary; it now includes the same subset of BÍN as before (basically everything except 'bibl' and plural question forms)
    • Changed the Miðlungur robot to use a separate vocabulary, similar to what Amlóði does
    • Added tests
    • Removed extraneous indexes from the RatingModel datastore entities
    • Added separate accounting of Elo points for manual-wordcheck games (not yet enabled in the UI)
    Source code(tar.gz)
    Source code(zip)
  • ksnid(Jan 13, 2021)

    • Updated dictionary from newest version of BÍN using "Kristínarsnið"
    • Removed ~130.000 rare, localized, poetic, old or misspelled word forms from dictionary
    • Moved to Python 3.8 runtime
    • Type annotations added
    Source code(tar.gz)
    Source code(zip)
  • Vocabfix3(Jul 22, 2020)

  • Vocabfix2(Apr 16, 2020)

  • Punchfix.1(Nov 26, 2019)

  • Firefix.1(Oct 16, 2017)

  • Obelix.1(Sep 21, 2017)

  • snowfall.1(Dec 3, 2015)

    Performance enhancements, especially for user lists. Removed locale dependency in dawgbuilder.py, as locale functionality is pretty erratic between Win32/Linux/OSX.

    Source code(tar.gz)
    Source code(zip)
  • rekindle.1(Nov 5, 2015)

    Adds a two-click mode when placing tiles: click on the tile to move and then on an empty square to place it.

    Moves the recall-to-rack button to the left of the rack, away from the Play button, as users occasionally pressed Play when they intended to recall tiles.

    Adds a live user search field, based on user identifiers or full names, instead of the previous alphabet categories, which were getting quite unwieldy as the user base grew. This required two new properties on the UserModel in the database.

    Source code(tar.gz)
    Source code(zip)
  • Rebus(Oct 25, 2015)

  • Ramadan.1(Aug 11, 2015)

  • Kufti.1(Apr 20, 2015)

    Navigation between games directly from the board; ability to see opponent track record directly from board; FAQ in help; highest scoring word and highest game score stored with users; Elo score stored with users during stats calculation; other smaller enhancements.

    Source code(tar.gz)
    Source code(zip)
  • Omar.1(Apr 7, 2015)

Owner
Miðeind ehf
Icelandic startup specializing in AI and Natural Language Processing
Miðeind ehf
Minecraft.nix - Command line Minecraft launcher managed by nix

minecraft.nix Inspired by this thread, this flake contains derivations of both v

12 Sep 06, 2022
A set of functions compatible with the TIC-80 platform

Pygame-80 A set of functions from TIC-80 tiny computer platform ported to Pygame 2.0.1. Many of them are designed to work with the NumPy library to im

7 Aug 08, 2022
An entropy-based strategy to wordle

An entropy-based strategy to wordle

Gilles Vandewiele 24 Dec 31, 2022
Datamining of 15 Days of (free) Games at the Epic Games Store (EGS).

EGS: 15 Days of Games This repository contains Python code to data-mine the 15 Days of (free) Games at the Epic Games Store (EGS). Requirements Instal

Wok 9 Dec 27, 2022
A full featured game of falling pieces using python's pygame library.

A full featured game of falling shapes using python's pygame library. Key Features • How To Play • Download • Contributing • License Key Features Sing

Giovani Rodriguez 7 Dec 14, 2022
Flappy bird using Pygames

flappy-bird Esse é um jogo que eu fiz utilizando a biblioteca de jogos do Python

Leandro Henrique 2 Jan 05, 2022
Simple game where you try to survive as long as you can on screen.

Survival Game Simple game where you try to survive as long as you can on screen. Play To run, download the code and run the survival_game.py file. Fro

Logan Morris 1 Feb 10, 2022
Pygame Raycaster made by me.

Pygame Raycaster made by me.

Sable 0 Jan 10, 2022
I got bored and wrote a wordle solver... Its pretty good though, just saying

Wordle Solver I got bored and wrote a wordle solver... Its pretty good though, just saying. Please go support Josh and have fun with Wordle on the off

Darrell Best 2 Jan 25, 2022
Among AIs is a (prototype of) PC Game we developed as part of the Smart Applications course @ University of Pisa.

Among AIs is a PC Game we developed as part of the Smart Applications course @ Department of Computer Science of University of Pisa, under t

Gabriele Pisciotta 5 Dec 05, 2021
Client-Server design (guess the closest number to the average score game)

Multiplayer game (enter the number closest to the average) Design Client-Server design The client's side is responsible for sending numbers from the g

Adam Piszczek 0 Jun 29, 2022
Automatically prepare your Minecraft maps for release

map-prepare Automatically prepare Mineraft map for release. Current state: kinda works Make sure you have backups for your world before running this p

11 Oct 11, 2022
Hex-brawl-v25 - Simple Brawl Stars v25.107 server emulator written in Python

Hex Brawl Simple Brawl Stars v25.107 server emulator written in Python. Requirem

Shark01 3 Nov 24, 2022
A game based on Motus, to be played on Unix terminals.

Motus python game A game based on Motus, to be played on Unix terminals. How to play? Before playing, you need to install all the requirements needed

Arthur Molia 1 Feb 02, 2022
Brawl Stars private server for version 30.242

Brawl Stars v30 Brawl Stars v30.242 server emulator written in Python. Requirements: Python 3.7 or higher pymongo dnspython colorama Running the serve

15 Oct 17, 2021
uses Entropy to find the best next guess for Wordle, given the color clues

WordleSolver uses Entropy to find the best next guess for Wordle, given the color clues use player.py and enter in the string for the suggested clue w

Steve Earth 1 Jan 26, 2022
Code and outputs from analysis determining that the wordle game can always be won in six moves.

wordle_worst_case_analysis Code and outputs from analysis determining that the wordle game can always be won in six moves. This is for the general cas

2 Aug 19, 2022
A program to read, edit, and write save files for the game Railroads! Online

RROSE - v0.3.6 This program is intended to be used as an external tool to Railroads Online server hosts. It will read save files, allow to modify entr

17 Dec 09, 2022
A minimal open source mtg-like tcg game made in python that can be played on a terminal emulator using a keyboard.

A minimal open source mtg-like tcg game made in python that can be played on a terminal emulator using a keyboard.

Amos 3 Aug 29, 2021
Unknown Horizons official code repository

Unknown-Horizons based on Fifengine is no longer in development. We are porting it to Godot Engine. Please dont report any new bugs. Only bugfixes wil

Unknown Horizons 1.3k Dec 30, 2022