Chess written in sed
31–40 of 57 posts
Re: Chess written in sed
#32Earlier quoted context omitted.
What's an example of something non-interactive that ed is good for that you can't easily do with other tools?
OK I'll bite. For this answer I'll assume "easily" to mean "with less typing". 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…
Re: Chess written in sed
#33- It routinely moves bishops vertically.
- It lets you make illegal moves yourself (not a huge deal).
- I got a square turning black for no reason.
Might also be nice if it told you what move it just made.
Re: Chess written in sed
#34sed, 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?
That said, I've recommended learning Python to a few people, but have never even suggested anybody learn sed or awk.
Re: Chess written in sed
#35Earlier quoted context omitted.
What's an example of something non-interactive that ed is good for that you can't easily do with other tools?
I use sed in makefiles, to scrape the source code for a version number, and then embed that version number in the name of the executable to be built. That would be easy enough in, say, Python, but as a sed script it's lightweight, decently readable, and puts everything you need to know right there in the makefile. That said, I've recommended learning Python to a few people, but have never even suggested anybody learn…
Re: Chess written in sed
#36For bonus points, guess what this sed script does: http://pastie.org/8261668 (hint: see line 14.)
Re: Chess written in sed
#37Re: Chess written in sed
#38There 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??
On my first game I got an even better bug: 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 perh…
Re: Chess written in sed
#39This 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.
Do you have a link to that?
Re: Chess written in sed
#40For bonus points, guess what this sed script does: http://pastie.org/8261668 (hint: see line 14.)