sed, 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.
Chess written in sed
21–30 of 57 posts
Re: Chess written in sed
#22There 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
#23This is a bit like that fellow who did pixel art by manually writing coloured table cells in HTML in Notepad - very, very impressive, but it does make one wonder a little about the person who has done it.
>very, very impressive, but it does make one wonder a little about the person who has done it. it has deep roots in the psyche of my old country: http://en.wikipedia.org/wiki/The_Tale_of_Cross-eyed_Lefty_fr...
Re: Chess written in sed
#24sed, 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
#25There 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
#26Re: Chess written in sed
#27sed, 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.
What's an example of something non-interactive that ed is good for that you can't easily do with other tools?
ed has a more concise syntax for joining arbitrary lines of a file (by line number or pattern) and then saving the file (by way of a temp file in $TMPDIR). You could do this with awk and perhaps with other standard tools (note: I don't consider perl to be "standard"). But I think it's safe to say the ed script would always be shorter. ed's syntax for deleting and moving arbitrary lines is similarly concise. For these specific tasks, it's not going to be easy to win at code golf using awk or other tools... and in some cases it may be impossible.
Re: Chess written in sed
#28Of course it was done by somebody Russian.
Re: Chess written in sed
#29There 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??
a b c d e f g h
8 ♔ ♛ ♝ ♘7 ♙ ♙ ♙ ♙
6
5 ♙
4 ♟ ♟ ♕
3 ♟ ♞
2 ♟ ♟ ♟ ♟
1 ♜ ♛ ♚ ♝ ♜
After performing en passant the computer went crazy and the King started taking all the pieces between down row 8. I ended up with a very easy checkmate as I walked my pawn the remaining three rows, unfettered even when it was under double pressure from the night and queen.
I wonder if this is perhaps an issue caused by the fact I used OS X's BSD sed.
Edit: Hmm, can't seem to format it right. Anyways, the bug seems to be present in gnu sed as well. Really the whole game was screwy. I started with e2 e4 and it all went down hill from their for my opponent :).