(hint: see line 14.)
Chess written in sed
11–20 of 57 posts
For bonus points, guess what this sed script does:
Re: Chess written in sed
#12Of course it was done by somebody Russian.
Re: Chess written in sed
#13It's, like, really really bad at chess.
Re: Chess written in sed
#14There appears to be a bug. Here is the state I reached (notice that "white" now has two bishops of the same color).
a b c d e f g h
8 ♖ ♘ ♗ ♕ ♔ ♘ ♖
7 ♙ ♙ ♙ ♙ ♙ ♗
6
5 ♙
4 ♝ ♟ ♟
3 ♙
2 ♟ ♟ ♟ ♟ ♟ ♟
1 ♜ ♞ ♝ ♚ ♞ ♜
Someone want to submit a pull request? :-)edit: For anyone who wants to reproduce ("black" went first, since black appears as white on the board)
1. e4 h5
2. d4 h4
3. Bb4 h3
4. Qf3 g5
5. Qxf7 Bxf7??Re: Chess written in sed
#15It's, like, really really bad at chess.
"The marvel is not that the bear dances well, but that the bear dances at all."
Re: Chess written in sed
#16It's, like, really really bad at chess.
and if you make illegal moves, it just moves again
Re: Chess written in sed
#17There's an error in line 1024. The transform strings are not the same length.
I'd like to see more sed programs on HN instead of the usual Python, Ruby or Go offerings.
I wrote a sed version of the the Python script "youtube-dl". This way I don't need Python installed to download YouTube videos. And it's easy to edit if YouTube suddenly changes their "API"; no need to wait for someone else to fix their Python or Lua script. In truth, it's not pure sed though. It uses sh (not bash), sed and ftp (or any other http client that handles 302's).
Re: Chess written in sed
#18sed, and also awk, and ed, are worth learning. I mean coding a chess game in those tools is just a novelty, but you can do so much really useful text processing with just those tools, and they are pretty much guaranteed to be available on almost any *nix machine.
Re: Chess written in sed
#19It's, like, really really bad at chess.
This is more about being very good at sed than bad at chess, really :)
Re: Chess written in sed
#20At one time, I became interested in the Turing-completeness of sed, and I started working on primitives for flow control and function calls. Then, I came to my senses.