Skip to content

Generate, read, and solve Straights grids.

Notifications You must be signed in to change notification settings

m-ringler/straights

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

straights

.NET Build

Solves and generates Straights (or Str8ts) puzzles.

straights accepts both text files (up to 64 x 64) and screenshots (up to 9 x 9) as input.

Straights Command Line Application

License: GPL

Description:
  Straights Puzzle Toolkit

Usage:
  straights [command] [options]

Options:
  --version       Show version information
  -?, -h, --help  Show help and usage information

Commands:
  generate                   Generates a straights puzzle
  play <imageOrTextFile>     Plays a straights puzzle in the default browser
  solve <imageOrTextFile>    Solves a straights puzzle []
  edit <imageOrTextFile>     Edits a straights puzzle []
  convert <imageOrTextFile>  Converts a straights puzzle

Some puzzles generated by the straights command line app can be found in the test folder.

Straights.Solver

NuGet Version License: MIT

Straights.Solver is the core library behind the straights command line app and the straights webapp. It solves, generates, and converts straights puzzles.

Straights.Solver theoretically supports grid sizes up to 64 x 64, but generating grids larger than about 10 x 10 gets increasingly computationally expensive; and I have not generated a grid larger than 13 x 13 yet.

Straights.Image

NuGet Version License: MIT

Straights.Image is a library that reads screenshots of Straights and Sudoku grids. It has no dependency on Straights.Solver or the Straights command line application (it is used by the latter).

It uses OpenCvSharp to detect the grids, and - on Linux - you may have to build an appropriate OpenCvSharpExtern.so runtime. See 'Installation' below.

Straights.Image supports grid sizes up to 9 x 9.

Straights.Web

License: GPL

Straights.Web is a web app for playing Str8ts that uses Straights.Solver to generate new grids. Try it online at https://m-ringler.github.io/straights/.

With Straights.Web, you can generate up to 10 x 10 grids, and play up to 12 x 12 grids (generated with the web app or with the command line app).

Straights.Web is a progressive web app that can be installed on users' devices (Add to home sceen), and that is fully functional when offline.

Status

The code works but is still pre-1.0, which means that breaking changes in the APIs can happen in every release. In particular:

  • Different releases of the command line app may produce different grids for the same arguments even if you pass an explicit random seed.
  • The library APIs are not stable, and may change in every release.
  • The data formats used by the webapp may still change.

Installation

Windows

Everything should work out of the box. To use the command line app put it somewhere on your $env:Path. And type straights at the command prompt.

The libraries Straights.Image and Straights.Solver are available on nuget.org, and you can use them by adding a package reference to your project.

Linux

Essentially the same as for windows.

However, the Linux native runtimes of OpenCvSharp used by Straights.Image depend on libraries that need to be installed on the system. These libraries are different for different distributions, e. g. for ubuntu-22.04 and ubuntu-24-04.

If Straights.Image fails with an "Unable to load shared library 'OpenCvSharpExtern' or one of its dependencies." error, you can check which dependencies are missing, and install them. Alternatively, you can simply install all the libraries used to build it.

If you are neither on Ubuntu-22 nor on Ubuntu 24, you may have to build your own OpenCvSharpExtern.so and replace the one shipped with straights.

As there is no official OpenCvSharp nuget package for Ubuntu-24, we're using our own nuget built from a fork of the OpenCvSharp repo for the Ubuntu-24 build of the straights command line app.

Building

You'll need:

  • a dotnet SDK that matches the SDK version in global.json,
  • npm

For Straights.Web, you need to download and activate the Emscripten SDK.

Straights Command Line App

npm ci
npm run tsc
dotnet publish Straights/Straights.csproj -c Release --use-current-runtime

Straights.Web

npm ci
npm run tsc
dotnet publish Straights.Web/Straights.Web.csproj -r browser-wasm -c Release -p MSBuildEnableWorkloadResolver=false

Backlog

  • Add more tests for the javascript code

  • Add more XML doc (use Copilot?)

  • Microsoft.CodeAnalysis.PublicApiAnalyzers

  • See if we can find a better solution for the Linux OpenCvSharp runtime

  • Issues/Bugs

    • Digit recognition sometimes fails on 3/5

Credits

  • Luis Walter: the straights webapp is derived from his.
  • Kshitij Dhama: the digit-recognition model in Straights.Image is trained on his printed-digits dataset.
  • Bekhzod Olimov: the pytorch code used to train the digit-recognition model in Straights.Image is largely his.

About

Generate, read, and solve Straights grids.

Resources

Stars

Watchers

Forks

Contributors 2

  •  
  •