Game of Life in Postscript
smashr writes "It never really occured to me that postscript could be used for something other than printing, until I came across this page. Evidently someone has written the classic 'Game of life' entirely in postscript. You can even send it to the printer and have it output every single iteration.. now that would be a fun prank."
But can it play MP3's?
Sad memories of being a nine year old loser are flooding my brain at the mere mention of "The Game of Life".
Is it really a game if there is no real winner?
Postscript is a programming language - so you can 'program' in it... whatever you want. Even something like the game of life. Crazy huh? That's technology for you.
I find it impressive that a technology that's been around since 1985 is not only still usable, but it's used almost everywhere for printing and is also an extremely powerful language. If only more technology was created this way these days. Definitely a testament to the people who created postscript...
using namespace slashdot;
troll::post();
Didn't someone write a webserver in postscript?
:)
Anyway, most people know script it turing complete - this is hardly the greatest hack ever
But it's cool - i'm not being negative.
Postscript is very compatible with HP calculator programs because they both use RPN (reverse Polish notation). Pretty much any HP calculator game could be ported to Postscript fairly easily.
...it auto-generated ASCII porn.
it is well known that Post Script as a language can do this sort of tricks ... just not try this on a true printer, and if you try plz use recycled paper :-)
Ok, someone write an OS in it.
PS-HTTPD - a webserver in PostScript.
Marxism is the opiate of dumbasses
..THIS game of life.. I couldn't quite understand out how that was going to work as it got spewed out of a printer :)
"Hey! Unless this is a nude love-in, get the hell off my property!!"
I'm surprised noone has tried to make better use of this (Game of Life is nice and all, but not exactly useful...)
Wouldn't it be possible to use this to allow a printer to directly process form information into something printable?
I'm still a little unsure as to why we should use a scripting language to print. In my untrained, extremely naive opinion, printers should be sent the data that they are expected to print.
Shouldn't the actual processing of data be solely handled by the computer? I mean, this article clearly says that it can tie up the printer for a long time if you actually try this.
That postscript document has just one page that is never finished -- what you see on the ghostview screen is the first page being drawn, forever. So if you go and send this to a printer, the job never finishes and the printer "hangs" until you cancel the print job on the printer.
If you like this sort of thing, check out the PostScript Fractals page. You can print out very detailed images from tiny PostScript files.
I'll wait for the Quake port.
%!PS-Adobe-1.0 EPSF-10. % PS GoBan (c) 1996 by Laurent DemaillyD /f{fill}D/S{setgray}D .5 M 1 0 arc gsave f R .5 S s c M e c M e .3 M 270 360 arc s R}D 0 0 x 2 M 1 0 arc .9 .7 .5 setrgbcolor f s 0 S c c x{d
%%BoundingBox: 0 0 150 150 % *** http://www.demailly.com/~dl/go/ ***
/D{def} def/d{dup}D/e{exch}D/s{stroke}D/l{lineto}D/M{mul}
/R{grestore}D/m{moveto}D/z 9 D/c 15 D/x z c M D/p{42 sub d z mod 1 add e z idiv
1 add gsave 1 index c M 1 index c M c
c
c m d x l d c e m x e l}for s(BeJR\\IHP>=6U){p}forall 1 S(?TS[QcGZFOC){p}forall
I've never used it, but you're talking about PS-HTTPD.
Pretty cool, eh?
--
the strongest word is still the word "free"
In some contexts, the size of the file sent
to the printer is an important consideration.
Coding a page as the shortest computer
program that can generate the page is "the
best you can do". Of course, whether or not
dvips is generating the optimal program is
another issue entirely.
How about a PostScript ray tracer?
I have in a few cases wrote small PS programs
so my "program generated" figures would look
good in a paper. I have not been able to determine
I am can duplicate this task in PDF (w/out first
creating a PS file). Is it possible?
Another nice little postscript program can be found here
It's only about 10 lines long and creates a image with 2 bubbles and even reflections.
And if someone wants to learn Postscript:
A first Guide to Postscript
and client workstations booted from a CD ROM & had no hard disk
those guys knew their eggs but Windows had the muscle
There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
I wrote a program that substitutes occurances of one string with another one. You send it to the printer than laugh as everyone else's pages mysteriously have the word "this" replaced with "that". One time I loaded it on just before a friend printed his source code. He couldn't figure out for the life of him where his semicolons had gone! Ah... youth.
The best part is, the code stays resident until the printer is power cycled. This enables slightly more sinster uses for this sort of thing. One of my professors used to joke about using as program like this to change the numbers on his paycheck when it was being printed!
The code is still on my website near the bottom. It's called PSReplace.
It is a programming language (stack based, like forth), which is amazing for its primary purpose: printing.
But to call the language itself "extremely powerful" is an exaggeration. As a programming language it is quite primitive and incomprehensible, compared to more powerful languages such as C++, java, ML, yes even forth.
Now write a towers of hanio program utilizing the n-1 algorithm.
Using the 3 or more poles you created to move all the discs from smallest to largest from pole1 to polex (x being the greatest number or the opposite pole). Use the second pole as a temporary holding area.
http://saveie6.com/
Ok, I am finally prompted to write this... please forgive me but I feel compelled to comment.
There are two other times when I came to the realization that the tech community was sometimes way lost beyond the boundaries of practicality in addition to this latest thing. Once upon touring MIT and seeing the amazing amount of intellect dedicated towards uber mundane pursuits such as remotely identifying the inventory of a coke machine, and another situation at Siggraph seeing tens of millions of dollars wasted on research projects that had a snowball's chance in hell of developing practical applications for the findings.
Now I can appreciate the pursuit of a tech solution to something that's of interest, and I understand that things like Star Wars in ASCII are projects borne of love, but at the same time, I wonder, do tech people every try to achieve both in the same breath? Yes, you can add an ant farm to your PC case. But if you ever wonder why the mainstream looks at tech types as total weirdos, it's because they love to use as an example, these weird manifestations of our ability, when we all know, these are more the exception than the rule. Or are they?
So my question is, aside from the arguments where someone draws a reasoned path explaining how a tennis shoe with voice recognition will change society, is anyone concerned about the image of the tech community and finding more realistic ways to demonstrate the creativity and resourcefulness of nerds?
AAARRGGG
EVIL!
Please your giving me nightmares.
I can't believe that tons of people asked why someone would write an HTML browser in Java, but hardly anyone asked why someone would do this?
:)
Are you guys living in the real world?
That's nothing! In college, my compiler writing course was changed (to help "discourage ``re-use'' of previous years students' code") to writing a C compiler which used *PostScript* as its target language instead of XYZ machine code for PDQ processor.
We took the output of our compiler and "ran" it with ghostscript. It was actually quite fun. One of the harder parts was writing a suitable "libc" to "link" in for basic stdio.
"Shouldn't the actual processing of data be solely handled by the computer? I mean, this article clearly says that it can tie up the printer for a long time if you actually try this."
Isn't this the same kind of thinking that brought us the Winmodem and Winprinter? Hey! Anyone want to buy a WinGraphics card?
I remember writing my thesis back in early 90's. To ensure top fidelity in graphs and drawing, I hand crafted all illustrations in postscript. I got to know ps in depth :-)
not bad for a 16? 17? year old sophmore at high school. Quite impressive.
Woohoo! Now I can have that flip book story of evolution I've always wanted!
Most people know that Postscript is Turing-complete, but I think the game of Life is too. So for a _real_ challenge you could implement a Postscript interpreter in Life (provided you find some way to encode the input and some way to do 'showpage').
Actually, I don't know of any working Turing machine or lambda-calculus implementations in Life, but I believe it is thought possible.
-- Ed Avis ed@membled.com
Install Ghostscript first, then use GSView to open the .ps files.
By the mid-90s, Xerox had written what was basically a SmallTalk interpreter using GhostScript. It was called DocuScript.
With that, Xerox wrote all sorts of applications for hallway copiers, including web browsers, hang-man games, and image processing/manipulation applications.
Take a piece of paper with an image you want to copy. Circle the image. Scan it. Take a piece of paper that you want the image on. Mark where the image goes. Scan the paper. Output: new piece of paper with the image from the first on it and the other elements from the second piece.
Ooops, you dropped 200 pages of a paper on the floor, and you have gathered it up in the wrong order. Circle the page number on the first page of the paper. Scan the entire paper in. Output: your paper now resorted according page number.
Go to a hospital and triage yourself by taking a printed image of the human body and circling on the image where you hurt and scanning it in to the hallway copier.
Take your 100 page paper and scan it into the hallway copier. Get a one page token in return (containing, basically, an encoded URL) Fly across country to a conference holding only that one page token. At the conference scan in your token. Output your 100 page paper.
And then, being Xerox, they found they couldn't/wouldn't/didn't want to sell it. Talk about the Game of Life!
Change the code for more digits... ;)
http://www.wizards.de/~frank/pi.ps
I have a program for my Palm that lets me print from it via IR on IR enabled printers. Step 1: Download program Step 2: Find IR and Postscript enabled printer(s) Step 3: Annoy somebody beyond reason (NO PROFIT!!!!)
Conway's Game of Life is also turing complete; therefore, you can regard this PostScript hack as proof that PostScript is turing complete as well, since you could implement a turing machine on top of Life, on top of PostScript..... :)
pb Reply or e-mail; don't vaguely moderate.
Don Lancaster used to make a HUGE deal about writing stuff in Postscript. He used to have programs in _Byte_ magazine all the time that did number crunching, fractal calculations, etc, in Postscript on a printer and then printed out the results.
there was also a grey scale raytracer written in postscript that would trace and render completely in the printer... took a while though.
here:
/nerd power!
http://rendell.server.org.uk/gol/tm.htm
a computer you can watch!
I'd say that he should get a life, but he programmed himself one.
__
Men with no respect for life must never be allowed to control the ultimate instruments of death.
GW Bu
Apparently, no matter how many boxes I check, I just cannot avoid seeing stories about games on Slashdot. A-n-n-o-y-i-n-g.
(Context: debating an assertion that Conway's Game of Life has no end condition; therefore, it's not a game. wo1verin3 brings an analogy to Tetris brand games.)
do you know anyone who has "finished" Tetris?
Some falling tetramino games, including Tetris brand games, display fireworks and credits after the player has completed specific objectives. For example, in The New Tetris for N64, it's 500,000 lines summed over all games played.
Will I retire or break 10K?
Did anyone of you guys out there tried to print it out on a printer?
What I am interested in is to find out if only one page would be printed with more and more pixels on it or is every generation of the life producing a new page?
Isn't this the same kind of thinking that brought us the Winmodem and Winprinter?
Winprinters are usually easy to get working on an alternative OS because it's straightforward to get the computer to produce a bitmap that gets sent over the wire, provided that the printer's escape codes to print a bitmap are known. For example, old impact printers were winprinters, and software such as Broderbund's Print Shop let the user copy codes for "set graphics mode at x dpi" and "new line of pixels" out of the printer's manual. The biggest problem with winprinters comes when a manufacturer will not publish the printer's escape codes.
Winmodems, on the other hand, are covered by software patents.
Will I retire or break 10K?
NeWS.
Comment removed based on user account deletion
If you can do that much, imagine a cluster of printers, programmed in PS to do something else than... print.
who read the blurb and expected the printer to start printing out little cards reading "Teacher", "Doctor", "20,000", "100,000", etc? :)
You start with a document outline, then the first few objects number the pages, each one built with text and image objects.
At the end you have a map of the various objects, it's a pain in the ass to read, but at least Adobe lets you download the reference manual for free.
Some of the commands and concepts are similar to PostScript, and some of the commands are 2-3 character version of the 8 character PS commands.
The best source about PostScript as a programming language is book "Thinking in PostScript" (http://www.rightbrain.com/pages/books.html).
I read it originally to learn PostScript from a printing perspective, which was somewhat futile. Very little of the book actually talks about printing or page layout at all.
Anyhow, a quick read of the table of contents would be enough to understand that the Game of Life in PostScript is neither difficult nor terribly interesting.
c.
Log in or piss off.
I think we should all GET a life.
If you're happy and you know it read my blog
Nothing to do with postscript, but regarding Life, the early Windoze/OS2 accellerators based on the IBM 8514/A (ATI and I think Paradise made one) had enough logic to also calculate life, and quite a bit faster than the 486/33 that was the standard CPU at the time. There were books available documenting how to program the 8514 at the hardware level from DOS, which was pretty cool. The 8514 used 8 bits per pixel, and had logic to compare a pixel against a reference value, which would determine whether or not the pixel should be written. (The weird and frustrating part of the 8514 was that it didn't compare the source, so it wasn't great at doing sprites with transparent colors. But it could compare against the destination.) The 8514 could also perform 8 bit additive blits. So just jitter some additive blits to get a neighbor count, use the pixel compare (both less than and greater than supported) to kill the starving and overfed cells, and finally convert the living ones back to 1 or 0 for the next screen. Of course you needed a couple of offscreen buffers, and the small (1 MB?) amount of video ram prevented really large simulations. Now a days, the OpenGL Redbook explains how to implement Life, and the nVidia SDK also has an implementation of Life (implemented as a pixel shader?)
Hey a new printer DOS?
.ps proggie once it determines that the printer can do postscript {there are simple ways to do so}.... port 9100 DOS anyone? many big campuses have LOTS of printers on them....
How hard would it be for someone to write a program/worm that scans a local subnet for Jetdirects or printers to connect to and send them this little
Those who do not learn from history are doomed to repeat it.
NeWS was a peer of X-Windows, based on postscript; it was incredibly powerful and underpromoted. The only licensee that I recall was SGI: it was the basis of the IRIX window system in the early 90s. The language itself was an object oriented version of PostScript; the frameworks were entirely object oriented.
NeWS was canned because it couldn't compete commercially with (free) X11. For a humorous slant, check out the Unix Haters Handbook or this link.
Many of the language implementation ideas from NeWS went on to Java; James Gosling was a primary with both.
As an aside, this is an example of how "free" software dealt a death blow to demonstrably superior commercial software.
Yeah, you can do this kind of stuff in PostScript. When I was learning it I have written this little Postscrpt file that prints a new maze every time you send it to the printer.
Somebody write a seti@home client in postscript to help seek extraterrestial life forms using your printer's spare CPU power? Ahhh.... A beowulf cluster of printers...A postscript-based AI... Printers will take over the world!
45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
Anyone know how someone could go about that easily?
a fully functional programming language. Granted the syntax leaves something to be desired. In my NeXT days (I used to do OPENSTEP programming, I now am a major participant in GNUstep) it was well known that you could hack into a machine if the Display Postscript Server was set to "public" (meaning other machines can connect, like xhost + under X).
;)
I even heard that someone wrote a fully functional program to pull ANY file on a machine with DPS set to public.
Scary.. and very cool.
Later, GJC
Gregory Casamento
## Chief Maintainer for GNUstep
and Solaris 8 on a SunFire 800? Now, that's a high end printer.
PS can do some amazing things. I've written
a little bit in it, and in full ps, you can
write printer viruses (which propagate from
printer to printer over the net). At least,
you used to. Some of the needed functionality
has been disabled in newer printers. (I didn't
write one, but realized you could).
During the first major factoring challange
back in the early 90's, some of the sieving
step was done on postscript printers.
Peter Trei
Way back in the dark age circa 1993 there was an IRC server written in postscript. It was at MIT and could handle about 5 connections ... if you typed really slow and all five of you were in the same room. I never net the author but I truely marveled at the concept.
Back in the deep mists of time, I rented a Commodore PET computer. It had a game called "Lifewar" that was exactly as you described. I wasn't aware of Conway's Life back then, so I didn't grasp the game's significance. Knowing how to make some of the things like gunships and puffers could make for an interesting game... Well, if not interesting, certainly a lot less boring.
"I'm not impatient. I just hate waiting." - My Dad
Yep there was, you can find a copy of it here. There's also another one that you could literally print out on a business card here.
Cool stuff, I remember hearing about this in my raytracing class in college a while back.
Quote from orignal post: You can even send it to the printer and have it output every single iteration.. now that would be a fun prank." Send it to someone elses printer :) if you send it to your own you miss the point. Im going to try this at a office:)
java is a worthless joke, a play-pretend half attempt at platform independence. there is no such thing as a java binary. java is not compiled. it is an interpreted language that runs specially compressed source code. there is no virtual machine. JRE is a glorified GWBASIC platform. java is the worst thing to happen to programming in ages.
There is no such thing as bytecode. These "registers" are lies. There is no runtime stack. The javac executable is really a wrapper around gzip. This "JVM" is a fabrication concocted by the infidel authors of GWBASIC and does not exist. These cowards have no morals. I blame Al-Jazeera- they are marketing for Sun. God will roast their stomachs in hell. They are not in control of anything- they don't even control their own code! Be assured, our CPUs are safe and protected from compressed interpreted source code. We have placed their threads in a quagmire from which they can never emerge unless they throw an exception. Java is a snake and we will cut it in pieces!
Damn, I wish I were 14 and irresponsible again. Now I'm just irresponsible.
"It was a summer's tale: Just a boy, his Linux, and a head full of dreams..."
It looks like perl.
I used to love to play with Postscript. I also commutted on a chartered bus that went from the East Bay taking workers through Palo Alto and down to Nasa Ames research center. The Palo Alto stop was/is along research alley with PARC, SRI, etc. etc., near Stanford. One particularly brilliant passenger was from SRI. We compared Postscript tricks, he had my hex paper blown away (ok, almost any postscript trick had my hex paper blown away).
He had a post script program that would break up any image you gave it onto the page in such a way that when you made an oragami globe out of it the image was allong the surface. He had not done it mathematically, but by brute force, folding the oragami, marking the facets, unfolding the paper, then encoding the coordinate transforms necessarry.
Someone I know has built something to create genetic art via postscript. Here:
http://odur.let.rug.nl/~kleiweg/genart/genart.htm-- Alper
I haven't yet learned it myself, but I've talked to my roommate extensively about Forth. He uses it for embedded system development. Apparently, quite a bit is done in Forth using only the stack. He told me it took him a couple of years to completely assimilate the Forth way of thinking, but now he prefers it to the C way. He said he writes better C code now for having learned Forth. The trick seems to be writing very short, concise words and aggressively refactoring them whenever possible.
Now that's a cool (and useful) hack. The only downside is that you can't get the results back from the printer except on hardcopy.
If you're that concerned about what "society" thinks about cool, but useless hacks, I question how much of a nerd (or geek for that matter) you really are.
Isn't it really a procedural language? Does it have functions as first class objects and higher-order functions? I guess some definitions of "functional" only involve having functions.
How is PDF more device independent than PS?
Anybody remember the NeWS window system, it also had postscript programs in it. I'd be interested to know if there are some online documents or books about it.
When I was a kid we used to run AI benchmarks
in Apple LaserWriters. They were
faster at the nfib (naive Fibonacci) benchmark
than most computers at that time!
Out of the 21 printers we have at work, only six have no hard drive. Of course, I'm counting a couple of pure copiers among that six. Two or three of the bigger/faster ones have their own web server, so we can check up on job status and such.
My favorite is the one that has a storage server about the size of a G4 Cube and connects to the scanner and printer by IEEE 1394. Xerox Synergix 8850, iirc.
Of course, working at Kinko's kinda makes me giggle every time I see a little inkjet cranking away at a single sheet.
I'd be trying this out right now, except my Postscript printer is the CUPS Ghostscript driver, so it'd be kinda silly.
Well, that's certainly true, at least until things like MathML and SVG are universally implemented. Hopefully, XHTML + MathML + SVG + CSS will enable all the stuff needed for those types of documents without resorting to a page description language, but PS or PDF will still probably be preferable for printing.
Does anyone know whether any printers exist that speak native PDF? Or if not, why such a thing does not exist?
I'd love to see Linux integrate PDF as closely as OS/X does, but I know it's never going to happen until PDF is as useful as PS.
I did some Postscript programming back in the day, enough to print cool things on the printer and replace the NeWS splash screen with "Don't Panic" in nice friendly letters, and as other people have said, it's pretty much like Forth, a Reverse Polish sort of thing that lets you define functions that draw stuff. While Forth's inventors may have had an overblown estimate of his creation's validity (he basically reinvented the subroutine crudely and differently) it was a good language for very small environments, like toasters and embedded systems. It wasn't real clean, but it was very memory-efficient, and this made it tend to be pretty fast.
Bill Stewart
New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
Sun's NeWS Network Extensible Window System was more powerful and really cool, and as I've commented earlier in this thread, was an ancestor of Java. Both of them shared the Postscript property of getting printing to Just Work Correctly. Other people have commented that it had problems with the licensing being too proprietary, so it didn't catch on compared to X in spite of being better at some things and dangerously flaky at others and having one of the world's coolest debuggers. NexTStEp was somewhat limited by Sun's intellectual property, IIRC, but it's stuck around in various forms and its devotees really loved it.
Bill Stewart
New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks