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
Wordle-Python - A simple low-key clone of the popular game WORDLE made with python and a 2D Graphics module Pygame

Wordle-Python A simple low-key clone of the popular game WORDLE made with python

Showmick Kar 7 Feb 10, 2022
Scalable computer implemented in the game of life.

scalable-gol-computer This is a computer built in Conway’s game of life. It supports variable sizes of 8, 16 and 32 bit. Maximum program size: 256 lin

Nicolas Loizeau 19 Nov 19, 2022
This is a Python solver for the game Wordle, which recently received its PT-BR version

PT_BR_Wordle_Solver Este é um solver feito em Python do jogo Wordle, que recebeu sua versão PT-BR recentemente. Onde jogar Os sites para se jogar mais

Vinicius Jameli 1 Jan 24, 2022
Python game engine for 2D multiplayer online games.

LAN-Caster The goal of LAN-Caster is to provide an easy-to-use code base (game engine) for developing 2D multiplayer online games. LAN-Caster original

Douglas Bakewell 1 Feb 11, 2022
Given some input, spit out the possible words for a Wordle puzzle

Wordle Helper, because why not. Given some input, spit out the possible words for a Wordle puzzle First time setup # Download the dictionary to a file

Richard Duarte 1 Jan 25, 2022
EL JUEGO DEL GUSANITO

EL JUEGO DEL GUSANITO El juego consiste en una línea que no para de moverse, el usuario lo controla con las flechas de: → derecha ← izquierda ↑ arriba

Valeria Saidid Miranda Ibarra 0 Dec 19, 2021
Playing memory game is fun and the more harder it is the more challenging it is.

Playing memory game is fun and the more harder it is the more challenging it is. Playing thi sgame make us stress free and also happy. So, I have decided to make a memory Game which people can play w

Shreejan Dolai 3 Nov 11, 2022
Pygame for humans (pip install hooman) (25k+ downloads)

hooman ~ pygame for humans pip install hooman join discord: https://discord.gg/Q23ATve The package for clearer, shorter and cleaner PyGame codebases!

Abdur-Rahmaan Janhangeer 31 Nov 08, 2022
This is a script which can be used to autobattle, upgrade metamon, compose eggs and open eggs in metamon game.

This is a script which can be used to autobattle, upgrade metamon, compose eggs and open eggs in metamon game. The only parameters you need to input are you wallet address and sign. The sign can be o

Taxiria 37 May 11, 2022
🐍 Conway's Game of Life cellular automaton implemented in PyGame

Conway's Game of Life My PyGame implementation of Conway's Game of Life. This implementation involves treating all edges of the grid as stitched toget

Mateusz Żebrak 1 May 29, 2022
Easy and fun game to play a bit. Written in python

NumGuesser Easy and fun game to play a bit. Written in python

Lodi#0001 4 May 22, 2022
FlappyBird game with python and pygame

FlappyBird game with python and pygame

Mohammad Dori 4 Jul 15, 2022
PYGA: Python Google Analytics (ga.js) - Data Collection API

PYGA: Python Google Analytics - Data Collection API pyga is an implementation of Google Analytics (ga.js) in Python; so that it can be used at server

Arun Karunagath 136 Sep 19, 2022
This is simple minesweeper-like Telegram game

This is simple minesweeper-like Telegram game. You need to open all "free" squares and put flags on squares with bombs on them. If you open a cell with a bomb, the game is over.

Aleksandr 32 Dec 31, 2022
My goofy little script for playing wordle

my wordle "solver" My goofy little script for playing wordle. It actually runs really slowly at first but once you've added some info (e.g. which lett

MB 3 Feb 04, 2022
Creating Tetris with Pygame

Tetris 🤝 Contributing Contributions, issues and feature requests are welcome! Feel free to check issues page. Show your support Give a ⭐️ if this pro

Gavin Capriola 0 Mar 01, 2022
Atari2600 Training / Evaluation with RLlib

Training Atari2600 by Reinforcement Learning Train Atari2600 and check how it works! How to Setup You can setup packages on your local env. $ make set

Jinwoo Park (Curt) 1 Dec 12, 2021
A sprite ripper and converter for Com2uS' 2007 game Music World.

Music World Sprite Dumper This repository contains a python script reads an UNCOMPRESSED Music World pxo file and attempts to dump sprites from it. Th

Buu342 1 Mar 16, 2022
A module for use with Pygame. Includes fully customisable buttons, textboxes, sliders and many more, as well as the ability to create and run animations on these widgets.

Pygame Widgets A helper module for common widgets that may be required in developing applications with Pygame. It supports fully customisable buttons,

37 Jan 02, 2023
General Crossy Road Game using Python code

Python-Game General Crossy Road Game using Python code Using code such as function and while using turtle, I was able to recreate a beginner version o

Jacob Paquette 1 Dec 19, 2021