A gamey, snakey esoteric programming language

Related tags

Miscellaneoussnak
Overview

Snak

Snak is an esolang based on the classic snake game.

Installation

You will need python3. To use the visualizer, you will need the curses module. Then it's as easy as:

python3 snak.py [-q] filename length

Snak program definition

Grid chunks

A Snak program consists of a description of a single chunk in an infinite 2D space. The contents of each cell of the space are defined by the character located in that position in the program. These include

Symbol Meaning
+ Incrementing Fruit
- Decrementing Fruit
> Snake initially moving east
< Snake initially moving west
^ Snake initially moving north
v Snake initially moving south

All other characters (aside from line feeds and carriage returns, which are stripped) have no semantic meaning (but do occupy space). (Thus, Snak programs can contain comments in their unused space. It is recommended to replace the letter v, where needed in such comments, with a u or w.)

The full operating space of a Snak program is created by infinitely tiling the fruits in the single defined chunk in every direction.

The width of the chunks is defined as the maximum length of any line of the program. The height of the chunks is defined as the number of lines in the program.

Snakes

A Snak program may have any number of snakes. A snake has a position, a direction, a length, and a finite queue of cells in the grid (the last of which is always its position). At program start, every snake occupies only a single cell in the prescribed location in the origin chunk (the chunk that contains the location (0,0)), regardless of its initial length.

Fruits

Every + or - in the program definition specifies an infinite number of corresponding fruits, one per chunk. As the program runs, some fruits will be removed from the grid, but, unlike the snake game, no fruits are ever added.

Execution of a Snak program

At the beginning of a Snak program, the length of every snake is initialized to the same value provided as the length parameter to the interpreter. This is the only input method that does not involve altering the program source.

A Snak program proceeds in finite ticks. At each tick, the following occur in sequence:

  1. Every snake takes one step in its current direction.
    1. The new position is enqueued in its list of occupied cells.
    2. The oldest position in the queue is popped and discarded.
    3. If the snake's position is now a cell it already occupies, the program halts.
  2. If any snake now occupies a cell occupied by any other snake, the program halts.
  3. If any snake now occupies the same position as a fruit:
    1. That fruit is removed from the grid.
    2. The corresponding incrementing or decrementing of the snake's length is performed.
      • If a decrementing brings a snake's length to zero, the program halts with an error condition.
    3. If a snake now occupies more cells than its length, its queue of occupied positions is popped.
  4. Every snake's direction is updated.
    1. Up to three fruits are selected from the grid.
      • A fruit is selected if it is the first fruit along the line in the snake's current direction from the snake's current position, or 90 degrees clockwise or counterclockwise from that direction and no snakes (including the snake for whom this computation is being performed) lying between the fruit and the snake's current position. In other words, the first fruit "visible" by the snake in any of the three directions it could take its next step.
    2. Of these selected fruits, the nearest ones to the snake's current position is selected.
    3. If more than one fruit are at the nearest distance, the clockwise one is preferred to the one in the same direction which itself is preferred to the counterclockwise one.

Note that this order ensures that every snake will attempt to take one step in their initially defined direction before the positions of any fruits have an effect on their movement.

When the program halts, the final length of each snake is printed. This is the only form of output aside from watching the program state as it changes.

Using the interpreter

There is an optional -q flag that turns off the curses-based visualizer/debugger. Using it will cause the program to run to completion (if it halts) as quickly as possible, producing its final result (if any).

Without this flag, you will be dropped into a visualization of the executing program, paused in its initial state, with a number of interaction options available:

Keyboard Input What it Does
Cursor keys Shift the view in the indicated direction
p Pause/unpause automatic execution
s Perform one tick while paused.
+ Increase the running speed
- Decrease the running speed
f Center view on first defined snake
n If centered on snake, select next snake
q Halt immediately and exit

If the terminal supports mouse input:

Mouse Input What it Does
Right-click on a snake Center the head of the snake in the view
Right-click on a non-snake Stop centering any snakes in the view
Click, hold, and drag Drag view

Note that, for weird curses reasons, to drag, you must click and hold still for a moment before beginning to drag. Also, you may need to click on the app for the simulation to keep running after certain interactions (I think this is depends on which term you use.) But

You can resize your terminal at any time to see more or less of the grid.

##See Also

Esolangs wiki page

Owner
David Rutter
David Rutter
Buffer Overflows

BOF Buffer Overflows 1. BOF tips Practice using mona.py Download vulnerable exe from Exploit DB.

Vinh Nguyễn 27 Dec 08, 2022
FileTransfer - to exchange files from phone to laptop

A small website I locally host on my network to exchange files from my phone and other devices to my laptop.

Ronak Badhe 4 Feb 15, 2022
MoBioTools A simple yet versatile toolkit to automatically setup quantum mechanics/molecular mechanics

A simple yet versatile toolkit to setup quantum mechanical/molecular mechanical (QM/MM) calculations from molecular dynamics trajectories.

MoBioChem 17 Nov 27, 2022
Architecture example simulator

SCADA architecture Example of a SCADA-like console application, used to serve as a minimal example of a standard architecture of an IIoT system. Insta

1 Nov 06, 2021
More routines for operating on iterables, beyond itertools

More Itertools Python's itertools library is a gem - you can compose elegant solutions for a variety of problems with the functions it provides. In mo

2.8k Jan 02, 2023
Odoo modules related to website/webshop

Website Apps related to Odoo it's website/webshop features: webshop_public_prices: allow configuring to hide or show product prices and add to cart bu

Yenthe Van Ginneken 9 Nov 04, 2022
The Begin button and menu for the Meadows operating system. The start button for UNIX/Linux.

By: Seanpm2001, Meadows Et; Al. Top README.md Read this article in a different language Sorted by: A-Z Sorting options unavailable ( af Afrikaans Afri

Sean P. Myrick V19.1.7.2 4 Aug 28, 2022
An useful scripts for Misskey

misskey-scripts This place storing useful scripts which made by me. icon-repair Repair broken remote user's icon.

CyberRex 5 Sep 09, 2022
Datargsing is a data management and manipulation Python library

Datargsing What is It? Datargsing is a data management and manipulation Python library which is currently in deving Why this library is good? This Pyt

CHOSSY Lucas 10 Oct 24, 2022
Small tool to use hero .json files created with Optolith for The Dark Eye/ Das Schwarze Auge 5 to perform talent probes.

DSA5-ProbeMaker A little tool for The Dark Eye 5th Edition (Das Schwarze Auge 5) to load .json from Optolith character generation and easily perform t

2 Jan 06, 2022
All Assignments , Test , Quizzes and Exams with solutions from NIT Patna B.Tech CSE 5th Semester.

A 🌟 to repo would be delightful, just do it ✔️ it is inexpensive. All Assignments , Quizzes and Exam papers at one place with clean and elegant solut

LakhanKumawat ᵖ⁺ 16 Dec 05, 2022
Configure request params such as text, color, size etc. And then download the image

Configure request params such as text, color, size etc. And then download the image

6 Aug 18, 2022
Repo to store back end infrastructure for Message in a Bottle

Message in a Bottle Backend API RESTful API for Message in a Bottle frontend application consumption. About The Project • Tools Used • Local Set Up •

4 Dec 05, 2021
Hydralit package is a wrapping and template project to combine multiple independant Streamlit applications into a multi-page application.

Hydralit The Hydralit package is a wrapping and template project to combine multiple independant (or somewhat dependant) Streamlit applications into a

Jackson Storm 108 Jan 08, 2023
Show Public IP Information In Linux Taskbar

IP Information In Linux Taskbar 📍 How Use IP Script? 🤔 Download ip.py script and save somewhere in your system. Add command applet in your taskbar a

HOP 2 Jan 25, 2022
Prometheus exporter for Spigot accounts

SpigotExporter Prometheus exporter for Spigot accounts What it provides SpigotExporter will output metrics for each of your plugins and a cumulative d

Jacob Bashista 5 Dec 20, 2021
Pardus-flatpak-gui - A Flatpak GUI for Pardus

Pardus Flatpak GUI A GUI for Flatpak. You can run, install (from FlatHub and fro

Erdem Ersoy 2 Feb 17, 2022
A free and powerful system for awareness and research of the American judicial system.

CourtListener Started in 2009, CourtListener.com is the main initiative of Free Law Project. The goal of CourtListener.com is to provide high quality

Free Law Project 332 Dec 25, 2022
This is a simple web interface for SimplyTranslate

SimplyTranslate Web This is a simple web interface for SimplyTranslate List of Instances You can find a list of instances here: SimplyTranslate Projec

4 Dec 14, 2022
decorator

Decorators for Humans The goal of the decorator module is to make it easy to define signature-preserving function decorators and decorator factories.

Michele Simionato 734 Dec 30, 2022