News for hackers. Stuff that matters.
Re:A first person shooter in 571 lines of GNU Awk (2017) by oweiler on Thursday January 19, 2023 @02:56PM (#34444811)
I am shocked how readable the code is. Was expecting some Perl-like spaghetti.
Re:A first person shooter in 571 lines of GNU Awk (2017) by userbinator on Thursday January 19, 2023 @03:29PM (#34445189)
You could say that the code isn't really awkward to read.
Re:A first person shooter in 571 lines of GNU Awk (2017) by amalgamated_inc on Thursday January 19, 2023 @04:35PM (#34445946)
That's what she sed
Re:A first person shooter in 571 lines of GNU Awk (2017) by gchamonlive on Thursday January 19, 2023 @06:22PM (#34447068)
Mom! They spilled Reddit all over my hackernews!
Re:A first person shooter in 571 lines of GNU Awk (2017) by amalgamated_inc on Thursday January 19, 2023 @09:39PM (#34448530)
Go ask your father.
Re:A first person shooter in 571 lines of GNU Awk (2017) by ufo on Thursday January 19, 2023 @04:22PM (#34445784)
I was hoping for some clever abuse of AWK's patterns & regexes but clean code will also do :)
Re:A first person shooter in 571 lines of GNU Awk (2017) by mths on Thursday January 19, 2023 @06:26PM (#34447097)
For that, to start with, you'd need to be able to create a feedback loop of awk's output back to itself as input. For it not to interfere with rendering, it needs to be on a separate file descriptor from stdout.

I found this snippet on stackexchange showing how exactly that is possible on Linux.

> echo hello | gawk '!length{exit(0)} {print; print substr($0,2) >"/dev/fd/3"; fflush()}' 3>/dev/fd/0

This "renders" on stdout then feeds itself more input on /dev/fd/3.

Re:A first person shooter in 571 lines of GNU Awk (2017) by ufo on Thursday January 19, 2023 @08:56PM (#34448258)
Wow
Re:A first person shooter in 571 lines of GNU Awk (2017) by nsxwolf on Thursday January 19, 2023 @06:00PM (#34446837)
I always avoided awk because I thought it was just a really weird looking alternative to sed. When it's nicely formatted like this it looks like a perfectly sensible C-like language.
Re:A first person shooter in 571 lines of GNU Awk (2017) by mseepgood on Friday January 20, 2023 @06:08AM (#34451473)
Awk reads quite javascripty. JavaScript's function syntax was copied from awk.