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
Python Interactive Graphical System made during Computer Graphics classes (INE5420-2021.1)

PY-IGS - The PYthon Interactive Graphical System The PY-IGS Installation To install this software you will need these dependencies (with their thevelo

Enzo Coelho Albornoz 4 Dec 03, 2021
:fishing_pole_and_fish: List of `pre-commit` hooks to ensure the quality of your `dbt` projects.

pre-commit-dbt List of pre-commit hooks to ensure the quality of your dbt projects. BETA NOTICE: This tool is still BETA and may have some bugs, so pl

Offbi 262 Nov 25, 2022
Simple and easy to use python API for the COVID registration booking system of the math department @ unipd (torre archimede)

Simple and easy to use python API for the COVID registration booking system of the math department @ unipd (torre archimede). This API creates an interface with the official browser, with more useful

Guglielmo Camporese 4 Dec 24, 2021
Python library for creating and parsing HSReplay XML files

python-hsreplay A python module for HSReplay support. https://hearthsim.info/hsreplay/ Installation The library is available on PyPI. pip install hsre

HearthSim 45 Mar 28, 2022
Moleey Panel with python 3

Painel-Moleey pkg upgrade && pkg update pkg install python3 pip install pyfiglet pip install colored pip install requests pip install phonenumbers pkg

Moleey. 1 Oct 17, 2021
Tutorial on Tempo, Beat and Downbeat estimation

Tempo, Beat and Downbeat Estimation By Matthew E. P. Davies, Sebastian Böck and Magdalena Fuentes Resources and Jupyter Book for the ISMIR 2021 tutori

49 Nov 06, 2022
Unofficial Valorant documentation and tools for third party developers

Valorant Third Party Toolkit This repository contains unofficial Valorant documentation and tools for third party developers. Our goal is to centraliz

Noah Kim 20 Dec 21, 2022
Generate PNG filles from NFO files.

Installation git clone https://github.com/pcroland/nfopng cd nfopng pip install -r requirements.txt Usage ❯ ./nfopng.py usage: nfopng.py [-h] [-v] [-i

4 Jun 26, 2022
How to use Microsoft Bing to search for leaks?

Installation In order to install the project, you need install its dependencies: $ pip3 install -r requirements.txt Add your Bing API key to bingKey.t

Ernestas Kardzys 2 Sep 21, 2022
Margin Calculator - Personally tailored investment tool

Margin Calculator - Personally tailored investment tool

1 Jul 19, 2022
Islam - This is a simple python script.In this script I have written all the suras of Al Quran. As a result, by using this script, you can know the number of any sura at the moment.

Introduction: If you want to know sura number of al quran by just typing the name of sura than you can use this script. Usage in termux: $ pkg install

Fazle Rabbi 1 Jan 02, 2022
A simple Programming Language

R.S.O.C. A custom built programming language About The Project R.S.O.C. is a custom built programming language very similar to a low-level 8085 progra

Ravi Maurya 17 Sep 13, 2022
poetry2nix turns Poetry projects into Nix derivations without the need to actually write Nix expressions

poetry2nix poetry2nix turns Poetry projects into Nix derivations without the need to actually write Nix expressions. It does so by parsing pyproject.t

Nix community projects 405 Dec 29, 2022
Multiple GNOME terminals in one window

Terminator by Chris Jones [email protected] and others. Description Terminator was

GNOME Terminator 1.5k Jan 01, 2023
A discord group chat creator just made it because i saw people selling this stuff for like up to 40 bucks

gccreator some discord group chat tools just made it because i saw people selling this stuff for like up to 40 bucks (im currently working on a faster

baum1810 6 Oct 03, 2022
ASCII-Wordle - A port of the game Wordle to terminal emulators/CMD

ASCII-Wordle A 'port' of Wordle to text-based interfaces A near-feature complete

32 Jun 11, 2022
This app converts an pdf file into the audio file.

PDF-to-Audio This app takes an pdf as an input and convert it into audio, and the library text-to-speech starts speaking the preffered page given in t

Ojas Barawal 3 Aug 04, 2021
Python programs, usually short, of considerable difficulty, to perfect particular skills.

Peter Norvig MIT License 2015-2020 pytudes "An étude (a French word meaning study) is an instrumental musical composition, usually short, of considera

Peter Norvig 19.9k Dec 27, 2022
Drop-down terminal for GNOME

Guake 3 README Introduction Guake is a python based dropdown terminal made for the GNOME desktop environment. Guake's style of window is based on an F

Guake 4.1k Dec 25, 2022
A conda-smithy repository for boost-histogram.

The official Boost.Histogram Python bindings. Provides fast, efficient histogramming with a variety of different storages combined with dozens of composable axes. Part of the Scikit-HEP family.

conda-forge 0 Dec 17, 2021