Skip to content

About

Retro 4x4 terminal pattern puzzle in Rust featuring grid shifts, color themes, move undo, and an auto solver.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pattern_lock

A little terminal puzzle game I built in Rust. You're handed a scrambled 4x4 grid ("SYSTEM LOCK: TERMINAL OVERRIDE") and your job is to shift rows and columns until it matches the original pattern and the "system" unlocks.

I wanted something that felt like cracking a keypad in a hacker movie but was actually just a sliding puzzle underneath. There's a Cyberpunk theme and a Matrix theme, undo, hints, and an auto-solver if you get stuck (or just want to watch it solve itself).

==================================================
       SYSTEM LOCK: TERMINAL OVERRIDE             
==================================================
+-----------------+
| [#] [@] [*] [$] |  <- Row 0
| [$] [#] [@] [*] |  <- Row 1
| [*] [$] [#] [@] |  <- Row 2
| [@] [*] [$] [#] |  <- Row 3
+-----------------+

Running it

You'll need Rust/Cargo installed.

git clone https://github.com/Razorbillworks/pattern_lock.git
cd pattern_lock
cargo run

It'll ask you to pick a theme and a difficulty, then drop you into the game.

Playing

type this to
r0 .. r3 shift that row
c0 .. c3 shift that column
u undo your last move
h get a hint
auto / s sit back and let it solve itself
q quit

Three difficulties — Very Basic, Intermediate, and Champ — which just control how many scrambles get applied at the start (2, 4, and 6).

How the puzzle actually works

Every game starts from a solved grid, and I scramble it by applying a handful of random row/column shifts. The trick is I record the inverse of every scramble move as I make it, so I always know exactly how to get back to the solved state — that solve stack is what powers both the hint system and the auto-solver. Hints just peek at the top of the stack, auto-solve just pops through the whole thing.

The grid itself is stored as a flat 16-item array under the hood rather than a 2D one, which made rotating rows/columns a lot simpler to reason about.

Built with

  • Rust
  • colored for the terminal colors
  • rand for scrambling

License

MIT

About

Retro 4x4 terminal pattern puzzle in Rust featuring grid shifts, color themes, move undo, and an auto solver.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages