<!-- MHonArc v2.4.4 --> <!--X-Subject: mud grammar (was Re: Just a bit of musing) --> <!--X-From-R13: "Qnegre F Eubpx" <pgfbNhzvnpf.hzq.rqh> --> <!--X-Date: from fabius.globecomm.net [207.51.48.6] by mx01.ny.us.ibm.net id 858001773.102291-1 Mon Mar 10 13:49:33 1997 --> <!--X-Message-Id: 199703101349.NAA18524#lupa,umiacs.umd.edu --> <!--X-Content-Type: text/plain --> <!--X-Head-End--> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <head> <title>MUD-Dev message, mud grammar (was Re: Just a bit of musing)</title> <!-- meta name="robots" content="noindex,nofollow" --> <link rev="made" href="mailto:ctso#umiacs,umd.edu"> </head> <body background="/backgrounds/paperback.gif" bgcolor="#ffffff" text="#000000" link="#0000FF" alink="#FF0000" vlink="#006000"> <font size="+4" color="#804040"> <strong><em>MUD-Dev<br>mailing list archive</em></strong> </font> <br> [ <a href="../">Other Periods</a> | <a href="../../">Other mailing lists</a> | <a href="/search.php3">Search</a> ] <br clear=all><hr> <!--X-Body-Begin--> <!--X-User-Header--> <!--X-User-Header-End--> <!--X-TopPNI--> Date: [ <a href="msg00080.html">Previous</a> | <a href="msg00082.html">Next</a> ] Thread: [ <a href="msg00239.html">Previous</a> | <a href="msg00083.html">Next</a> ] Index: [ <A HREF="author.html#00081">Author</A> | <A HREF="#00081">Date</A> | <A HREF="thread.html#00081">Thread</A> ] <!--X-TopPNI-End--> <!--X-MsgBody--> <!--X-Subject-Header-Begin--> <H1>mud grammar (was Re: Just a bit of musing)</H1> <HR> <!--X-Subject-Header-End--> <!--X-Head-of-Message--> <UL> <LI><em>To</em>: <<A HREF="mailto:mud-dev#null,net">mud-dev#null,net</A>></LI> <LI><em>Subject</em>: mud grammar (was Re: Just a bit of musing)</LI> <LI><em>From</em>: "Carter T Shock" <<A HREF="mailto:ctso#umiacs,umd.edu">ctso#umiacs,umd.edu</A>></LI> <LI><em>Date</em>: Mon, 10 Mar 1997 08:43:50 -0500</LI> </UL> <!--X-Head-of-Message-End--> <!--X-Head-Body-Sep-Begin--> <HR> <!--X-Head-Body-Sep-End--> <!--X-Body-of-Message--> <PRE> > From: coder#ibm,net > A good MUD grammar is incredibly context sensitive. A simple example is > the case where the presence or proximity of an object adds verbs to the > players. There is no need for this crap to wander thru the global > namespace, or even warp the general grammar. > > >As such, one should be able to whip up a command interpreter with > >lex/yacc. I've started on it at least a dozen times but never managed to > >quite finish. Is this worthwhile? Thoughts? > > Nope. That approach tends to preclude having a dynamic language where > users or objects can add, redefine, mutate or delete verbs and nouns > freely at runtime. A Very Bad Idea. > I think we have a misunderstanding here. There's grammar (the structure of a language) and then there's vocabulary (all of the individual words that make up the language). I agree that the vocabulary is dynamic. I don't think the grammar is. I'll go one step more and suggest that how you implement the various entities (people, critters, and objects) in your mud can influence the success of such an approach. Lessee... in most mud worlds, the "nouns" are dynamic, but the verbs are not. I put nouns in quotes because often a noun/adjective pairing is required to uniquely identify an object (the long sword, the black sword, etc.). The verbs in the system are your commands. cast, throw, hit, etc. If we want to allow dynamic or generic verbs, now you're getting into natural language processing and I definitely don't want to go there. So there are some distinct sentence structures that emerge: <verb> <object> "hit foo" <verb> <object> <object> "give gold foo" "cast fireball foo" So the first trick is to define your grammar... establish a mapping of verbs to appropriate objects. We'll start with "hit". In most codes if you "hit foo" the code first sees what the allowable targets are for foo, then tries to locate a foo somewhere in the world that satisfies the target rules (get_person_room_vis(), get_obj_room_vis() whatever). The basic flow doesn't change a whole lot. We still have classes of objects... people, things, places, etc. One solution is to write our lexical analyzer so it enforces target rules. Another is to write objects so they can respond to any command (I've done sort of a mix here. Done in C++, the base generic object has a handler for all available commands, all of which respond "You can't do that" or somesuch. Real objects are derived from the base. For commands that make sense on the derived object, overload the virtual default handler, multiple levels of inheritence work nicely here). An example of where this works very nicely is with magic. Identify the verb "cast" as special in your lexical analyzer. Rather than <verb> <object> <object> it becomes <verb> <spell> <object> Now the question, why bother? Well, first off, it can make the mud more user-friendly. Rather than simply reporting "huh?" on bad commands, a true parser should be able to: 1) report the exact location of the error in the command 2) offer up suggestions (tab completion of commands) Now, we could do all of this without learning lex/yacc, but doing it in lex/yacc gives you a standard interface.. not to mention someone else has written most of the ugly code for you already. Btw, the newer flavors of the GNU lexer/parser software (glex and bison I think) offer up a C++ version that encapsulates the parser as an object. Nifty side effect is that you can have more than one. So, if you really want to screw with the user's minds you could conceivably have different command sets in different parts of your world. (something along Zelazny's Amber... the physics are different in the place you've warped to so the commands, spells, etc are different). Wait, it gets better... if we want to link up muds, there are ways that one mud could export its parser object to another so, if you wanted, you could process commands for a user in the remote mud locally (not sure why you'd want to, but hey.... explore the possibiliteis :) </PRE> <!--X-Body-of-Message-End--> <!--X-MsgBody-End--> <!--X-Follow-Ups--> <HR> <!--X-Follow-Ups-End--> <!--X-References--> <!--X-References-End--> <!--X-BotPNI--> <UL> <LI>Prev by Date: <STRONG><A HREF="msg00080.html">Re: Just a bit of musing</A></STRONG> </LI> <LI>Next by Date: <STRONG><A HREF="msg00082.html">Re: Threads, IO handling, and Event Queues</A></STRONG> </LI> <LI>Prev by thread: <STRONG><A HREF="msg00239.html">Re: mud grammar</A></STRONG> </LI> <LI>Next by thread: <STRONG><A HREF="msg00083.html">Re: mud grammar (was Re: Just a bit of musing)</A></STRONG> </LI> <LI>Index(es): <UL> <LI><A HREF="index.html#00081"><STRONG>Date</STRONG></A></LI> <LI><A HREF="thread.html#00081"><STRONG>Thread</STRONG></A></LI> </UL> </LI> </UL> <!--X-BotPNI-End--> <!--X-User-Footer--> <!--X-User-Footer-End--> <ul><li>Thread context: <BLOCKQUOTE><UL> <LI><STRONG>Re: mud grammar</STRONG>, <EM>(continued)</EM> <ul compact> <LI><strong><A NAME="00190" HREF="msg00190.html">Re: mud grammar</A></strong>, coder <a href="mailto:coder#ibm,net">coder#ibm,net</a>, Mon 24 Mar 1997, 04:29 GMT </LI> <LI><strong><A NAME="00191" HREF="msg00191.html">Re: mud grammar</A></strong>, Nathan Yospe <a href="mailto:yospe#hawaii,edu">yospe#hawaii,edu</a>, Mon 24 Mar 1997, 05:25 GMT </LI> <LI><strong><A NAME="00198" HREF="msg00198.html">Re: mud grammar</A></strong>, Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Mon 24 Mar 1997, 15:00 GMT </LI> <LI><strong><A NAME="00239" HREF="msg00239.html">Re: mud grammar</A></strong>, claw <a href="mailto:claw#null,net">claw#null,net</a>, Fri 28 Mar 1997, 04:05 GMT </LI> </ul> </LI> <LI><strong><A NAME="00081" HREF="msg00081.html">mud grammar (was Re: Just a bit of musing)</A></strong>, Carter T Shock <a href="mailto:ctso#umiacs,umd.edu">ctso#umiacs,umd.edu</a>, Mon 10 Mar 1997, 21:49 GMT <UL> <li><Possible follow-up(s)><br> <LI><strong><A NAME="00083" HREF="msg00083.html">Re: mud grammar (was Re: Just a bit of musing)</A></strong>, Nathan Yospe <a href="mailto:yospe#hawaii,edu">yospe#hawaii,edu</a>, Tue 11 Mar 1997, 02:58 GMT </LI> <LI><strong><A NAME="00085" HREF="msg00085.html">Re: mud grammar (was Re: Just a bit of musing)</A></strong>, Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Tue 11 Mar 1997, 13:20 GMT </LI> <LI><strong><A NAME="00112" HREF="msg00112.html">mud grammar (was Re: Just a bit of musing)</A></strong>, claw <a href="mailto:claw#null,net">claw#null,net</a>, Sat 15 Mar 1997, 07:29 GMT </LI> <LI><strong><A NAME="00121" HREF="msg00121.html">Re: mud grammar (was Re: Just a bit of musing)</A></strong>, Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Sun 16 Mar 1997, 04:15 GMT </LI> </UL> </LI> </UL></BLOCKQUOTE> </ul> <hr> <center> [ <a href="../">Other Periods</a> | <a href="../../">Other mailing lists</a> | <a href="/search.php3">Search</a> ] </center> <hr> </body> </html>