292
tui-sudoku (lemmy.world)
submitted 1 year ago* (last edited 1 year ago) by christos@lemmy.world to c/linux@lemmy.ml

tui-sudoku is a configurable terminal interface sudoku game, with quite a few features.

https://gitlab.com/christosangel/tui-sudoku

Starting the game, and through the main menu, the player can :

  • Start a new game
  • Load previously saved game
  • Configure some parameters (colors, preferred editor, puzzle symmetry,preffered png)
  • exit the program

PLAYING THE GAME

After choosing the n New Game option, the player can select the level of difficulty.

The user will be presented with the known 9x9 sudoku matrix.

Using the shortcuts in the shown cheatsheet table, the player can

Shortcuts Action
hjkl 🠄 🠅🠇🠆 Move Cursor
[1-9] Insert Number
0,␣,␈ Clear Cell
E Earmark cells
H Toggle Highlight Numbers
I Toggle show Info (key cheatsheet)
P Pause Game
S Save Game
z,Z Undo / Redo
M Return to Main Menu
Q Show Solution & Quit
  • Typing H while the cursor is on a number, e.g. 2, will highlight all the 2s in the matrix.

    Typing H again will undo the highlighting:

-Typing E and entering up to 3 digits, will earmark the cell:

  • Entering an illegal number (a number that already exists in the row, the line or the 3x3 block) will mark the number with a different color, and give a warning message:

While the Moption returns to the Main Menu, and the S option saves the game, the Q option prints the solution and exits:

  • The user can also Undo or Redo their entries with the z or Z option respectively.

Back in the Main Menu, the player can also

  • Load a previously saved game with the l option

  • Configure preferred colors, preferred text editor and puzzle symmetry with the c option

  • or Browse the Top Ten Scores (s option)

The configuration is kept in the $HOME/.config/tui-sudoku/tui-sudoku.config file.

If there is no file kept there, default values will be loaded.

  • You can select the colors you like and the respective codes as they demonstrated here:

    https://talyian.github.io/ansicolors/

    Default colors

    Color Code Script Variable
    Grid Color \x1b[38;5;60m C1
    Given Numbers Color \e[1;33m C2
    Found Numbers Color \e[1;36m C3
    Wrong Numbers Color \e[1;31m C4
    Highlight Color \e[1;32m C5
    TextColor1 \e[35m C6
    TextColor1 \e[36m C7
  • SYMMETRY variable configures the symmetry of the given cells in the 9x9 matrix. Valid options are: none, rotate90, rotate180, mirror, flip, or random

  • PREFFERED_PNG variable defines the png that shows in the notifications. These images are located in the $HOME/.cache/tui-sudoku/png/ directory.

Any feedback is appreciated!


Added feature in 0.2.0: earmarked cells change color when illegal (the number already exists in row, column or 3x3 square)


Added feature in 0.3.0: Toggle info (key cheatsheet).


Added feature in 0.4.0: Pause Game.

top 25 comments
sorted by: hot top controversial new old
[-] DAT@feddit.de 13 points 1 year ago

ah… that brought back memories to when I wrote my own sudoku-generator

wanted to know how that one does it's things

Q="$(qqwing --generate 1 --difficulty $LEVEL --symmetry $SYMMETRY --csv --solution|tail -1|sed 's/./0/g')"

huh

QQwing is software for generating and solving Sudoku puzzles.

so it doesn't do the fun parts? sad.

[-] christos@lemmy.world 15 points 1 year ago

Oh, the FUN parts.

I initially tried to incorporate past attempts to generate a sudoku 9x9 matrix, even added a backtracking routine that would detect and exclude duplicate solutions. Unfortunately, the whole process of generating a new puzzle was taking about 30". What is more, the outcome, although symmetrical and all, was not what I wanted. The routines were in c. You can have a look if you like:

https://gitlab.com/christosangel/c-sudoku

[-] DAT@feddit.de 2 points 1 year ago

Yeah, I'm totally seeing why using qqwing was easier, better and more robust.

It's the all-around-better way to do that and the developers of that thing probably already spend more time thinking about those problems than we'll ever do.

But… fun? :-D

[-] dichotomiker@dresden.network 1 points 1 year ago

@DAT @christos divide & conquer 😏

[-] KHTangent@lemmy.world 7 points 1 year ago

This looks really nice, I'll star it so I remember to download it later

[-] christos@lemmy.world 4 points 1 year ago

I am glad you like it!

[-] suny@literature.cafe 6 points 1 year ago

hey, this looks really nice. do you have any plans to implement a killer sudoku mode?

don't know how that could work in terminal with all the small hints and boxes though.

[-] IRQBreaker@startrek.website 5 points 1 year ago

Almost expected it to be implemented in Electron but was happily wrong. Nice work!

[-] christos@lemmy.world 3 points 1 year ago

Hahaha, it never entered my mind!

[-] makeasnek@lemmy.ml 4 points 1 year ago

Sudoku is basically a game based on concept of latin squares. There's a fun volunteer computing project, actually several of them, that are making a global database of all the possible latin squares. Latin squares have lots of interesting applications, small latin squares are used in scientific studies all the time to control for bias/environment. Who knows what new applications will be found when a big enough database of them exists and can be perused for research.

All the projects I know of are on !boinc@sopuli.xyz , here's the main one https://boinc.multi-pool.info/latinsquares/

[-] Strit@lemmy.linuxuserspace.show 3 points 1 year ago

Is it possible to get a tag on the repo, so it's easy to package for package maintainers?

[-] christos@lemmy.world 1 points 1 year ago

I have no experience on this procedure, I have not done this before, I need to read some documentation to understand what it is you are asking, and if I can, I surely will. If you send me any helpful link, I would appreciate it.

[-] Strit@lemmy.linuxuserspace.show 7 points 1 year ago

It's pretty simple. :)

In the gitlab projects page there is a "Tags" section. Click the button to create a new tag, like 0.1.0 or whatever versioning you want, and that's about it.

That way packagers can target versions, instead of just main branch.

[-] christos@lemmy.world 4 points 1 year ago

I think I needed this info, I will do it today. Thank you!

[-] christos@lemmy.world 2 points 1 year ago

I have now added a tag (0.1.0) on the tui-sudoku repo.

[-] Strit@lemmy.linuxuserspace.show 2 points 1 year ago

Nice. I made an AUR package for it.

[-] christos@lemmy.world 1 points 1 year ago

Great, I guess that makes this script readily available to any Arch (+Arch based distros) user who is looking for a sudoku program in the AUR, correct? Thanks very much!

[-] Strit@lemmy.linuxuserspace.show 1 points 1 year ago

That's correct. Although the user needs to create folders and copy files into their own home folder, as that's where the script looks for them. But as a package, we can't touch it, so it's a manual step for the user.

[-] christos@lemmy.world 2 points 1 year ago

Thank you again for the effort and contribution, it is very appreciated.

[-] TomaTomaToma@lemmy.ml 1 points 1 year ago

It is one space off in the first row (numbers)

[-] christos@lemmy.world 1 points 1 year ago

Do you have this problem from the start? Is this the only problem you are facing? Have you installed the dependecies?

[-] chrismit3s@feddit.de 2 points 1 year ago

You can see it in the image you linked.

[-] christos@lemmy.world 1 points 1 year ago

Oh, I see. Phew, you gave me a scare for a moment. That I will fix right now, easy. Thanks for the feedback!

[-] christos@lemmy.world 1 points 1 year ago
this post was submitted on 26 Sep 2023
292 points (100.0% liked)

Linux

48705 readers
940 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS