Woo my MUD has its first NPC


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.

@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.

@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.

@emacsomancer Right? At the moment it's all fairly simple but I'd love to see like, it plugged into some of the conlang generators out there so that your cultures could like, develop languags over time/dispersal, and other shit like that.

@emsenn And even if one wanted to do a lot 'hand-crafting' of a world, having a generated base to work from could be very useful.

@emacsomancer You'd think so but if there's any sort of mechanic interplay between like the world's climate simulation and the plants that grow in an area, making a village grow apple sfor cider because you think that'd look cool can just, fail.

@emsenn So you're thinking of pretty advanced procedural generation then? I hadn't thought about climates and ecologies and that sort of thing.

@emacsomancer From looking at how Azgaar does it, they achieve pretty impressive results with pretty simple code, so yea, I would be when I played with that sorta stuff. It's not like I /also/ have to render graphics for all these procedurally generated stuff, just make sure the sentences describing stuff parses out alright.

And I've already done some tinkering on code that like, makes it rain in an area and then the ground is divided into areas that have surface area and the soil can retain water but then excess goes to whatever thing is designated the watershed, and blah blah blah.

It's all just chains of procedures and hooks, it's just a LOT to make it into any sort of cohesive thing. rn it just random rains in a barren field players can't access.

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 ))

'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

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... .