Woo my MUD has its first NPC

grapevine.haus/games/emsMUD/pl

Attached is a screenshot of the code that makes her, which is really rough and verbose because well, its the first one!

But, she can send messages to players in the same room as her, and move herself room to room.

Follow

@emacsomancer tremble at my "it kinda works"! lisp nonsense bwuahaha

@emsenn at least personally, one of things I like about lisp is that getting from "it doesn't work at all" to "it kinda works" is easier than in many other languages.

also "A: What's the code like? Is it good code?" "B: It's better than good: it's done!"

@emacsomancer I have /never/ been able to actually do what I want in a language like any given LISP lets me do.

And it's so powerful for this sort of programming: nearly every part of the code started as code for working with one or two things, and then things got generalized out - a lot of times legit just copying hacky procedures into the main files, cause they work well enough!

And like, that any given NPC can be programmed from the ground-up like that? verbose right now, sure, but with hacky procedures i'm sure to make it'll get more terse, and also, wow! any npc can do p much anything! which is a cool freedom in worldbuilding.

@emsenn Yes, that's been precisely my experience as well. And because of those things, as an experience it's also a much more enjoyable (for me) than trying to write code in other languages.

@emacsomancer Yea.

And I've always viewed MUDs as a wonderful tool for introducing folk to programming - I mean, they were my introduction.

A MUD that introduces people straight to LISP programming? OMG

Especially because there's not that big of a leap between entering the MUD commands and LISP procedures - like LISP, the command (procedure) always comes first!

So it's just a matter of learning what procedures ACTUALLY call when you enter "move north" and how those reduce

(move-thing-into-thing! player (hash-ref (thing-quality (thing-quality player 'container) 'exits) 'north))

(I think, or something similar.)

@emsenn And I don't think that would be the case for lots of languages: it's not like a MUD written in C would really be that easy to translate into an interface that would make the MUD'er likely to begin grokking C.

(It's also potentially significant here that early interactive fiction, at least Infocom's, was written in a lisp.)

@emacsomancer like there's so much fluidity! the mass quality defined here... actually only ever exists in one other place, kind of, where there's a check for things with that quality when you "look"

Other than that, it's just... just add it and use it! It's kinda like... emacs in that way? loosely extensible, yo ucould add a emacsomancer-score quality to any given thing and work with it however you wanted.

(And you can define proper checks like to make sure the score is only ever an int.)

(I am kinda proud of this engine as a whole I'll be honest. for a hobbyist hack effort, it's cool!)

@emsenn I'm of course coming at all of this from a hobbyist perspective too: and I think there's something to that.

Other than a potential barrier of lisp being syntactically different from other languages that a user may have previous encountered, I think that lisps are easier for people to wrap their heads around enough to be able do something significant and innovative than is the case for lots of other programming 'paradigms'.

@emacsomancer *nod* I look to early MUD history and say, if those folk who sometimes came into being MUD developers just because they were expert players and had no programming experience, could make some of those cool systems, using a weird C derivative, then folk can probably do at least as well with a LISP.

I don't really care about people who are already programmers they can use one of the many other MUD engines :D

@emsenn Yeah, I'd definitely contend that it's likely that the translation from "I don't know anything about programming but I like MUDs" to "I'm a MUD developer" would be quicker, easier, and more enjoyable with a lisp than lots of other languages.

@emacsomancer I will say, I've probably written like 20 different versions of "make the world map" code, but like, without ever really needing to think or work too hard about it and I think that more shows how un-locked-into-one-way things are.

@emacsomancer (if you or anyone else is curious this is the current way that it's done: the objects are prebuilt with "area-id" qualities that are each unique, and then sorted into a hash-table where each key is that id and each value is the corresponding thing.

Then exits are added, using those IDs to find things.

It wouldn't scale well for a world of thousands of rooms, but this isn't that sort of MUD!

@emsenn I wonder about the scaling. Hash table lookups should be pretty computationally cheap, right?

@emacsomancer i don't know about any of that, but it only looks them up in the hash table to set the exits up, once they're set it points directly to the thing that is the room you'd move into

@emsenn Yeah, I'm not sure. But I'm guessing it might scale better than one might think.

@emacsomancer The main issue with scale I see is actually just the human error of it being hard to manually map the exits of several thousand rooms without errors.

Luckily this way of map-building errors on build, /not/ when a person tries to use an exit that is broken.

@emsenn Ah, I see. Presumably, if desired, one could add some sort of sanity check procedure which occurred before the room-exit associations were created. Or even a different 'front-end' of some sort for doing these associations which got translated into the hash table entries.

@emacsomancer *nod*

I'm planning on handwriting this universe of my own library and stuff but for the game-MUD I'm planning I've actually had a change of heart towrad generated worlds, because I think that's the only way I can get the sort of ecological complexity that I crave.

@emsenn Writing code for generated worlds I think would be fun and interesting to do too!

@emacsomancer Yea! I was looking at the source behing azgaar.github.io/Fantasy-Map-G and it made it seem accessible enough to get started with.

@emsenn I've seen the generator before (it seems pretty cool), but I didn't try digging into the source at all.

@emacsomancer It is! And it's in active development and getting more sophisticated - it's a LOT more sophisticatedthan it looks at glance, in terms of building cultures and stuff.

But at the end of the day it's a mapping app and I'd love to have something similar that makes a living world you can then step into.

@emsenn I have a personal love of maps, especially 'fantasy' type ones, and so there's something really enchanting about this sort of automated generation of a potential infinity of maps of such worlds.

I really haven't dug into the culture-building and other aspects - that's really cool - I was entranced just looking at the maps! But having those other things make it even more interesting.
Show more
@emsenn The argument against this would be that this property makes lisp a bad choice for multi-programmer projects - because there isn't a single "right way" of doing things, so it's harder for other programmers to understand your code.

But looking at your code snippet (even without being able to see the rest of it), I have a pretty good idea of what everything does. (Of course, one still has to choose sensible labels and so on, as you've done.) So I'm still not fully convinced about this part of the 'curse of lisp' narrative.

@emacsomancer I think that's so much a cultural thing and so little a code thing.

that said, I don't understand how to document Racket procedures so documetning my own API hasn't happened yet. But yea, everything is pretty clearly labeled, and I feel like even procedures like add-string-to-quality-of-things-with-quality-in-quality-of-thing! are pretty sensible once you understand the underlying concepts about things and qualities.

(Cool engine thing: call (add-string-to-quality-of-things-with-quality-in-quality-of-thing! 'output-buffer 'output-buffer 'contents room) and it actually looks, first in the room itself and then the universe the room exists in, if there is one, for an (add-string-to-output-buffer-of-things-with-output-buffer-in-contents-of-thing!) procedure and uses it, instead.

At least, I think it's cool - this sort of "let thigns and universes hold their own procedures" is letting me do cool chains of hooks, basically, i think they're called, and I've never seen that in a MUD before. espeically not where it's so easy to add your own hooks.

@emsenn I think there's some convergence between code and culture in some cases - some languages make it harder to do the same thing in multiple ways, but yes, there's surely a lot of culture around different languages which has little to do with actual technical bits.

The 'chain of hooks' model for a MUD sounds pretty cool!

@emacsomancer Thanks! So far I'm really inconsistent in applying it, but honestly the "swap out the world quality for arguments then try and use that procedure" is... gosh it's so convenient.

Cause I can then just write (set-thing-mass! t m) (unless (integer? m) (raise-argument-error...) (set-thing-quality! t 'mass m #:skip ))

(add-procedure-to-universe!
'set-thing-mass! set-thing-mass emsverse)

And bam now whenever anything created into the emsverse tries to (set-thing-quality! moose 'mass 200), it checks that 200 is an int.

No further writing of procedures about mass needed!

(This is the pinnacle of what like 18 years of restarting a MUD engine from scratch, but only to work on it for a month or so every 2-3 years, gets you. lol.)

@emsenn And not that you couldn't do something like this in another language, but I find that lisps make it much easier for me as a human being to wrap my head around various concepts/abstractions/approaches in the first place.

@emacsomancer right - exactly.

(+ 2 2) is intelligible, once you learn to read it

(+ 2 (+ 1 1)) makes sense then too

(+ 2 x) makes sense too - and the above implies that x doesn't HAVE to be a number.

These little implications kind of led me to the idea "well if I can swap out that second two for a procedure or variable, then I can make code that does the swapping, too!

@emsenn I think lisp's wearing its syntax on its sleeve, and the fact that for the most part that syntax is minimal and consistent, really help one to be able to see these sorts of implications.

I have a much easier time forming some sort of more complete mental representation of a lisp program than a python program.

@emacsomancer I feel like LISP helps me accept I don't need a complete mental representation, I just need to maintain my bearing along my current flow of inputs leading to output!

@emsenn I agree, but I think that part of this is that the structure and syntax of lisp (at least for me) makes it easier to mentally 'maximise'/'minimise' (expand/collapse) different bits as necessary for me to be able keep my bearings.

@emacsomancer This brings me to a question I had with Emacs:

Do you know of any folding modes that let you fold "every s-exp ABOVE this one"

A lot let you fold everything more nested (I've been using yafolding and appreciate it's simple "how indented are you folding)

but sometimes I wanna close everything that leads up to a statement and justlook at that.

@emsenn I wouldn't be surprised if there is something like this, but I don't know of anything off-hand.

at worst, I imagine one might be able to tweak one of the existing s-exp 'highlighting' packages to implement this sort of behaviour.

In any case, I'll keep an eye out for things of this sort and let you know about anything promising I come across.
Sign in to participate in the conversation
Ecosteader

This mastodon instance is dedicated to the survival of indigenous languages, plant knowledge, art, and culture outside white supremacist-controlled networks Facebook and Twitter.
Decolonize food. Decolonize medicine. Decolonize housing. Decolonize from corrupt white supremacist networks. Decolonize the US from its oligarchal form of government! European statues, place names, words, languages, and accounting systems DO NOT BELONG on Turtle Island, and are killing the whole planet. "Traditional Ecological Knowledge" (TEK) is the only thing that can help humans as colonial systems continue to sink deeper into broken, inequitable, and faulty systems that value money over Earth's many forms of life. #LivingWalls, not border walls. . Understand more... .