simple-go-snake

command module
v0.0.0-...-ebe20b2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 11 Imported by: 0

README ΒΆ

🐍 Simple Go Snake

Go Version License Platform AUR

A modern, hyper-optimized implementation of the classic Snake game that runs directly in your terminal. Written in Pure Go with a focus on Clean Architecture and O(1) Algorithms.

Gameplay Preview


⚑ Key Features (v4.0)

  • πŸ“¦ AUR Support: Install easily on Arch Linux via simple-go-snake.
  • ⏸️ Pause Game: Need a break? Press 'P' to freeze the snake.
  • πŸ’Ύ Standard Configs: Settings are saved automatically in your system's standard config folder (XDG/AppData).
  • πŸ“Ί ASCII & Emoji Modes: Toggle between beautiful 🐍 graphics or SSH-friendly ASCII (%/@) mode.
  • πŸš€ True O(1) Performance: The engine uses a Linked List via Map structure. Movement is instant (~300ns) regardless of snake length.
  • πŸ’» Cross-Platform: Native builds for Windows (with icon support), Linux, and macOS.

πŸ“Š Benchmarks

The movement logic is implemented as a Linked List using a map[Coordinates]Coordinates. This ensures O(1) time complexity. Whether the snake has 10 segments or 10,000, the movement time remains constant.

Test Environment: Ryzen 5 5600H, Linux

Snake Length Time per Op
Small (10) ~335 ns/op
Medium (1,000) ~283 ns/op
Huge (10,000) ~284 ns/op

Data obtained via go test -bench=. ./structs


πŸ“₯ Installation

Arch Linux (AUR)

The recommended way for Arch users:

paru -S simple-go-snake
Manual Download (All OS)

Download the executable for your OS from the Releases Page.

OS File
πŸͺŸ Windows snake-windows-amd64.exe
🐧 Linux snake-linux-amd64
🍎 macOS (Apple Silicon) snake-macos-arm64
🍎 macOS (Intel) snake-macos-intel

(Linux/macOS users: run chmod +x <file> to make it executable).

Build from Source
git clone [https://github.com/XPLassal/simple-go-snake.git](https://github.com/XPLassal/simple-go-snake.git)
cd simple-go-snake
go build -ldflags "-s -w" -o snake .
./snake

βš™οΈ Configuration

On the first run, the game will ask for your preferences (Size, Difficulty, Emoji/ASCII). These settings are saved permanently in your system's user folder:

  • Linux: ~/.config/simple-go-snake/config.json
  • Windows: %AppData%\simple-go-snake\config.json
  • macOS: ~/Library/Application Support/simple-go-snake/config.json
Setting Description
Columns Map size (e.g., 20).
FPS Set FPS number (10 recommended).
Allow Wall Pass If y, the snake, upon hitting a border, wraps around and reappears on the opposite side of the map (Teleport mode). If n, hitting a border results in Game Over.
Multi Apple Mode If y, several apples (food items) can be present on the map simultaneously. If n, only one apple will spawn at a time (Classic mode).
FPS Set FPS number (10 recommended).
Hard Mode If y, the game speeds up as your score increases.
Use Emojis y for beautiful graphics. n for ASCII - recommended for SSH or older terminals.

Tip: Delete config.json to reset settings or press 'C' inside the game.


πŸ•Ή Controls

Key Action
W, A, S, D Move Snake β¬†οΈβ¬…οΈβ¬‡οΈβž‘οΈ
P Pause Game ⏸️
C Config / Restart (Stops current game)
Q Quit Game

πŸ— Technical Details

  • Logic: map[Coordinates]Coordinates (Linked List) for O(1) movement logic.
  • Rendering: strings.Builder + bufio.Writer for zero-allocation rendering per frame.
  • Architecture: Clean separation of main (Loop), structs (Domain), and render (UI).

πŸ“„ License

This project is licensed under the MIT License.

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL