2024-08-12 02:52:50 okay, I fleshed the random noise explorer into an actual roguelike where you try to collect all the treasures: http://canonical.org/~kragen/sw/dev3/wmaze.fs 2024-08-12 02:53:12 it's twice as much code with a semi-decent maze generator 2024-08-12 02:53:42 (which is still buggy actually) 2024-08-12 02:53:56 but it's a playable game 2024-08-12 02:57:17 I'm using union-find and Fisher-Yates shuffle in almost the canonical way to generate the maze. but it's not quite the canonical way, and consequently it generates some unreachable spaces (almost always just one block) and multiple paths 2024-08-12 03:10:45 an idea... sed -i -e 's/: width 80 ; : height 23 ;/form value width 1- value height/g' wmaze.fs 2024-08-12 03:22:55 that's an excellent idea! 2024-08-12 03:23:08 catching SIGWINCH might be tricky though 2024-08-12 03:23:48 hmm, pfe doesn't support `form` 2024-08-12 03:24:16 if pfe has some means of executing system shell commands 2024-08-12 03:24:53 the output of stty size will get the current tty's columns and rows 2024-08-12 03:25:40 true, and usually it's also in the environment 2024-08-12 03:26:36 ah a getenv for COLUMNS and LINES would definitely work 2024-08-12 03:27:01 on Unix anyway 2024-08-12 03:27:03 more efficient would be ioctl(STDOUT_FILENO, TIOCGWINSZ, ... somewhere 2024-08-12 03:27:39 hard to imagine system() will cost a significant fraction of a screen frame tho 2024-08-12 03:28:04 I usually remove the ability for games to do dangerous things like run arbitrary programs 2024-08-12 03:28:33 pledge() ? 2024-08-12 03:28:57 yep 2024-08-12 03:29:18 seems reasonable 2024-08-12 03:55:37 thrig: does pledge() allow blocking mmap() and friends as well? 2024-08-12 03:57:40 nevermind, found the man page and got answered 2024-08-12 04:11:40 I'm surprised to only find one implementation of Lisp in Forth online hehe 2024-08-12 04:19:43 til pledge 2024-08-12 04:20:12 seems useful for the forth bot I gave up on for security reasons 2024-08-12 05:01:39 unjust: I added in your idea and also added a victory animation if you collect all the treasure 2024-08-12 05:01:56 the mapgen is still buggy and will sometimes generate treasure in unreachable places though 2024-08-12 05:02:21 also it animates the initial maze construction 2024-08-12 05:02:57 nice 2024-08-12 05:06:19 that's a cool effect 2024-08-12 06:24:40 xentrac: here's an ugly hack of .board to add some colour: https://pastebin.com/raw/7NnkTWR5 2024-08-12 06:42:28 this game would be even better if you could collect explosives (maybe they'd be red if colour is enabled and are only appear for a short period of time) that you can use to blow up walls that keep you away from the cash 2024-08-12 06:42:48 s/are// 2024-08-12 06:46:09 kind of stealing the idea from bomberman, there could be a key dedicated to dropping a bomb - space could be an option, seeing as your thumb is likely to be over it if the rest of fingers are on hjkl 2024-08-12 07:22:17 the same, but slightly less wasteful with the SGR resets: https://pastebin.com/m7hPpt4i 2024-08-12 13:04:14 thanks! 2024-08-12 13:05:08 color is a good idea 2024-08-12 13:06:43 I'm not super happy with the factoring of the maze generator 2024-08-12 13:43:08 .board split into .board, paint & wrap? - https://pastebin.com/raw/xaFR9zjT 2024-08-12 13:45:55 what other ways could you split the maze generation up? 2024-08-12 14:11:34 I'm not sure, but it feels repetitive and like it's not much functionality for the amount of code 2024-08-12 14:20:38 it's amusing to browse the SGRed code with less -r 2024-08-12 14:21:03 heh, but why would you make gold green rather than yellow 2024-08-12 14:22:39 well the $ symbol makes me think of cash rather than gold 2024-08-12 14:22:46 and i like that green/cyan/dark blue palette 2024-08-12 14:23:29 ^ stealing from z/OS 2024-08-12 14:24:44 What's z/OS? 2024-08-12 14:25:11 a mainframe operating system 2024-08-12 14:25:28 https://en.wikipedia.org/wiki/Z/OS 2024-08-12 14:26:50 if you do an image search for: z/os ispf 2024-08-12 14:26:52 Who's maze game is this? 2024-08-12 14:27:09 you'll see where that colour scheme was borrowed from 2024-08-12 14:27:14 veltas: it's xentrac's game 2024-08-12 14:27:21 xentrac: Not tried running it but very nice code 2024-08-12 14:28:20 My advice would be don't obsess over having everything fit in one line, not that you've necessarily done that but if you're running out of good names for stuff, sometimes that means it's not worth factoring 2024-08-12 14:29:36 It looks quite tasteful and readable to me 2024-08-12 14:40:49 veltas: thanks! I'm not sure I agree it's tasteful and readable but I'm glad you think so :) 2024-08-12 14:42:39 I've said before I think Forth code is surprisingly readable 2024-08-12 14:42:51 my tendency to break things into tiny definitions is mostly for the sake of debugging 2024-08-12 14:43:03 You'd think it wouldn't be, but I think the difficulties in writing it produce more readable code in the end just out of necessity 2024-08-12 14:43:12 I mean you struggle to read your own code in Forth already lol 2024-08-12 14:43:16 haha yes 2024-08-12 14:43:28 Makes sense 2024-08-12 14:43:39 I spent quite a while yesterday trying to figure out why it was digging too many blocks 2024-08-12 14:44:03 being able to interactively do things like 31 dig 32 dig 33 dig .board was helpful there 2024-08-12 14:44:15 31 32 connected? . 2024-08-12 14:45:35 but it wasn't until I got up to make coffee for my wife that I realized that the problem was that connect? needed to family swap family at! instead of just at! 2024-08-12 14:46:05 it was stealing nodes from one union-find tree to graft onto another instead of grafting one union-find tree root onto the other 2024-08-12 14:46:55 I guess family at! would probably be sufficient (set the family of node B to node A) 2024-08-12 14:47:30 the array/at@/at!/ints words were pretty useful for debugging too 2024-08-12 14:48:13 I feel like breaking things into tiny definitions like this can hurt readability though 2024-08-12 14:53:54 Swings and roundabouts 2024-08-12 14:54:20 i think tiny definitions threaded into readable phrases in composite words makes things even more readable, imho 2024-08-12 14:54:37 well, it expresses the high-level intent more clearly 2024-08-12 14:55:10 but it conceals the low-level implementation and even the medium-level dataflow 2024-08-12 14:59:57 to debug or modify code, I need to understand not just the high-level intent but also the implementation 2024-08-12 15:03:05 unjust: When it works sure 2024-08-12 15:03:31 And they don't turn into weird symbols or nonsense words 2024-08-12 15:03:46 definitely 2024-08-12 15:03:53 something much easier said than done properly 2024-08-12 15:04:04 I'm kind of unhappy with my workflow 2024-08-12 15:04:14 And you're not just breaking out the thesaurus looking up load/read/slurp/etc 2024-08-12 15:04:33 I was editing code in Emacs, but to test it I was copying and pasting most of the program into fresh Gforth processes 2024-08-12 15:04:44 in a terminal emulator 2024-08-12 15:06:00 Sounds legit 2024-08-12 15:06:31 I'd like to do more in gforth itself, that's why I have a program that just copies everything I wrote into a file at the end 2024-08-12 15:06:39 yeah 2024-08-12 15:06:59 I'm still either copying stuff into gforth or occasionally INCLUDE'ing it 2024-08-12 15:07:00 Gforth in Emacs shell-mode is a little clumsy because of how echoing works 2024-08-12 15:07:58 older Forths including PFE support `forget`, which is really helpful for interactive development 2024-08-12 15:08:44 because the non-"obsolescent" Forth standard approach is to define a marker before each hunk of things you might want to forget 2024-08-12 15:15:34 is there a cleaner standard way to do this? 2024-08-12 15:15:35 : gamename c" wmaze" ; gamename find [if] wmaze [endif] drop marker wmaze 2024-08-12 15:15:58 (also whyy did `find` have to use a counted string?) 2024-08-12 15:18:37 New forths use MARKER 2024-08-12 15:19:09 It's not equivalent to FORGET at all, as far as I'm concerned there's no good reason new Forths can't implement FORGET 2024-08-12 15:20:14 I'd like to have a `forget?` which does nothing if the word you give it to forget up to isn't defined 2024-08-12 15:20:38 more practically though I'd like to be able to redefine words that already exist, like in Lisp 2024-08-12 15:20:55 but that completely breaks any kind of standards compatibility 2024-08-12 15:22:18 xentrac: i find connecting a named pipe to gforth's stdin and then using w! /path/to/pipe from ed or vim works well enough for me: https://ibb.co/BPdBCLq 2024-08-12 15:23:52 is the theory that you'll also write whatever debugging commands you'd like to invoke in the editor? 2024-08-12 15:24:19 oh, iix reads them from the terminal? 2024-08-12 15:24:59 iix reads from /tmp/pipe and writes to its child's (gforth's) stdin 2024-08-12 15:25:26 yes, the idea is that i can mess around in gforth with the code ad-hoc 2024-08-12 15:25:28 so it doesn't read anything from the terminal; it's an output-only pane 2024-08-12 15:26:02 it also reads its own stdin and writes that data to the child's stdin 2024-08-12 15:26:14 oh, so it *does* read from the terminal 2024-08-12 15:26:38 If I write a Forth I'll probably write the last 64 lines of history to 4 blocks as a circular buffer 2024-08-12 15:27:02 I mean write another Forth 2024-08-12 15:27:05 heh 2024-08-12 15:27:06 not a bad idea 2024-08-12 15:28:46 why is iix written to spawn a child instead of writing to its own standard output? 2024-08-12 15:29:35 I mean also if I do that then I don't need a dedicated buffer for terminal input, can use a BLOCK buffer 2024-08-12 15:29:45 xentrac: the README explains it @ https://github.com/jhswartz/iix 2024-08-12 15:30:39 thanks! 2024-08-12 15:30:51 veltas: ooh, interesting! 2024-08-12 15:31:03 : TIB HISTORY @ 16 U/MOD BLOCK SWAP 64 * + ; or something like that when I'm less distracted 2024-08-12 15:31:10 unjust: oh, because gforth wants a tty? 2024-08-12 15:32:23 iix was written originally because i wanted to debug programs with gdb that read input from stdin, and being able to provide the process-under-debug with input that way once the program has been spawned wasn't possible (might still not be) 2024-08-12 15:33:02 I see 2024-08-12 15:33:39 i think of it as something like an equivalent of tee for stdin 2024-08-12 15:34:10 I mean I think GDB is happy to read its stdin from a pipe rather than a tty 2024-08-12 15:34:40 it's own stdin maybe, but it's the process under debug that needs the input 2024-08-12 15:34:55 (it does behave a bit differently though) 2024-08-12 15:35:17 in your example I think xxd and GDB have the same stdin? 2024-08-12 15:35:52 In gforth you can redefine KEY (and ACCEPT?) 2024-08-12 15:36:01 or something like that 2024-08-12 15:36:21 So you can use gforth's facilities to multiplex stdin 2024-08-12 15:38:04 xentrac: had to look at that again, i wrote that a while ago. yes 2024-08-12 15:39:06 maybe you wrote it that way to preserve GDB tab-completion? 2024-08-12 15:39:58 i think it was mostly that i was trying to exploit something and copying and pasting binary data into the tty was not viable 2024-08-12 15:40:04 unjust: iix is nice C code 2024-08-12 15:40:27 veltas: thanks, i think my style changed a lot since then though 2024-08-12 15:40:50 Well lots of styles are valid 2024-08-12 15:41:12 not mine though 2024-08-12 15:41:18 :P 2024-08-12 15:41:23 heh 2024-08-12 15:41:25 http://canonical.org/~kragen/sw/dev3/ks1.c 2024-08-12 15:42:04 what's your handicap? 2024-08-12 15:42:17 about 20 kyu 2024-08-12 15:45:29 veltas: this is how it's changed, https://pastebin.com/VQv5RMTP 2024-08-12 15:47:11 very nice 2024-08-12 15:47:37 hopefully that tool will be nice to use 2024-08-12 15:48:21 it's certainly nice to read 2024-08-12 15:48:44 thanks 2024-08-12 15:56:50 when running: https://imgur.com/a/WadjmRc 2024-08-12 16:07:57 Yeah that's nice too 2024-08-12 16:08:06 An improvement because it's more declarative, IMO 2024-08-12 16:08:20 Although they're not the same problem 2024-08-12 21:59:11 unjust: ever since `goto fail` I always brace my if blocks unless they're on the same line 2024-08-12 21:59:47 but maybe I'm just being overly paranoid 2024-08-12 22:12:07 that makes sense 2024-08-12 22:13:18 I mention it because I see in https://pastebin.com/VQv5RMTP that you don't. which is a valid stylistic choice and one I used to use 2024-08-12 22:14:00 i used to brace everything, with braces on single lines 2024-08-12 22:14:10 s/single/their own/ 2024-08-12 22:15:15 GNU-style? 2024-08-12 22:19:20 iix is an example of how i used to do it. so it's maybe similar to GNU-style but with tabs instead of spaces 2024-08-12 22:20:14 that's more BSD style 2024-08-12 22:20:18 i do like to keep lines at 79 characters or less though 2024-08-12 22:20:52 yeah 2024-08-12 22:21:06 for cellphones it might be good to switch to a narrower width 2024-08-12 22:21:30 that's true 2024-08-12 22:22:00 i use ed on my phone rather than vim though 2024-08-12 22:22:18 i reckon line editors are better for that physical interface 2024-08-12 22:23:00 ed is mostly the reason i switched to avoiding braces unless necessary in C 2024-08-12 22:23:24 vim is pretty unpleasant on my phone 2024-08-12 22:23:32 what do you use instead? 2024-08-12 22:24:04 I've mostly been using Bill Farmer's unhelpfully named "Editor" from F-Droid 2024-08-12 22:24:18 but it's under-featured for programming 2024-08-12 22:24:36 using HeliBoard for the keyboard makes a bigger difference 2024-08-12 22:25:03 i haven't tried either 2024-08-12 22:25:18 what are the benefits of heliboard? 2024-08-12 22:25:35 well, it depends on what you're contrasting it with 2024-08-12 22:25:59 but being able to set it to not capitalize each new line (or sentence) is pretty important for programming 2024-08-12 22:26:02 let's go with gboard, the bloated default 2024-08-12 22:26:12 I don't think I have gboard 2024-08-12 22:27:25 what operating system are you using? i'm guessing android, but i realize it could be linux with something like anbox 2024-08-12 22:27:37 LineageOS, so basically degoogled Android 2024-08-12 22:27:50 ah ok 2024-08-12 22:28:03 the other features I appreciate about HeliBoard are disabling autocorrect, disabling inserting periods before double spaces, working word completion dictionaries, multiple (natural) languages (I have English, Spanish, and Greek enabled) 2024-08-12 22:28:44 definitely useful features 2024-08-12 22:28:54 it has left and right arrows on a popout menu which replaces the autocompletion suggestions, and swiping left and right on the spacebar moves the cursor 2024-08-12 22:28:55 is it a single button switch for language selection? 2024-08-12 22:29:33 long press on spacebar brings up a menu which includes the other keyboards as well as different HeliBoard languages 2024-08-12 22:29:49 so it's two buttons 2024-08-12 22:30:38 sounds pretty decent 2024-08-12 22:30:39 previously I was using one (either FlorisBoard or AnySoftKeyboard, I forget) which had a language switch button in a menu bar just above the top row of keys 2024-08-12 22:30:51 so occasionally when I tried to hit "u" or "i" I would accidentally switch to Greek 2024-08-12 22:31:15 how many of these features are in the default Android keyboard these days? I have the sense that most of HeliBoard's features derive from there 2024-08-12 22:32:04 what I'd really like for text editing on the phone is a *translucent* keyboard that pops up *overlaying* the text I'm editing 2024-08-12 22:32:23 like the action buttons in cellphone games like Fortnite