GithubHelp home page GithubHelp logo

angeljumbo / sssnake Goto Github PK

View Code? Open in Web Editor NEW
198.0 2.0 10.0 318 KB

cli snake game that plays itself

License: MIT License

C 98.91% Makefile 1.09%
autoplay curses game snake-game terminal tty ascii cli terminal-game snake-ai

sssnake's Introduction

sssnake

The classic snake game for the terminal that can play itself and be used like a screensaver. asciicast

Installation

You need ncurses :

apt install libncurses-dev       #Debian/Ubuntu/Mint
yum install ncurses-devel        #RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux
pacman -S ncurses                #Arch Linux
zypper install ncurses-devel     #OpenSUSE 
xbps-install -S ncurses-devel    #Void linux

With that you can just do:

git clone https://github.com/AngelJumbo/sssnake.git
cd sssnake
make
make install

Usage

You can check the manpage or use the -h option to see the details of what this program can do. So instead I would like to show you a few things that I like to run.

sssnake -m autopilot -s 15 -j 10

Watch the video

sssnake -m autopilot -s 15 -z -t -l ascii

Watch the video

sssnake -m screensaver -s 15 -z -x 8 -y 8 --try-hard 1

Watch the video

Planned features

Definitely be added

  • Pause key Spacebar is now the pause key.
  • Increase and decrease speed keys You can increase or decrease the speed with + and - in autopilot/screensaver modes.
  • An alternative/replacement to the A* algorithm (probably BFS) BFS is now available with: --short-path=bfs.

May be added

  • Hamiltonian cycles.
  • Custom colors.
  • IDA* to find the shortest path.

Faq

Can I control the snake?

Yes, that's the default mode or you can try the arcade mode where the game increases the speed every time you eat. The controls are wasd, the arrow keys or hjkl(vim keys).

Does the snake fills the entire screen/terminal with the autopilot?

If you use the "--try-hard" options the snake will get pretty close and sometimes it will fill the terminal. I implemented two algorithms "--try-hard 1" is good for big terminals/boards. You can test it running:

sssnake -m autopilot -s 15 --try-hard 1

"--try-hard 2" uses more cpu and it can get laggy with big boards but it has more chances to fill the board. Try:

sssnake -m autopilot -s 10 -x 10 -y 10 --try-hard 2

Neither of the two algorithms work well with junk.

Why the name "sssnake"?

All the snake games in the terminal that I found use ascii characters and lets be honest, they are kinda ugly. I try to do something more visually appealing, something "sexy" and it can play itself so it is "smart". Smart and sexy snake => sssnake.

A* vs BFS

At first this project was just an implementation of A* in the snake game, after finding chuyangliu's project I implemented their greedy solver with my A* instead of their BFS. Noticing that the behavior of the two implementations is different I decided to implement BFS in this project also as an alternative to A*. You can see the result here:

Watch the video

Commands of the video: For A*:

sssnake -m autopilot -x 20 -y 20 -s 17 --try-hard 2 -z

For BFS:

sssnake -m autopilot -x 20 -y 20 -s 17 --try-hard 2 -z --short-path=bfs

Credits

sssnake's People

Contributors

angeljumbo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sssnake's Issues

[feature] game field scaling

It would be neat, if one could configure for one unit to be n terminal rows and 2n terminal columns (nโˆˆโ„•).
This would allow a zoomed snake game without having to zoom in the terminal application itself.

Distro Packaging

Can you add a version and release tarball for distro packagers to reference?

Error in make

When trying to use the make, the following undefined reference happen:

/usr/bin/ld: /tmp/ccTdzNGY.o: in function `draw_point':
main.c:(.text+0x69d): undefined reference to `addwstr'
/usr/bin/ld: main.c:(.text+0x6b1): undefined reference to `addwstr'
/usr/bin/ld: main.c:(.text+0x6c5): undefined reference to `addwstr'
/usr/bin/ld: main.c:(.text+0x6d9): undefined reference to `addwstr'
/usr/bin/ld: main.c:(.text+0x6ed): undefined reference to `addwstr'
/usr/bin/ld: /tmp/ccTdzNGY.o:main.c:(.text+0x701): more undefined references to `addwstr' follow
collect2: error: ld returned 1 exit status
make: *** [makefile:5: sssnake] Error 1

Make does nothing

I just cloned to repo, and make tells me there is nothing to do:

$ git clone https://github.com/AngelJumbo/sssnake.git
Cloning into 'sssnake'...
remote: Enumerating objects: 248, done.
remote: Counting objects: 100% (63/63), done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 248 (delta 44), reused 43 (delta 32), pack-reused 185
Receiving objects: 100% (248/248), 121.15 KiB | 1.75 MiB/s, done.
Resolving deltas: 100% (154/154), done.
$ cd sssnake
$ make
make: 'sssnake' is up to date.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.