4 ms·
Modelling mobs as actors can make it extremely difficult to build a fully featured MUD, especially if you want to implement a scripting language that lets build
by bcrosby95 3y ago
Modelling mobs as actors can make it extremely difficult to build a fully featured MUD, especially if you want to implement a scripting language that lets builders make them do cool things. You probably want something more coarse grained.
- lightedman 3y agoCheck out BYOND - you could build a Final Fantasy-styled 2D MUD and let builders do cool stuff, like link worlds together and what not.
- deleted 3y ago[deleted]
- Twisol 3y agoWhoa, I haven't thought about BYOND in ~20 years. I'm incredibly impressed it's still going (same website and everything)!
- adamkittelson 3y agoI built a MUD in Elixir and I completely agree. After many iterations what I landed on as the best path was having rooms as actors. Mobs, characters, items etc are just data in the room process (actor) state (in memory that is, in the database they're all modeled more or less as you'd expect for a relational DB). This gives me a large number of units of concurrency, while allowing the overwhelming majority of the code to be written sequentially since most of the complicated bits (combat etc) happen within a room so I don't have to think about concurrency at all for those. The only communication between processes is moving monster / character data from one room to another when those entities move around the map.
- bcrosby95 3y agoEven rooms can be very tricky! Consider this: bob is closing a door in rooma. A dragon is trying to move to rooma through that exit. How do you code this such that bob never sees the dragon walk through a closed door? With no deadlocks? The way I solved this is by creating a new process for coordinating multi-room actions. If a room is part of a coordinating process, it will queue everything from all other processes.