Get serious about your shell scripting skills and maybe you can pull this one off. It’s a game of snake played in a BASH shell. It seems like a coding nightmare, but the final product turns out to be organized well enough for us to understand and took less than 250 lines of code.
[Martin Bruchanov] started on the project after pining for an old DOS game called Housenka. It’s another version of the classic Snake game which we’ve coded ourselves and seen in several projects including this head-to-head version using musical recorders as controllers. When using a terminal emulator capable of ANSI sequences the game is displayed in color using extended characters.
We give [Martin] bonus points for the way he wrote about his project. It describes the mechanics most would be interested in, like how the user input is captured and what drives the update function and food generation. The rest of the details can be gleaned by reading through the code itself.
“Lets play: CLI snake over 300 baud serial line”
I guess well done… but really it is just another example of bash being used where a compiled application should have been. I wonder how much quicker a Linux machine would be if all it’s start-up scripts were replaced with real applications.
Pretty quick actually. At least right up until you wanted to customize something, in which case “I can’t edit it at all” roughly translates to a big zero for speed.
(If you’ll never get to where you want, it’s hard to claim progress is being made)
A good comparison of speed and feature would be to install a fresh Windows system.
Boots really fast! But we’ve all been there when banging our heads against a stone wall trying to get the OS to do something the makers didn’t intend :P
since when does windows boot up fast? my linux system has always booting faster then any windows box out there :/
Seconded.
Thirded.
Since Windows 8.
7 could boot fast with certain kinds of hardware. Ubuntu can be just a slow as windows, even with a clean install.
Well, there is systemd already.
For really bent shell scripts, here are some scripts that draw binary pixels directly to a Kindle eink framebuffer (native eink algorithmic art shell scripting):
http://www.mobileread.com/forums/showthread.php?t=172182
And here is one that also draws to the eink framebuffer, and also reads the binary input events for the Kindle Touch touchscreen, letting you draw on the screen with your finger (and save the results out to a display list file):
http://www.mobileread.com/forums/showthread.php?t=178356
The point is, a number of people had fun contributing to that as a sort of puzzle to see just how much you can bend a shell script to your will, doing things that many thought was limited only to “real” programming languages.
Are you kidding me?? As soon as my score broke 999,999, all hell broke loose. What a waste of six hours :(
Check out these games written in sed!
http://sed.sourceforge.net/#gamez
this has been done before… I made a hearts game in a CS class using escape codes to change the background and foreground to make the output look like cards….
there are also ascii demos that kick ass. they use an ascii filter on a bitmap.
hell, speaking of ascii filters, you can make this kind of stuff in gimp
How is he getting away with $[] in lieu of $(())? I can’t find the $[ ] syntax documented anywhere. If I find that it words without side effects, though, I’m stealing that idea for use in my own code.
He also reminded me that the “:” nop can take args, so I can hide arithmetic side effects there.
You learn something new every day.
Also, now that I know how to make a shell script respond instantly to individual key presses, that’s so getting used.
enjoyed playing it!
I’ve made a pretty simple text-based clicker game in shell script:
https://github.com/SngLol/Loading
Horisontal scroller with multiplayer.
https://github.com/vaniacer/piu-piu-SH