5 ms·
PSChess – A chess engine in PostScript
- tromp 3y agoA nice showcase of Postscript's abilities, which I first became aware of around 1990, when I sent a tiny program to a Postscript printer to generate a 1024x1024 maze, taking half a day to finish. The graphics are simple but good looking. The engine is weak as expected for a tiny engine. The game I played with my first 4 moves of e2e4, d2d4, e4e5, and d4d5 resulted in checkmate on move 18. I wasn't sure if it would accept en-passant capture but it did. Other tiny engines like Micro-Max [1] and nanochess [2] are much stronger. An interesting long running (2009-2021) discussion between their authors may be found on the chess programming forum [3]. [1] https://home.hccnet.nl/h.g.muller/max-src2.html https://home.hccnet.nl/h.g.muller/max-src2.html [2] https://nanochess.org/chess3.html https://nanochess.org/chess3.html [3] http://talkchess.com/forum3/viewtopic.php?f=7&t=26622 http://talkchess.com/forum3/viewtopic.php?f=7&t=26622
- deleted 3y ago[deleted]
- tambourine_man 3y agoPostScript is deep magic that I admire from a distance. This is some mad scientist stuff. Great work.
- robinsonb5 3y agoI've done a bit of PostScript programming in the dim and distant past - the most ambitious of which was a "pretty-printer" for the YAM email client on Amiga, which otherwise just printed emails as plain ASCII. I found PostScript to be one of those things where something "clicks" after a while, and I really started to appreciate the elegance and simplicity. The hardest part is the mental gymnastics required to track what's on the stack and in what order!
- beefburger 3y agoOP here. Indeed, hardest part is the initial mental gymnastics. This can be overcome by devising and enforcing some conventions that I wrote about in a separate article https://seriot.ch/projects/programming_in_postscript.html https://seriot.ch/projects/programming_in_postscript.html
- deleted 3y ago[deleted]
- llm_trw 3y agoIf you want an accessible introduction to postscript that does a bunch of very pretty pictures you can't go wrong with: https://personal.math.ubc.ca/~cass/graphics/text/www/ https://personal.math.ubc.ca/~cass/graphics/text/www/ I particularly like chapter 14 where you implement 3d shader in postscript.
- enriquto 3y ago> PostScript is deep magic Why do you say that? It's a very simple and tiny language that you can learn in an afternoon. Far from the utter complexity of modern things. It's barely more complicated than a programmable calculator. Certainly simpler, cleaner, and arguably more powerful than svg graphics. You don't even need to read any manual to guess what this example program does: 100 100 moveto 200 300 lineto stroke
- alex_lav 3y agoI have absolutely no idea what that program is intending to do, such that I can’t tell if you’re joking.
- tambourine_man 3y agoIt draws a straight line.
- mattsan 3y agox coord, y coord, command that consumes the arguments from what we can infer is pushed onto a stack beforehand
- koito17 3y agoYour guess is as good as mine, but I assume it draws a line from coordinates (100, 100) to (200, 300)
- tambourine_man 3y agoThe drawing part is pretty straightforward. It’s the stack-based approach and reverse Polish notation thing that trips me off. Very cool stuff, but not what I do day to day, so it’s a bit intimidating at first.
- lxgr 3y agoI’d most certainly need to read a manual to know what this does. Is there an implicit bounding box? How large is it? Does x or y go first in the parameters? > Certainly simpler, cleaner, and arguably more powerful than svg graphics. Much more powerful, I agree. Some might even say a bit too powerful for a graphics description language, halting problem and all.
- coldcode 3y agoIt's not a terrible language; it just requires a little different thinking. In 1988/89, I learned to write a postscript generator with no dev environment, just reams of paper. Debugging was hard since you had to add debugging print statements in the same document you were printing, which was hard if no printing occurred! I read Adobe Illustrator files, which were the precursor to PDF, so at least I had something to look at.
- WillAdams 3y agoFor folks who want to learn more, the "Green Book" _PostScript Language Program Design_ is a classic: https://www.goodreads.com/book/show/3883749-postscript-language-program-design https://www.goodreads.com/book/show/3883749-postscript-langu... and _Thinking in PostScript_ was made available from the author's site and is widely available as a PDF: https://w3-o.cs.hm.edu/users/ruckert/public_html/compiler/ThinkingInPostScript.pdf https://w3-o.cs.hm.edu/users/ruckert/public_html/compiler/Th... For a more typical usage see: https://personal.math.ubc.ca/~cass/graphics/manual/ https://personal.math.ubc.ca/~cass/graphics/manual/ (I used to do PostScript programming on my NeXT Cube for custom fills and strokes in Altsys Virtuoso)
- alpacca-farm 3y agoOh, NeXT Cube and custom fills? That's pretty hardcore. Did you find programming in PostScript more intuitive compared to other languages, especially for graphical stuff?
- WillAdams 3y agoThe Cube was a gift, and the PS work didn't go that far. I found PS pretty inscrutable, esp. the function-filled variant used in Virtuoso, but did manage to get dimension lines coded up (which promptly ran into precision problems which I eventually gave up on). OpenSCAD is a lot more approachable, and METAPOST was easy to pick up and make use of: http://ftp.tug.org/TUGboat/tb40-2/tb125adams-3d.pdf http://ftp.tug.org/TUGboat/tb40-2/tb125adams-3d.pdf Still working through this at: https://willadams.gitbook.io/design-into-3d/3d-project https://willadams.gitbook.io/design-into-3d/3d-project and mostly using visual tools (which arguably is limiting me) https://www.blockscad3d.com/editor/ https://www.blockscad3d.com/editor/ and https://github.com/derkork/openscad-graph-editor https://github.com/derkork/openscad-graph-editor and of course, had to throw: http://pythonscad.org/ http://pythonscad.org/ into the mix. Still a bit miffed that Nodebox and Processing or maker.js weren't a good fit.
- ks2048 3y agoEven the official reference book ("red book" or PLRM, https://www.adobe.com/jp/print/postscript/pdfs/PLRM.pdf https://www.adobe.com/jp/print/postscript/pdfs/PLRM.pdf) is readable and very well done.
- anthk 3y agoZMachine in PS: gs -dNOSAFER zmachine.ps -- game.z3 http://zzo38computer.org/zmachine/interp/zmachine.ps
- ks2048 3y agoNice work! Interesting convention on naming procedures. I'm not sure I could deal with the verbosity, but it is probably a good idea for bigger programs. I've written neural network (ConvNet) in PostScript and this post has inspired me to finish it up and publish a blog post this week.
- zklzx 3y agoxxkndfvdjwxxxxxxxxxxxxxxxxxxxxxxxxypppppppxxxxoxoxxoxoxoxoxoxooxoxxooxoxxoxoxoxoxo
- Blamoso 3y ago[dead]