Live data from Hacker News

Show HN: 3D shooter in your terminal using raycasting in Awk

github.com

31–40 of 57 posts

Re: Show HN: 3D shooter in your terminal using raycasting in Awk

#31
post #22

General greatness aside, I have to say that's the best quality awk code I've seen. Too many people treat writing awk like picking up after your dog - something to get done quickly, when you have to. Which leads to write-only line noise code, which leads to people treating awk like picking up...

I used to write a fair amount of AWK code back in the day. It was great for one-liners, but I wrote some more elaborate programs in it too. I treated it seriously, like a real programming language, and it served me well.

My favorite AWK program was probably my LaserJet II code listing program from 1991. I wrote this out of frustration with the terrible default listings I got when I printed source code. The AWK code did a "two-up" printout of source code: two pages of code per page of paper in landscape mode. It used a nice font and drew graphic boxes around the pages. I was in the habit of using separator lines like this in my code:

//-------------------------------------

So the program found these and changed them to graphic line separators. It also avoided splitting a function onto two pages if it could - it would leave whitespace at the bottom of a page instead, filled in with a faint dot pattern.

Somewhere I have a printout I made with this program; I was hoping to find it and scan it in to show what it looked like. I know it's here somewhere, but in the meantime the source code will have to do:

https://github.com/geary/awk/blob/master/LJPII.AWK

Of course, these days I hardly ever print out any code. But back then we printed everything.

Re: Show HN: 3D shooter in your terminal using raycasting in Awk

#32
post #26
post #7

Earlier quoted context omitted.

I guess 20 years ago CS students weren't told to "write a Doom-like game" as an awk homework =)

Well, there were those bored days with a TI-83... shudders at TI-BASIC

My son spends a ton of his class time programming games into his TI-83. He even built his own Final Fantasy type game (when he really should have been doing classwork). He built a battle system, and even a merchant/vendor for buying upgrades. I had a lot of fun playing his game, and offered him some ideas for improvement (which, again, were made during class time).

And yet, I can't get him to sit down and put any time into programming on a computer. Sigh.

Re: Show HN: 3D shooter in your terminal using raycasting in Awk

#33

My go-to-awk-guru-friend and I had fun playing with your game---if you couldn't tell by the PRs ;)

Thanks to you and everyone for contribution. Seeing people care about this little project reminds me why I decided to do programming for a living.

As for the PRs, apparently I've slept through all the action =) I'll get back to them as soon as I can.

Re: Show HN: 3D shooter in your terminal using raycasting in Awk

#34
post #22

General greatness aside, I have to say that's the best quality awk code I've seen. Too many people treat writing awk like picking up after your dog - something to get done quickly, when you have to. Which leads to write-only line noise code, which leads to people treating awk like picking up...

I used to write a fair amount of AWK code back in the day. It was great for one-liners, but I wrote some more elaborate programs in it too. I treated it seriously, like a real programming language, and it served me well. My favorite AWK program was probably my LaserJet II code listing program from 1991. I wrote this out of frustration with the terrible default listings I got when I printed source code. The AWK code d…

Years ago I wrote a compiler (for bytecode) in awk. Ummm... http://cowlark.com/mercat, although you'll need to wade through zip files to get at the source. It was 1.6kloc for a fully typed algolish language producing stack-based bytecode.

awk's a lovely little language, and deserves to be better known than it is. Its two big failings are local variable syntax and absence of structured types... and the standard library's a bit mad in places (gsub, sigh). But it's expressive and concise and still readable, and meets its core competency of doing easy text processing beautifully.

The most recent thing I wrote in it was this:

https://github.com/EtchedPixels/FUZIX/blob/master/Applicatio...

That's a C file which is also an executable shell script which contains an embedded awk script. The whole thing's a Forth interpreter. Running the file uses the awk script to compile a Forth subset into bytecode and patch the source file with the new bytecode, which allows me to keep the whole thing in a single source file. It's not what I'd call good awk, but it's incredibly effective awk...

Re: Show HN: 3D shooter in your terminal using raycasting in Awk

#35
post #19
post #17

Man, that AWK looks a helluva lot like Javascript.

As in Javascript, awk represents all numeric values using double precision floating point. I have always thought that was a strange (but not necessarily bad) choice for a language that is basically all about text processing. I guess it works out pretty well if you need to do 3D graphics math. There is a bit of cheating going on here though. Awk doesn't support true multidimensional arrays. They are depending on a Gaw…

Double precision floats can losslessly manipulate integers with up to 56 bits precision, so you get the best of both worlds with no extra effort.

Re: Show HN: 3D shooter in your terminal using raycasting in Awk

#36

Like a sculpture made out of snot,you can applaud the elegance of the sculpture, and the elegance of the construction, but you have to wonder about the building material...

I so wish I had written this (and I've done some really evil shit in my time). So, so wish. It's awesome.

Re: Show HN: 3D shooter in your terminal using raycasting in Awk

#37

Like a sculpture made out of snot,you can applaud the elegance of the sculpture, and the elegance of the construction, but you have to wonder about the building material...

That's exactly how I felt about cool games made with Flash.

Re: Show HN: 3D shooter in your terminal using raycasting in Awk

#38
I was inspired to check out AWK after reading this sentence from the book Masterminds of Programming:

"If I had to choose a word to describe our centering forces in language design, I’d say Kernighan emphasized ease of learning; Weiberger, soundness of implementation; and I, utility. I think AWK has all three of these properties."

Re: Show HN: 3D shooter in your terminal using raycasting in Awk

#39

Like a sculpture made out of snot,you can applaud the elegance of the sculpture, and the elegance of the construction, but you have to wonder about the building material...

Ah but awk is great! It's parsimony when processing structured text files is hard to beat. Such a pity the next step on from it is perl. Perl is snot certainly.

No, the next step from awk is ruby :-D.

Anyways, I was talking about how this thing totally misappropriated awk, not awk itself.

Re: Show HN: 3D shooter in your terminal using raycasting in Awk

#40

Like a sculpture made out of snot,you can applaud the elegance of the sculpture, and the elegance of the construction, but you have to wonder about the building material...

That's exactly how I felt about cool games made with Flash.

Oh, don't get me started on flash. AS is alright, but flash is a load of rubbish, and I am so glad that we are almost clear of it.
Post reply on HN