Zurück zum Ranking

donno2048/snake

Assemblydonno2048.github.io/snake/

A 54 bytes snake game in x86 assembly

dossnake-gamex86code-golfsizecodingassembly-languagelow-level
Sterne-Wachstum
Sterne
1.4k
Forks
40
Wochenwachstum
Issues
0
5001k
Sept. 2021Apr. 2023Dez. 2024Juli 2026
README

54-byte snake game

Snake QR Code and README generation, and site deployment

This is a minimal x86 assembly snake game for DOS.

This code golfing project shows the extreme binary footprint optimizations possible on x86.

There is also a version that requires no BIOS, bootloader or OS.

Running

Online demo

You can try the game in the online demo, which updates for every change to snake.asm.

Use your arrow keys, and the pause key to pause/unpause on PC, or swipe on mobile.

Self-hosting

To test it just run main.sh or main.bat and open http://localhost:8000.

Motivation

The project was inspired by MattKC's video, "Can you fit a whole game into a QR code?".

It was made to create the smallest "fun" game possible.

For the people mentioning jinX's snake64 I'd note that without disparaging the achievement made by jinX, his implementation does not obey the same restrictions mine does: In his version, the snake can go through the right side directly to the left side but not from top to bottom, food items randomly spawn so there could be 30 simultaneously, some random pixels are turning white, you need to use 4, 6, 8, 2 keys to move instead of the arrows, you must start the game with downwards movement or it crashes, you have to clear the screen before starting the game, you have to initialize the correct video mode ahead, when you go through the top and supposed to lose you can just go back down, and as jinX stated "It will not work if you run a game from DOSBox terminal. It requires 0 (or 50h, 80h, 0D0h...) value in port 60h on start."

For the countless people saying I'm intentionally not mentioning the Hugi Size Coding Competition (a competition in which the competitors had to make the smallest nibbles game to win) here is my reply to one such comment (from when the game was still 133 bytes):

Firstly, it seems that you didn't even read the rules of the "Nibbles" game:

in the inside of this border a "snake" is supposed to grow, whose size is one pixel at the beginning. after starting the program, the snake's size shall grow one pixel more in each repetition of the program's main-loop.

Which is simply not the same as snake and a lot less difficult to implement.

Secondly, the implementations from this competition have flaws (not that they're not good but I'm saying it doesn't make my version bad) like, for example from the comments in the winning entry:

game can't handle any other keys but keypad arrow keys, you need to start it by typing pause|nibbles in DOS prompt and then hitting an arrow key

and

Because top memory segment in PSP is environment dependant[sic] you need version suitable for your environment

and it doesn't even work on DOSBox because of some special configurations needed.

From the second place entry:

When starting this program, press the 2 (DOWN) key __IMMEDIATELY__

And it too won't work without setting the cycle count and changing it sometimes breaks the game

As for the third place

press '8','4','6' but not '2' once game begins immediately

and the game breaks in the same way the second place does (and needs the same cycle adjusting) but the walls are also broken.

I'll look at the fourth place entry and stop wasting my time doing this,

Well, just looked at it and couldn't make it to boot

And lastly, what place is your entry to the competition? Before you criticize other people first check your criticism is correct and try doing it yourself before you judge.

Thanks for the feedback anyways :)

P.S. I didn't even claim my version was ideal, the main point of the post was asking for help, and this comment actually made me feel better about my implementation in a way, as in an actual size optimization competition someone had a submission of 121 bytes for just a line extending over the screen and my entire snake game (which obviously contains this functionality just as a small part of the entire program) takes only 12 bytes more now, and if I can fix the PR only 7 bytes more.

AFAIK This is the smallest snake game ever made.

Perspectives

At 54 bytes the compiled binary is so small it can fit it into a single QR:

QR Code
Hex
c57800b80a20
9992cd105b89
fc00cc96300c
7af9bed007e4
60f6ead414d5
44989301c301
f0ab103074e3
7b890c29d675
fa5e883479de

How little is 54 bytes?

  • Even a simple sentence like this one weighs more than 60 bytes.
  • And so does this arbitrary pair of emojis: 👩🏼‍❤️‍💋‍👨🏼👩🏼‍❤️‍💋‍👨🏼
  • An empty C program compiled with gcc -w -xc - <<< "main;" on linux-x86_64 is 15776 bytes.
  • An empty C program compiled with size optimization, no startup code, no standard libraries, no main or _start functions, no symbol information, and no code at all, compiled with gcc -Os -nostartfiles -nodefaultlibs --entry 0 -Wl,--strip-all -xc /dev/null on linux-x86_64 is 9056 bytes.

Comparison

My version MattKC's version ibara's version EimaMei's version
Bytes 54 ~1400 (compressed) 2024 2953
QR QR Code
Link https://github.com/donno2048/snake https://mattkc.com/etc/snakeqr/ https://github.com/ibara/snakeqr https://github.com/EimaMei/snake-qr

Media coverage

The game has been featured on many sites, among them:

Technical details

  • Assembled with NASM
  • Written in 16-bit x86 assembly
  • Compatible with all x86 CPUs
  • Running in real mode
  • QR Code encoded using qrencode
  • Currently using a version 4 QR Code
  • Demo deployed using GH actions
  • Demo hosted using GH pages
  • Local hosting using Python
Ähnliche Repositories
MatrixTM/MHDDoS

Best DDoS Attack Script Python3, (Cyber / DDos) Attack With 56 Methods

PythonPyPIMIT Licenseddosddos-attacks
16.4k3.6k
rwv/chinese-dos-games

🎮 Chinese DOS games collections.

PythonPyPIGNU General Public License v3.0dosgame
dos.lol
10.2k1.3k
pavel-odintsov/fastnetmon

Very fast DDoS sensor with sFlow/Netflow/IPFIX/SPAN support

C++GNU General Public License v2.0fastnetmonddos
3.7k587
gkbrk/slowloris

Low bandwidth DoS tool. Slowloris rewrite in Python.

PythonPyPIMIT Licensedosdos-attack
2.8k733
epsylon/ufonet

UFONet - Denial of Service Toolkit

PythonPyPIdosddos
ufonet.03c8.net
2.5k635
dosbox-staging/dosbox-staging

DOSBox Staging is a modern continuation of DOSBox with advanced features and current development practices.

C++Otherdosboxdos
dosbox-staging.org
1.7k230
C0nw0nk/Nginx-Lua-Anti-DDoS

A Anti-DDoS script to protect Nginx web servers using Lua with a HTML Javascript based authentication puzzle inspired by Cloudflare I am under attack mode an Anti-DDoS authentication page protect yourself from every attack type All Layer 7 Attacks Mitigating Historic Attacks DoS DoS Implications DDoS All Brute Force Attacks Zero day exploits Social Engineering Rainbow Tables Password Cracking Tools Password Lists Dictionary Attacks Time Delay Any Hosting Provider Any CMS or Custom Website Unlimited Attempt Frequency Search Attacks HTTP Basic Authentication HTTP Digest Authentication HTML Form Based Authentication Mask Attacks Rule-Based Search Attacks Combinator Attacks Botnet Attacks Unauthorized IPs IP Whitelisting Bruter THC Hydra John the Ripper Brutus Ophcrack unauthorized logins Injection Broken Authentication and Session Management Sensitive Data Exposure XML External Entities (XXE) Broken Access Control Security Misconfiguration Cross-Site Scripting (XSS) Insecure Deserialization Using Components with Known Vulnerabilities Insufficient Logging & Monitoring Drupal WordPress Joomla Flash Magento PHP Plone WHMCS Atlassian Products malicious traffic Adult video script avs KVS Kernel Video Sharing Clip Bucket Tube sites Content Management Systems Social networks scripts backends proxy proxies PHP Python Porn sites xxx adult gaming networks servers sites forums vbulletin phpbb mybb smf simple machines forum xenforo web hosting video streaming buffering ldap upstream downstream download upload rtmp vod video over dl hls dash hds mss livestream drm mp4 mp3 swf css js html php python sex m3u zip rar archive compressed mitigation code source sourcecode chan 4chan 4chan.org 8chan.net 8ch 8ch.net infinite chan 8kun 8kun.net anonymous anon tor services .onion torproject.org nginx.org nginx.com openresty.org darknet dark net deepweb deep web darkweb dark web mirror vpn reddit reddit.com adobe flash hackthissite.org dreamhack hack hacked hacking hacker hackers hackerz hackz hacks code coding script scripting scripter source leaks leaked leaking cve vulnerability great firewall china america japan russia .gov government http1 http2 http3 quic q3 litespeedtech litespeed apache torrents torrent torrenting webtorrent bittorrent bitorrent bit-torrent cyberlocker cyberlockers cyber locker cyberbunker warez keygen key generator free irc internet relay chat peer-to-peer p2p cryptocurrency crypto bitcoin miner browser xmr monero coinhive coin hive coin-hive litecoin ethereum cpu cycles popads pop-ads advert advertisement networks banner ads protect ovh blazingfast.io amazon steampowered valve store.steampowered.com steamcommunity thepiratebay lulzsec antisec xhamster pornhub porn.com pornhub.com xhamster.com xvideos xvdideos.com xnxx xnxx.com popads popcash cpm ppc

LuaMIT Licensecloudflareanti-ddos
1.6k310
haileys/doslinux

Run Linux programs on DOS

COtherdoslinux
1.6k42
alexfru/SmallerC

Simple C compiler

CBSD 2-Clause "Simplified" Licensec-compilercompiler
1.6k173
caiiiycuk/js-dos

The best API for running dos programs in browser

TypeScriptnpmjsbrowser
js-dos.com
1.3k179
jeffpar/pcjs

The original IBM PC and other machine emulations in JavaScript

JavaScriptnpmOtheribm-pcjavascript
pcjs.org
1.2k178
dethrace-labs/dethrace

Reverse engineering the 1997 game "Carmageddon"

CGNU General Public License v3.0cgamedev
twitter.com/dethrace_labs
1.2k79