<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Scurvy Jake&#039;s Pirate Blog &#187; MUD Development</title>
	<atom:link href="http://bogomip.net/blog/category/mud-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://bogomip.net/blog</link>
	<description>Rated arrrr for Piracy</description>
	<lastBuildDate>Tue, 22 May 2012 21:31:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Where Does the Time Go?</title>
		<link>http://bogomip.net/blog/2010/07/07/where-does-the-time-go/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=where-does-the-time-go</link>
		<comments>http://bogomip.net/blog/2010/07/07/where-does-the-time-go/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 19:19:31 +0000</pubDate>
		<dc:creator>Scurvy Jake</dc:creator>
				<category><![CDATA[MUD Development]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[picture]]></category>

		<guid isPermaLink="false">http://bogomip.net/blog/?p=4331</guid>
		<description><![CDATA[Now that my MUD (which I've recently settled on the name ForeverMUD) is getting more stable, I thought I'd run some profiling tools on it. Valgrind is a very cool utility made to do this very thing. When I first started developing, I wrote in a loop timer that keeps track of the longest processing [...]]]></description>
			<content:encoded><![CDATA[<p>Now that my MUD (which I've recently settled on the name <em>ForeverMUD</em>) is getting more stable, I thought I'd run some profiling tools on it. <a href="http://valgrind.org/">Valgrind</a> is a very cool utility made to do this very thing.</p>
<p>When I first started developing, I wrote in a loop timer that keeps track of the longest processing time as well as the average loop time. After the introduction of a large (16,200 room) world map, the loop times jumped from 10-30 &micro;sec to over 190,000 &micro;sec&#8212;no bueno.</p>
<p>So last night I ran <a href="http://valgrind.org/">Valgrind</a> and used <em>kcachegrind</em> to view the results, which showed me this:</p>
<p><a href="http://bogomip.net/images/callgrind.png"><img src="/images/callgrind-small.png" alt="Valgrind and kcachegrind results" /></a></p>
<p>Put simply, most of my time is spent <em>manipulating mutexes</em>. I'm going to have to rethink my design, because that's way too much time&#8230;</p>
<img src="http://bogomip.net/blog/16cfc4b3/266bb3e8/CCBot/1.0 (+http://www.commoncrawl.org/bot.html).gif" />]]></content:encoded>
			<wfw:commentRss>http://bogomip.net/blog/2010/07/07/where-does-the-time-go/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MUD Progress</title>
		<link>http://bogomip.net/blog/2010/06/23/mud-progress-5/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mud-progress-5</link>
		<comments>http://bogomip.net/blog/2010/06/23/mud-progress-5/#comments</comments>
		<pubDate>Thu, 24 Jun 2010 05:21:44 +0000</pubDate>
		<dc:creator>Scurvy Jake</dc:creator>
				<category><![CDATA[MUD Development]]></category>
		<category><![CDATA[MUD]]></category>

		<guid isPermaLink="false">http://bogomip.net/blog/?p=4308</guid>
		<description><![CDATA[I've been making a little progress on the MUD again. I don't work on it much, but it hasn't been building for a while, and I've got a drive to get it fixed so at least I can continue testing it. I've made a few modifications lately, the biggest being changing the command objects to [...]]]></description>
			<content:encoded><![CDATA[<p>I've been making a little progress on the MUD again. I don't work on it much, but it hasn't been building for a while, and I've got a drive to get it fixed so at least I can continue testing it.</p>
<p>I've made a few modifications lately, the biggest being changing the command objects to <a href="http://en.wikipedia.org/wiki/Singleton_pattern">Singleton objects</a> since that's the way I've been using them anyway. I've also been working on the <strong>get</strong> command, and as happens when a design gets better, it's shrinking in size. Hopefully I'll be able to wrap it up tomorrow, since Lorien will be working until almost 9:30pm tomorrow night anyway.</p>
<p>I've also been lax about source control. My current system is rolling up a tarball, bz2-compressing it, and dropping it into my gmail account. I really should get something a little more sophisticated. At some point I'm going to have to do something about it. But the goal right now is to get it building again, and to test out the <strong>get</strong> revision.</p>
<img src="http://bogomip.net/blog/16cfc4b3/266bb3e8/CCBot/1.0 (+http://www.commoncrawl.org/bot.html).gif" />]]></content:encoded>
			<wfw:commentRss>http://bogomip.net/blog/2010/06/23/mud-progress-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the yaml-cpp Library</title>
		<link>http://bogomip.net/blog/2010/06/19/using-the-yaml-cpp-library/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-the-yaml-cpp-library</link>
		<comments>http://bogomip.net/blog/2010/06/19/using-the-yaml-cpp-library/#comments</comments>
		<pubDate>Sat, 19 Jun 2010 18:57:42 +0000</pubDate>
		<dc:creator>Scurvy Jake</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[MUD Development]]></category>
		<category><![CDATA[MUD]]></category>

		<guid isPermaLink="false">http://bogomip.net/blog/?p=4299</guid>
		<description><![CDATA[I've been using the yaml-cpp library for a while now, and I have to say that overall I'm greatly pleased by how well it works. As I was making some adjustments to my I/O last night I ran across a bit of documentation that I never noticed before. Of course, it could be newly added. [...]]]></description>
			<content:encoded><![CDATA[<p>I've been using the <a href="http://code.google.com/p/yaml-cpp/">yaml-cpp library</a> for a while now, and I have to say that overall I'm greatly pleased by how well it works.</p>
<p>As I was making some adjustments to my I/O last night I ran across a bit of documentation that I never noticed before. Of course, it could be newly added. Anyway, I've found the most convenient way to parse my documents (I have many thousands of them to read and write), is to access them by node-name. For example:</p>
<pre>node["location"]["name"] >> mObjectLocation.location;</pre>
<p>The information I read last night, however, may convince me to change this behavior.</p>
<p>Apparently, named-node access in <code>yaml-cpp</code> is <strong>order-n<sup>2</sup> complex</strong> over the entire document. Put simply, every time you access a node like this the library loops through all nodes looking for a match. Personally, I think a hashed table lookup would have been much faster, and perhaps they'll add that later. </p>
<p>Overall, I wouldn't normally worry about it because my documents tend to only have a few dozen nodes. But I do have 20,000 documents to parse. And to top that off, as they are used they become more complex. And as more items are added, the node size will grow geometrically. I can easily envision a future where a single document contains hundreds of nodes, and it's starting to scare me.</p>
<p>The solution? Well, I can honestly say I don't have a good one yet. I think perhaps if I enforce the order things are written, which already only happens in one way, I can then read in linearly instead of by node-name. The problem with that is if a file is edited by hand and the order is accidentally changed. So by renaming my <em>current</em> solution to <code>readCompatible()</code> and writing a new linear <code>read()</code> function, I should cut down on a lot of extra unnecessary processing.</p>
<p>But I'm still not sure that's the best solution. Any smart people out there have a better idea?</p>
<img src="http://bogomip.net/blog/16cfc4b3/266bb3e8/CCBot/1.0 (+http://www.commoncrawl.org/bot.html).gif" />]]></content:encoded>
			<wfw:commentRss>http://bogomip.net/blog/2010/06/19/using-the-yaml-cpp-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Boost::Spirit 2 Redux</title>
		<link>http://bogomip.net/blog/2010/06/01/boostspirit-2-redux/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=boostspirit-2-redux</link>
		<comments>http://bogomip.net/blog/2010/06/01/boostspirit-2-redux/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 03:27:35 +0000</pubDate>
		<dc:creator>Scurvy Jake</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[MUD Development]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[MUD]]></category>
		<category><![CDATA[spirit]]></category>

		<guid isPermaLink="false">http://bogomip.net/blog/?p=4256</guid>
		<description><![CDATA[Well if you stopped by yesterday you may have read my post about Boost::Spirit 2 and the trouble I had converting to the new Spirit 2 library. Fortunately, Hartmut Kaiser, one of the Boost::Spirit authors must have a Google blog notification when Spirit is mentioned in a blog, because he left a comment with a [...]]]></description>
			<content:encoded><![CDATA[<p>Well if you stopped by yesterday you may have read my <a href="http://bogomip.net/blog/2010/05/31/boostspirit-2/">post about Boost::Spirit 2</a> and the trouble I had converting to the new Spirit 2 library. Fortunately, <a href="http://boost-spirit.com/home/">Hartmut Kaiser</a>, one of the <a href="http://boost.org/">Boost::Spirit</a> authors must have a Google blog notification when Spirit is mentioned in a blog, because he <strong>left a comment</strong> with a suggestion for me earlier!</p>
<p>Unfortunately, I still can't seem to get <code>qi::phrase_parse</code> to work right. The problem is that I'm trying to match one of a set of increasingly complicated grammar structures (perhaps starting at the most complicated and working backwards would fix this issue&#8230;). So, here is my problem in gruesome detail:</p>
<p>I'm implementing a <strong>get</strong> command for a MUD, an online text-only game system. Since I'm writing it from scratch, I decided to use some of the most up-to-date tools I could find to do so, and Boost has some terrific libraries that make this possible. As far as I can discern, the <strong>get</strong> command can come in the following forms:</p>
<ol>
<li>get hammer</li>
<li>get 20 nails</li>
<li>get hammer 2 <em>(the second hammer)</em></li>
<li>get 20 nails 3 <em>(20 of the 3rd type of nails visible)</em></li>
<li>get hammer from toolbelt</li>
<li>get 20 nails from bucket</li>
<li>get hammer from toolbox 2 <em>(the hammer from the second toolbox)</em></li>
<li>get 20 nails from bucket 3 <em>(you get the idea)</em></li>
<li>get hammer 3 from toolbox 2</li>
<li>get 20 nails 2 from bucket 3</li>
</ol>
<p>The problem comes when using <code>phrase_parse</code> with an empty space skip-parser. Given the two rules:</p>
<pre>bool res = qi::phrase_parse(first, str.end(),
				(
					+qi::alpha
				),
				' ',
				item
);</pre>
<p>And</p>
<pre>bool res = qi::phrase_parse(first, str.end(),
					(
						+qi::alpha
						>> "from"
						>> +qi::alpha
					),
					' ',
					item,
					container
);</pre>
<p>If I check the phrase <strong>get hammer from bucket</strong> it matches rule one, because after you remove all the spaces from the string it's just one long word! This is an unexpected result, and even if I check rule two before rule one I <em>only match rule one</em>!</p>
<p>And now I'm really lost. I imagine there's a better way to do this, but I can't seem to figure it out. Also, since my allergies are going crazy, I've got to take the night off anyway. Anybody out there know of a solution?</p>
<img src="http://bogomip.net/blog/16cfc4b3/266bb3e8/CCBot/1.0 (+http://www.commoncrawl.org/bot.html).gif" />]]></content:encoded>
			<wfw:commentRss>http://bogomip.net/blog/2010/06/01/boostspirit-2-redux/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Boost::Spirit 2</title>
		<link>http://bogomip.net/blog/2010/05/31/boostspirit-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=boostspirit-2</link>
		<comments>http://bogomip.net/blog/2010/05/31/boostspirit-2/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 01:34:32 +0000</pubDate>
		<dc:creator>Scurvy Jake</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[MUD Development]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[MUD]]></category>
		<category><![CDATA[spirit]]></category>

		<guid isPermaLink="false">http://bogomip.net/blog/?p=4248</guid>
		<description><![CDATA[Last year I added Boost::Spirit to my MUD project. A few weeks ago I learned that all of the work I had done was deprecated in the new Spirit 2 library. I could still use "Spirit classic," but it is deprecated and may be removed at some point in the future. So I spent some [...]]]></description>
			<content:encoded><![CDATA[<p>Last year I added <a href="http://www.boost.org/doc/libs/1_43_0/libs/spirit/doc/html/index.html">Boost::Spirit</a> to my MUD project. A few weeks ago I learned that all of the work I had done was deprecated in the new Spirit 2 library. I could still use "Spirit classic," but it <em>is</em> deprecated and may be removed at some point in the future. So I spent some time today figuring out how to convert my grammar rules.</p>
<p>For example, in Spirit classic, I had this rule to handle the most complex rule for my <code>get</code> command. In this case, it handles a command like <em>get 20 items 2 from container 3</em>:</p>
<pre>rule6 = int_p[assign_a(mNumberToGet)] >> ' ' >>
			(+alpha_p)[assign_a(mItemToFind)] >> ' ' >>
			int_p[assign_a(mItemNumber)] >> ' ' >>
			str_p("from") >> ' ' >>
			(+alpha_p)[assign_a(mContainerToLookIn)] >> ' ' >>
			int_p[assign_a(mContainerNumber)];</pre>
<p>which could be tested by the following code: <code>if(parse(str.c_str(), rule6).full)</code></p>
<p>Here is the equivalent code in Spirit 2</p>
<pre>
	std::string::iterator first = str.begin();

	bool r = qi::parse(first, str.end(),
					(
						qi::int_ >> ' '
						>> +(~qi::char_(' ')) >> ' '
						>> qi::int_ 	>> ' '
						>> qi::lit("from") >> ' '
						>> +(~qi::char_(' ')) >> ' '
						>> qi::int_
					),
					mNumberToGet,
					mItemToFind,
					mItemNumber,
					mContainerToLookIn,
					mContainerNumber
	);

	if(r &#038;& first == command.end()) {
		return true;
	}</pre>
<p>In many ways, the new Spirit 2 library is better, and purports to be much faster as well. The <code>parse</code> function has certainly been made somewhat more convenient. Overall, I'd rather not have had to spend time on this, but the only other option is to lock in with an old version of <strong>Boost</strong> that may hamper me in the future.</p>
<img src="http://bogomip.net/blog/16cfc4b3/266bb3e8/CCBot/1.0 (+http://www.commoncrawl.org/bot.html).gif" />]]></content:encoded>
			<wfw:commentRss>http://bogomip.net/blog/2010/05/31/boostspirit-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Grammar Implementation</title>
		<link>http://bogomip.net/blog/2009/08/24/grammar-implementation/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=grammar-implementation</link>
		<comments>http://bogomip.net/blog/2009/08/24/grammar-implementation/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 06:06:29 +0000</pubDate>
		<dc:creator>Scurvy Jake</dc:creator>
				<category><![CDATA[MUD Development]]></category>

		<guid isPermaLink="false">http://bogomip.net/blog/?p=3846</guid>
		<description><![CDATA[I just finished writing the get() functionality I mentioned a few days ago. Using Boost::Spirit it was really easy to parse the grammar. It was much more work to actually act on the results of the parsing. There are nine different ways to use the get command, each with its own grammar rule. Each of [...]]]></description>
			<content:encoded><![CDATA[<p>I just finished writing the <code>get()</code> functionality I <a href="http://bogomip.net/blog/2009/08/18/programmatical-grammar/">mentioned a few days ago</a>. Using <a href="http://www.boost.org/">Boost::Spirit</a> it was really easy to parse the grammar. It was much more work to actually <em>act</em> on the results of the parsing.</p>
<p>There are <strong>nine</strong> different ways to use the <code>get</code> command, each with its own grammar rule. Each of the rules gets more programmatically complicated, so the command code itself got pretty long.</p>
<p>I do suspect that the <code>get</code> and <code>put</code> functions will be some of the most complicated to write. I'd say I'm halfway done, but I haven't done enough testing on the <code>get</code> code to really call it "done."</p>
<img src="http://bogomip.net/blog/16cfc4b3/266bb3e8/CCBot/1.0 (+http://www.commoncrawl.org/bot.html).gif" />]]></content:encoded>
			<wfw:commentRss>http://bogomip.net/blog/2009/08/24/grammar-implementation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programmatical Grammar</title>
		<link>http://bogomip.net/blog/2009/08/18/programmatical-grammar/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=programmatical-grammar</link>
		<comments>http://bogomip.net/blog/2009/08/18/programmatical-grammar/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 06:15:18 +0000</pubDate>
		<dc:creator>Scurvy Jake</dc:creator>
				<category><![CDATA[MUD Development]]></category>

		<guid isPermaLink="false">http://bogomip.net/blog/?p=3831</guid>
		<description><![CDATA[I've been working on implementing boost::spirit in my MUD to parse complicated grammar. Once I figured out how the library worked, it wasn't difficult to add to my existing codebase. The complicated part comes from actually using the results of the grammar. Take the get command, for instance. Now that I have an easy-to-use grammar [...]]]></description>
			<content:encoded><![CDATA[<p>I've been working on implementing <a href="http://www.boost.org/doc/libs/1_39_0/libs/spirit/classic/index.html">boost::spirit</a> in my MUD to parse complicated grammar. Once I figured out how the library worked, it wasn't difficult to add to my existing codebase. The complicated part comes from actually <em>using</em> the results of the grammar. Take the <strong>get</strong> command, for instance. Now that I have an easy-to-use grammar system, I can make it as complicated as I want. I currently support the following types of get commands:</p>
<ul>
<li>get book</li>
<li>get book 2</li>
<li>get 30 coins</li>
<li>get book from shelf</li>
<li>get book 3 from shelf</li>
<li>get book from shelf 2</li>
<li>get book 2 from shelf 3</li>
<li>get 30 coins from bag 2</li>
<li>get 5 arrows 2 from quiver 3</li>
</ul>
<p>I had to define a search order, too. If a player is carrying a container, and a similarly-named container also exists in the player's current room, the player can only manipulate the one in their inventory, and would have to first pick up container, <em>then</em> take items from it. I could work out a way to combine the inventories of the player and their location, but I'm not sure I want to go that far. Honestly, the way I've coded things it's not too difficult, but I'm more worried about perception of items and the confusion combining them all could potentially cause.</p>
<p>In any case, the <code>get</code> command is growing in complexity by orders of magnitude right now, and it's almost too much to keep in my head. I'm going to have to go through and refactor it before I've even finished writing it.</p>
<p>Here's a code example of one of my rules:</p>
<pre>
// 'get 20 items from container 2' grammar
rule5a = boost::spirit::int_p[boost::spirit::assign_a(mNumberToGet)] >> ' ' >>
	(+boost::spirit::alpha_p)[boost::spirit::assign_a(mItemToFind)] >> ' ' >>
	boost::spirit::str_p("from") >> ' ' >>
	(+boost::spirit::alpha_p)[boost::spirit::assign_a(mContainerToLookIn)] >> ' ' >>
	boost::spirit::int_p[boost::spirit::assign_a(mContainerNumber)];
</pre>
<p>Which reminds me, since this class (the <code>get</code> command) is a shared pointer, I have to lock up the volatile bits in a mutex so multiple threads play nice together.</p>
<img src="http://bogomip.net/blog/16cfc4b3/266bb3e8/CCBot/1.0 (+http://www.commoncrawl.org/bot.html).gif" />]]></content:encoded>
			<wfw:commentRss>http://bogomip.net/blog/2009/08/18/programmatical-grammar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tons of Progress</title>
		<link>http://bogomip.net/blog/2009/08/07/tons-of-progress/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tons-of-progress</link>
		<comments>http://bogomip.net/blog/2009/08/07/tons-of-progress/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 15:06:53 +0000</pubDate>
		<dc:creator>Scurvy Jake</dc:creator>
				<category><![CDATA[MUD Development]]></category>
		<category><![CDATA[MUD]]></category>

		<guid isPermaLink="false">http://bogomip.net/blog/2009/08/07/tons-of-progress/</guid>
		<description><![CDATA[I've had a lot of time here in Portland, especially in the mornings when nobody else is up, to work on my MUD project. I converted it to use YAML to load and save everything, and the issue that caused me to have to choose a structured language, the inability to show relationships between deeply [...]]]></description>
			<content:encoded><![CDATA[<p>I've had a lot of time here in Portland, especially in the mornings when nobody else is up, to work on my MUD project. I converted it to use YAML to load and save everything, and the issue that caused me to have to choose a structured language, the inability to show relationships between deeply nested containers is now fixed. I also rewrote the login process to use dynamic handlers depending on the login state you're in (thanks Jeff!).</p>
<p>I know I'm on the right track, because in nearly every case, the code changes were smaller than the original code. So far, that's always been a good sign for me.</p>
<p>The best part is now I have loadable and saveable objects all working, and I can continue to build the rest of the functionality to complete the MUD and make it playable. Thank goodness for lazy vacations! </p>
<img src="http://bogomip.net/blog/16cfc4b3/266bb3e8/CCBot/1.0 (+http://www.commoncrawl.org/bot.html).gif" />]]></content:encoded>
			<wfw:commentRss>http://bogomip.net/blog/2009/08/07/tons-of-progress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Another MUD Update</title>
		<link>http://bogomip.net/blog/2009/07/26/another-mud-update/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=another-mud-update</link>
		<comments>http://bogomip.net/blog/2009/07/26/another-mud-update/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 04:08:23 +0000</pubDate>
		<dc:creator>Scurvy Jake</dc:creator>
				<category><![CDATA[MUD Development]]></category>

		<guid isPermaLink="false">http://bogomip.net/blog/?p=3777</guid>
		<description><![CDATA[Yeah, you're probably getting bored of these. You're probably wondering: "Jacob, what exactly is a MUD, anyway? Well, at least some of you are. But I'm not going to get in to that. The Internet is a big place, you can find that on your own. Suffice (for me) to say, it's my current hobby, [...]]]></description>
			<content:encoded><![CDATA[<p>Yeah, you're probably getting bored of these. You're probably wondering: "Jacob, what exactly <em>is</em> a MUD, anyway? Well, at least some of you are. But I'm not going to get in to that. The Internet is a big place, you can find that on your own. Suffice (for me) to say, it's my current hobby, a "pet project" of mine spanning nearly a decade. Off and on. Okay, so mostly off, but <em>some</em> on.</p>
<p>On with the update! If you keep up with this blog (and I can only assume you do if you read this), you know I've run in to issues with unstructured text files and saving complicated data objects to a storage media and then restoring them. I began a search for the <strong>right solution</strong>&#8212;a white whale, a magic bullet, whatever you wish to call it. My first instinct was to leap to XML because it can surely solve this small problem with ease. Right?</p>
<p>Wrong! XML is complicated, both to read and write (by machines anyway). Yes, there are libraries to help with that. Oh there are such libraries that you have no idea what you may be getting yourself in to (most of you, anyway).</p>
<p>Throwing out XML, and going with a cow-orker's recommendation of implementing <a href="http://www.json.org/">JSON</a>, I began writing a proof-of-concept program to save and restore data, but quickly ran in to a serious issue: <em>JSON doesn't support multi-line strings</em>.</p>
<p>Yet more searching around yielded a link to <a href="http://www.yaml.org/">YAML</a>, which <a href="http://bogomip.net/blog/2009/07/23/structured-files/">I posted about the other day</a>. YAML is easy to read from a human standpoint, and even has a couple of C++ libraries to help read it. YAML supports everything I want to do. So I scrapped the JSON project and started a proof-of-concept for YAML. I quickly ran in to an issue reading YAML, but it turned out to be my own fault: I didn't understand how a part of the library worked. Shortly after that, though, I <em>did</em> uncover a bug in the <a href="http://code.google.com/p/yaml-cpp/">yaml-cpp</a> library with indicator characters used as scalars (this is where you non-technical people either stop reading, or stick your fingers in your ears&#8212;metaphorically&#8212;and ignore me from here on out). With that issue wrapped up, serious work began and the proof-of-concept grew wings and took off. Just like I hoped it would.</p>
<p>Now I'm in the midst of tearing out underlying serialization code (the part that handles the loading and saving of objects), and it looks like it may take many hours to get things back up and working again. But hopefully by that time I'll have a full-blown, ready-to-use system that will require very little future modification.</p>
<p>Since then I have also become aware of (thanks Keith) the <a href="http://www.boost.org/doc/libs/1_39_0/libs/serialization/doc/index.html">Boost Serialization</a> library. It does the same thing I'm looking at doing, but a little more generically, just like <code>Boost</code> always does. Now the dilemma is: do I go forward with the YAML code, or switch to boost::serialization? Perhaps another proof-of-concept program should be written to determine this, but I need to do a little more research. Right now I have no idea <em>how</em> the serialized data looks to human eyes, and I haven't found any examples yet. It's important to my project to have these files as easily modified by humans as by machines.</p>
<p>In summary, that's where the project sits today. I may have some time this week to work on it, but if it's anything like last week I'm not going to have the brainwidth (I just came up with that word!)  to work on it. Fortunately, Lorien and I plan a vacation to see family in Oregon in another week, so I should have a few idle days to work on it then.</p>
<p>PS. And wouldn't you know it, I just ran across Google's <a href="http://code.google.com/apis/protocolbuffers/docs/overview.html">Protocol Buffers</a>, yet another solution for basically the same problem. I have my work cut out for me!</p>
<img src="http://bogomip.net/blog/16cfc4b3/266bb3e8/CCBot/1.0 (+http://www.commoncrawl.org/bot.html).gif" />]]></content:encoded>
			<wfw:commentRss>http://bogomip.net/blog/2009/07/26/another-mud-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Structured Files</title>
		<link>http://bogomip.net/blog/2009/07/23/structured-files/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=structured-files</link>
		<comments>http://bogomip.net/blog/2009/07/23/structured-files/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 05:19:01 +0000</pubDate>
		<dc:creator>Scurvy Jake</dc:creator>
				<category><![CDATA[MUD Development]]></category>

		<guid isPermaLink="false">http://bogomip.net/blog/?p=3770</guid>
		<description><![CDATA[I've reached the point with my MUD project that plain old text files make saving and restoring information prohibitively difficult. I need to add some structure to them. On the other hand, I'd like them to remain easy to read and modify by hand as well as by computer. Enter]]></description>
			<content:encoded><![CDATA[<p>I've reached the point with my MUD project that plain old text files make saving and restoring information prohibitively difficult. I need to add some structure to them. On the other hand, I'd like them to remain easy to read and modify by hand <em>as well</em> as by computer.</p>
<p>Enter <a href="http://www.yaml.org/'>YAML</a>. First thing it has going for it is a <strong>recursive acronym</strong> for a name: <em>YAML Ain't Markup Language</em>, which gives it <code>++coolFactor</code>.</p>
<p>Secondly, YAML supports multi-line strings, and <a href="http://www.json.org/">JSON</a> doesn't (excluding the hack of using Unicode newlines to separate your lines&#8212;DO NOT WANT!).</p>
<p>Anyway, I decided on writing a proof of concept for using YAML, and started it this evening. I haven't gotten terribly far, but far enough to run in to some issues reading files with <a href="http://code.google.com/p/yaml-cpp/">yaml-cpp</a>. Even reading the YAML 1.2 spec sample files. I'm not sure what's wrong. In any case, I hope to resolve this soon and that YAML works out. I'd really like to use it for the MUD!</p>
<p>I <em>can</em> parse the "complete example" code, though. Right down to each individual scalar. I used recursion to read the nodes until I hit a scalar value instead of their fancy <code>operator&gt;&gt;</code> overloading.</p>
<img src="http://bogomip.net/blog/16cfc4b3/266bb3e8/CCBot/1.0 (+http://www.commoncrawl.org/bot.html).gif" />]]></content:encoded>
			<wfw:commentRss>http://bogomip.net/blog/2009/07/23/structured-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

