An open API service indexing awesome lists of open source software.

https://github.com/lemonyte/terminal-snake

The classic Snake game, in your terminal.
https://github.com/lemonyte/terminal-snake

ascii game pyco python snake snake-game terminal

Last synced: 4 months ago
JSON representation

The classic Snake game, in your terminal.

Awesome Lists containing this project

README

          

# Terminal Snake

The classic Snake game, in your terminal.

![Screenshot](https://user-images.githubusercontent.com/49930425/220823010-501ac047-e6de-40cd-b0ef-8ea8f13a8272.png)

This project was created as a demo for the [Pyco](https://github.com/lemonyte/pyco) library.

## Installation

With uv:

```shell
uv tool install git+https://github.com/lemonyte/terminal-snake
```

With pip:

```shell
pip install git+https://github.com/lemonyte/terminal-snake
```

Requires [Python 3.9](https://www.python.org/downloads/) or higher.

## Usage

### Command line

```shell
snake [--auto] [--speed ]
```

The `auto` flag will let the snake control itself.
The `speed` option controls the speed of the game in updates per second. A value of 0 translates to no delay, so the game will run as fast as possible.

### Controls

| Key | Description |
| ------------------------------ | -------------- |
| ESC or q | Exit the game |
| SPACE | Pause the game |
| w | Move up |
| a | Move left |
| s | Move down |
| d | Move right |

When resizing the terminal, pause and unpause the game with SPACE to update the internal pixel grid accordingly.

## Contributing

Contributions are welcome!

### Challenge

If you have an implementation for the [CPU snake player](src/snake/auto.py) that can achieve a higher score or win the game, please do open an issue or pull request.

## Removed features

The previous version of this game had a number of features that were removed due to implementation complexity.
They may be added back later.

- Looping through walls
- Configurable colors
- Snake speed based on length

## License

[MIT License](license.txt)