Code Monkey home page Code Monkey logo

yayagram's Introduction

yayagram - Play nonograms/picross in your terminal

yayagram is a puzzle game in which you fill out a grid with cells based on logic and number clues in your terminal using the mouse.

The game goes by many names: nonogram, picross, paint by numbers, griddlers, pic-a-pix, hanjie, and others.

Showcase

A randomized grid where white signifies a filled cell and red signifies a crossed out cell.

See this example to find out how to play.

Playing it is as easy as:

cargo install yayagram
yayagram

Binaries are also provided in the Releases.

Demo

demo.mp4

Features

  • Runs in the terminal and is playable with the mouse!
  • Cross-platform: runs on Linux and macOS.
  • Helpful additional features and tools like undo, redo, flood fill, clear, and more.
  • Random grids.
  • Custom grids: create your own grids for others to play.
  • A new kind of cell: maybed.
  • Very well suited for big grids.
  • Intuitive to play.

Controls

The game is primarily played with mouse and keyboard but can also be played exclusively with the keyboard. You don't need to memorize the following controls. The most important controls are displayed ingame.

  • Mouse movement, arrow keys, or HJKL: select a cell.
  • Left-click or Q: place a cell.
  • Middle-click or W: maybe a cell.
  • Right-click or E: cross out a cell.
  • C: clear the grid.
  • A: undo cell placements or a grid clear.
  • D: redo cell placements or a grid clear.
  • F: flood-fill multiple cells.
  • X: set measurement point.
  • Tab: toggle the editor.
  • S: save the edited grid as a file locally.
  • Enter: load local .yaya grid files with drag & drop onto the window.
  • Esc: exit.

For anyone that prefers to use the vi keys, you may be interested in @Maugrift's wonderful fork which features an alternate control scheme!

Editor

Press Tab to toggle the editor and start placing the cells for your grid. You can make use of all cell kinds. To export your grid, press S to save the grid as a new local .yaya grid file while in editor mode. Note that in the same session it will always write the grid to the same file again unless renamed.

Loading grid files

  • You can press Enter ingame to load a .yaya grid file with drag & drop onto the window. Many but not all terminals support this.
  • On Linux and macOS the .yaya file can be passed via the command line.

img2yaya

As an alternative to the editor you can generate .yaya grids using @AaronErhardt's amazing img2yaya to convert images to playable .yaya files!

Command line arguments

The program takes a single number for a squared grid size, two numbers for width and height, or the filename of a .yaya grid file to load a custom user-made grid.

yayagram # a random 5x5 grid
yayagram 10 # a random 10x10 grid
yayagram 5 15 # a random 5x15 grid
yayagram example.yaya # a custom grid

--help, -h and --version, -V are also supported.

Measurement tool

Particularly on bigger grids it can sometimes become hard to count all the cells. For this you can use the measurement tool. Simply press X to set your first point and then X again to set your second point. You will then be able to see the distance between those two points with the measured cells that appear. Measured cells never overwrite cell kinds other than empty cells and its own.

If you save a grid that contains measured cells, their distance indices won't be saved and the measured cells will only appear as green when that grid is loaded.

Maybed

The blue "maybed" cell kind can be placed on the grid with middle-click and is supposed to make "what if?" reasoning and trying out things easier, as an alternative to using crossed out or filled cells which may be confusing.

Big grids

yayagram is very well suited for big grids, up to size 99x99. Here are the reasons:

  • The measurement tool makes counting many cells far less error-prone and a lot easier.
  • There is a fill tool that easily lets you flood-fill multiple cells at once.
  • Cells surrounding the pointer are highlighted so that you don't lose track of the cell row you are focusing on.
  • The grid is shown in smaller form on the top left, making it easier to see the whole picture.

Other Tips

  • Try to avoid guesssing and play it safe! Guessing can come back later to bite you. Guessing is unsafe.
  • Don't forget to cross out cells that you are sure won't be filled. This helps immensely at ruling out possibilities.
  • If you want a new random grid, drag the litle resize icon in the grid's bottom right, next to the progress bar, to the size you want.
  • Be careful about accidentally pasting in your clipboard data. Some terminals paste with the press of a mouse button. If the data contains 'c' for instance, the grid will be cleared because it's recognized as the C key being pressed. This clear can be undone using the A key of course, but it may be confusing. The same applies to items dropped onto the window. Press Enter before loading grid files.

Example

Here's a simple example to help you grasp the game.

2 3 2
2
3
2

This is our grid where we need to fill out these 9 empty fields with the help of the 6 clue numbers on the top and on the left. First, let's take a look at the 3 clues on the very top: the first one is 2. It tells us that exactly 2 cells in a row of the 3 cells below it are filled. Through logic we can determine that this means that at least the middle cell is definitely filled:

2 3 2
2
3
2

Let's look at what the clue next to it to the right tells us (3). This clue means that there is exactly 3 cells in a row filled below. Because we only have 3 cells here (because it's a 3x3 grid), we can simply fill out all of those 3 cells safely:

2 3 2
2
3
2

Next clue on the top: 2. Again, through logic we can determine that at least the cell in the middle is definitely filled:

2 3 2
2
3
2

Now let's continue with the clues on the left, starting with the top one: 2. Here it's the same, there is definitely at least the middle cell filled, which is already the case so we can simply move on with the clue below it: 3. The row is already filled out so let's move on to the next one: 2. Again, nothing to do. It turns out that we have a pretty rare case here where two solutions are correct:

2 3 2
2
3
2

or

2 3 2
2
3
2

Both solutions fulfill the requirements.

I hope this helped you grasp the game a little bit. Now you can try to apply some of what you learned on a small grid like 3x3 or 5x5 by simply passing the grid size as a command line argument to the program: yayagram 3 or yayagram 5 respectively.

You can also load the above example grid into the game with this file: example.yaya.

yayagram's People

Contributors

wooster0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

yayagram's Issues

Keyboard interaction

Make it possible to control the interface via the keyboard instead of with mouse

`cargo install yayagram` fails in tanmatsu

Hello,

Trying to install yayagram gives me the following error.

$ cargo install yayagram
# ... listing of downloaded crates ...
error[E0277]: the trait bound `fn(u16) -> MoveToNextLine {MoveToNextLine}: crossterm::Command` is not satisfied
   --> C:\Users\anon\.cargo\registry\src\github.com-1ecc6299db9ec823\tanmatsu-0.6.3\src\sys\other.rs:222:27
    |
222 |         self.stdout.queue(cursor::MoveToNextLine).unwrap();
    |                     ----- ^^^^^^^^^^^^^^^^^^^^^^ the trait `crossterm::Command` is not implemented for `fn(u16) -> MoveToNextLine {MoveToNextLine}`
    |                     |
    |                     required by a bound introduced by this call
    |
note: required by a bound in `queue`
   --> C:\Users\anon\.cargo\registry\src\github.com-1ecc6299db9ec823\crossterm-0.20.0\src\command.rs:60:39
    |
60  |     fn queue(&mut self, command: impl Command) -> Result<&mut Self>;
    |                                       ^^^^^^^ required by this bound in `queue`

error[E0277]: the trait bound `fn(u16) -> MoveToPreviousLine {MoveToPreviousLine}: crossterm::Command` is not satisfied
   --> C:\Users\anon\.cargo\registry\src\github.com-1ecc6299db9ec823\tanmatsu-0.6.3\src\sys\other.rs:226:27
    |
226 |         self.stdout.queue(cursor::MoveToPreviousLine).unwrap();
    |                     ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `crossterm::Command` is not implemented for `fn(u16) -> MoveToPreviousLine {MoveToPreviousLine}`
    |                     |
    |                     required by a bound introduced by this call
    |
note: required by a bound in `queue`
   --> C:\Users\anon\.cargo\registry\src\github.com-1ecc6299db9ec823\crossterm-0.20.0\src\command.rs:60:39
    |
60  |     fn queue(&mut self, command: impl Command) -> Result<&mut Self>;
    |                                       ^^^^^^^ required by this bound in `queue`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `tanmatsu` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `yayagram v0.8.0`, intermediate artifacts can be found at `C:\cygwin64\tmp\cargo-installklkVGp`

Caused by:
  build failed

Remove square shape requirement

Hey!

I really enjoyed playing yayagram (I really like nonograms in general) and had the idea of automatically generating .yaya files from images. I quickly implemented a prototype and it worked out pretty well yet during testing I came across a weird error message saying "malformed data" when opening a generated file. When looking for the cause in your code I found the following lines:

if width != height {
    return Err(LoadError {
        message: "malformed data",
        line_number: None,
    });
}

Well, first this error message isn't very descriptive. But more importantly, nonograms are not necessarily square shaped. Especially when converting images this can be a problem as the image would need to be scaled or resized if it's not square shaped which is suboptimal. So I wonder whether this check could be simply removed... at least that would help me a lot with my image to yayagram converter :)

Ability to remove measurement cells

I use the measurement tool a lot, but after a while large parts of the picture are green. This makes the numbers harder to read and you start to mistake unfilled cells for others, as they become a rare occurance.

My workaround is to just fill all green bars with maybe-cells, but they can't be overridden by new measurements.

Therefore, I suggest defining the Y key to clear all green measurements. To give a second option, you could also map this key to clear a single cell. In combination with the fill-utility, one could achieve a similar result. However, I do prefer my first suggestion.

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.