I like the old-school notion that I can just copy and paste it into vi and then compile with gcc. It just works. No complicated installation of a runtime or dependencies.
My favorite part is that you get a totally different dungeon each time you run it. It really is a working procedural generator, and not something more like a demo that only produces a single carefully selected result.
This is kind of a pet peeve of mine, but if you post simple, standalone code you really ought to post the compiled executable(s) as well. I don't currently have a C compiler installed on my home Windows box.
But you have to use the modified code in the comments above or you will get a :
main.c:8:7: error: variably modified ‘m’ at file scope
=80;i m[H][W];i g(i x) {r rand()%x;}
If he'd posted an executable, unless it was for exactly your platform, wouldn't you just have complained you didn't currently have a machine running the correct operating system on the correct hardware?
Not at all. Tiny textmode programs do not generally require specific hardware or OS versions. Windows/Mac/Linux should cover the large majority of users. Or you could just do Windows, since Unix machines (including Macs) most likely have gcc installed already. Or you could skip all that and include a Repl.it link, like Yorwba thoughtfully provided in the sibling comment.
If it did require specific hardware or software, that would be different, which is why I specifically said "simple, standalone code."
This is really cool, nice work (and sorry about your dog).
It reminds me that once upon a time the roguelike dev newsgroup had a "1k (source code) roguelike challenge".
The thread is here [1] and submissions are here in a slightly annoying format [2] but sadly I can't find the entry I remember, which I thought was in C and actually quite playable, if slightly at the mercy of the random number generator to make each new level solvable. Perhaps it was for a later iteration of the same challenge.
23 comments
[ 3.2 ms ] story [ 58.5 ms ] threadHere's some modified code that runs on my machine if pasted directly into bash:
gcc -x c - <<EOF
EOF./a.out
https://gist.github.com/femto113/28f69626acddc70a002ecead0b3...
Just expands the macros/typedefs and applies standard indenting, code is otherwise same as the original.
https://gist.github.com/munificent/ce8f7a9e6b09938ca8d2d43fa...
This is kind of a pet peeve of mine, but if you post simple, standalone code you really ought to post the compiled executable(s) as well. I don't currently have a C compiler installed on my home Windows box.
But more seriously, this is a toy implementation and the value is in reading it to see how it works, not in seeing its output
But you have to use the modified code in the comments above or you will get a : main.c:8:7: error: variably modified ‘m’ at file scope =80;i m[H][W];i g(i x) {r rand()%x;}
I swear the URL wasn't chosen by me.
If it did require specific hardware or software, that would be different, which is why I specifically said "simple, standalone code."
It reminds me that once upon a time the roguelike dev newsgroup had a "1k (source code) roguelike challenge".
The thread is here [1] and submissions are here in a slightly annoying format [2] but sadly I can't find the entry I remember, which I thought was in C and actually quite playable, if slightly at the mercy of the random number generator to make each new level solvable. Perhaps it was for a later iteration of the same challenge.
[1] https://rec.games.roguelike.development.narkive.com/3tm7xGpn... [2] https://sites.google.com/site/1024brl/