<?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>T=Machine &#187; devdiary</title>
	<atom:link href="http://t-machine.org/index.php/category/devdiary/feed/" rel="self" type="application/rss+xml" />
	<link>http://t-machine.org</link>
	<description>Internet Gaming, Computer Games, Technology, MMO, and Web 2.0</description>
	<lastBuildDate>Tue, 20 Jul 2010 09:43:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Volunteer project: a simple RPG for iPhone &#8211; UPDATE</title>
		<link>http://t-machine.org/index.php/2009/08/13/volunteer-project-a-simple-rpg-for-iphone-update/</link>
		<comments>http://t-machine.org/index.php/2009/08/13/volunteer-project-a-simple-rpg-for-iphone-update/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 17:33:53 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[devdiary]]></category>
		<category><![CDATA[entrepreneurship]]></category>
		<category><![CDATA[games design]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[startup advice]]></category>

		<guid isPermaLink="false">http://t-machine.org/?p=648</guid>
		<description><![CDATA[A lot of people asked me to blog as this volunteer project progressed, share some insight into how things were going. I&#8217;ve not had enough time until just now, and it&#8217;s a mix: Some good news, some bad news.

Good news:

It&#8217;s a friendly group of people, and we seem to get along well
Alex Crouzen picked up [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of people asked me to blog as <a href="http://t-machine.org/index.php/2009/06/28/want-to-help-write-a-simple-rpg-for-iphone/" >this volunteer project</a> progressed, share some insight into how things were going. I&#8217;ve not had enough time until just now, and it&#8217;s a mix: Some good news, some bad news.<br />
<span id="more-648"></span><br />
Good news:</p>
<ul>
<li>It&#8217;s a friendly group of people, and we seem to get along well
<li>Alex Crouzen picked up Objective C and OpenGL, and Shi Daniels threw together some wall and floor textures. That gave us a very basic &#8220;here&#8217;s some walls and floors, running in OpenGL, on an iPhone&#8221;, but no walking, no movable camera, no interaction, etc. It actually worked! :)
<li>Brian Green and Wendy Despain (both games industry pros) joined up and did loads of great game-design and plot work. As a group, lead by them, we generated lots of pages of good design &#8211; although (my fault) the remit probably wasn&#8217;t as well constrained as it should have been
<li>Lots of good ideas and commentary from the other people in the group
<li>We setup a private wiki, a 24-hour skype group-chat, and a private google group, and had some pretty good communications going between the active contributors
<li>I picked up Alex&#8217;s code and rewrote the underlying OpenGL stuff (I&#8217;m very rusty; haven&#8217;t done any OpenGL for > 4 years), but got it integrated with iPhone GUI stuff, so you could use drag gestures to move around the map in 3D, and added some programmatic map generation
</ul>
<p>Bad news:</p>
<ul>
<li>A lot of people (I think more than half, in the end!) had to step back &#8211; or even drop out &#8211; due to time constraints / external commitments (work, life, etc). Ultimately, through no fault of any individual &#8230; our team was somewhat gutted before we&#8217;d got beyond the first milestone :(
<li>&#8230;as a result of that, and some mistakes I personally made on the project leadership side, we stagnated, and the project has ground to a halt with too few active coders
</ul>
<p>It&#8217;s not clear where we&#8217;ll go from here, but I&#8217;m now looking at whether I can take some of the lessons learnt from this and start it all over again, do it better, more simply, and more clearly directed, as a commercial project.</p>
<p>One of the biggest mistakes I made personally is that I tried to do this as a volunteer project &#8211; but simultaneously tried to do it unmanaged, Scrum-style. You could fairly argue that this was foolish, given that I&#8217;ve run a lot of volunteer projects before, and they have *always* needed huge amounts of vicious, aggressive project management. Not because people are lazy or dumb, but merely because volunteer projects are always the lowest item on people&#8217;s list of priorities (way below &#8220;day job&#8221; and &#8220;family&#8221;, for instance &#8211; which is fair enough).</p>
<p>But I&#8217;ve got so used to working this way now (team-based, distributed responsibility, etc) that I ignored my  previous experience and actively avoided aggressive PM.</p>
<p>I&#8217;m putting together a detailed project plan now &#8211; as if I were doing this commercially. i.e. working it out based on me personally paying other people to work on it &#8211; it may not be viable / possible, but if nothing else it&#8217;s a good practice to plan to that level of diligence. It&#8217;s just a theoretical exercise right now, although I&#8217;m sharing it with some industry colleagues and some professional coders and artists, seeing if it&#8217;s convincing enough for any of them to want to try it.</p>
<p>One of the interesting things I&#8217;ve noticed already while writing it up that way is that &#8211; if I have to pay people &#8211; I&#8217;d start with a much smaller team, almost entirely coders, and only bring on other people once we have (*if* we have&#8230;) a substantial working prototype. Which is the opposite of how I was taught to make games originally. But it&#8217;s exactly how I was taught to do commercial startups. This could be interesting&#8230;</p>
<p>PS: here&#8217;s a screenshot of one of the first renders:</p>
<p><img src="https://t-machine.org/wp-content/uploads/picture-11.png" alt="picture-11" title="picture-11" width="414" height="770" class="alignnone size-full wp-image-626" style="float: left" /></p>
]]></content:encoded>
			<wfw:commentRss>http://t-machine.org/index.php/2009/08/13/volunteer-project-a-simple-rpg-for-iphone-update/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Dungeon Master Clone for iPhone &#8211; Concept GUI</title>
		<link>http://t-machine.org/index.php/2009/08/13/dungeon-master-clone-for-iphone-concept-gui/</link>
		<comments>http://t-machine.org/index.php/2009/08/13/dungeon-master-clone-for-iphone-concept-gui/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 17:04:00 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[computer games]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[dev-process]]></category>
		<category><![CDATA[devdiary]]></category>
		<category><![CDATA[games design]]></category>
		<category><![CDATA[iphone]]></category>

		<guid isPermaLink="false">http://t-machine.org/?p=625</guid>
		<description><![CDATA[(c.f. my original post here: http://t-machine.org/index.php/2009/06/28/want-to-help-write-a-simple-rpg-for-iphone/)
I&#8217;ve been playing around with GUI setups for DM / EOTB / Wizardry clones on iPhone, and thought I&#8217;d post some of the more interesting results here &#8211; I&#8217;m interested to see what other people think of each of them.
The first three are all assuming a single-character RPG, the fourth [...]]]></description>
			<content:encoded><![CDATA[<p>(c.f. my original post here: <a href="http://t-machine.org/index.php/2009/06/28/want-to-help-write-a-simple-rpg-for-iphone/" >http://t-machine.org/index.php/2009/06/28/want-to-help-write-a-simple-rpg-for-iphone/</a>)</p>
<p>I&#8217;ve been playing around with GUI setups for DM / EOTB / Wizardry clones on iPhone, and thought I&#8217;d post some of the more interesting results here &#8211; I&#8217;m interested to see what other people think of each of them.</p>
<p>The first three are all assuming a single-character RPG, the fourth is something more like DM / Wizardry (could be 6 chars, could be 3).</p>
<p>Everything is clickable &#8211; small maps become full screen map, blue buttons fire spells, character portraits go to the inventory screens.</p>
<p>Screens with no arrow buttons require you to drag your finger forwards/backwards/left/right to move, and allow 360 degree movement. Screens with arrow buttons assume you can only turn 90 degrees at a time (like the original games), although they smoothly animate the rotations (UN-like the original games &#8211; because I have access to OpenGL to do the 3D for me).</p>
<p>What do you think?</p>
<p><a href="http://t-machine.org/index.php/2009/08/13/dungeon-master-clone-for-iphone-concept-gui/concept-ss-1/"  rel="attachment wp-att-642"><img src="https://t-machine.org/wp-content/uploads/concept-ss-1.png" alt="concept-ss-1" title="concept-ss-1" width="480" height="320" class="alignnone size-full wp-image-642" /></a></p>
<p><a href="http://t-machine.org/index.php/2009/08/13/dungeon-master-clone-for-iphone-concept-gui/concept-ss-2/"  rel="attachment wp-att-643"><img src="https://t-machine.org/wp-content/uploads/concept-ss-2.png" alt="concept-ss-2" title="concept-ss-2" width="480" height="320" class="alignnone size-full wp-image-643" /></a></p>
<p><a href="http://t-machine.org/index.php/2009/08/13/dungeon-master-clone-for-iphone-concept-gui/concept-ss-3/"  rel="attachment wp-att-644"><img src="https://t-machine.org/wp-content/uploads/concept-ss-3.png" alt="concept-ss-3" title="concept-ss-3" width="480" height="320" class="alignnone size-full wp-image-644" /></a><a href="http://t-machine.org/index.php/2009/08/13/dungeon-master-clone-for-iphone-concept-gui/concept-ss-4/"  rel="attachment wp-att-645"><img src="https://t-machine.org/wp-content/uploads/concept-ss-4.png" alt="concept-ss-4" title="concept-ss-4" width="480" height="320" class="alignnone size-full wp-image-645" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://t-machine.org/index.php/2009/08/13/dungeon-master-clone-for-iphone-concept-gui/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Salaries for startup directors / executives</title>
		<link>http://t-machine.org/index.php/2008/10/02/salaries-for-startup-directors-executives/</link>
		<comments>http://t-machine.org/index.php/2008/10/02/salaries-for-startup-directors-executives/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 14:30:03 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[devdiary]]></category>
		<category><![CDATA[games industry]]></category>
		<category><![CDATA[startup advice]]></category>

		<guid isPermaLink="false">http://t-machine.org/index.php/2008/10/02/salaries-for-startup-directors-executives/</guid>
		<description><![CDATA[This is in two parts &#8211; the problem that lead to me even caring, and then some very interesting conclusions that can be drawn from looking at last year&#8217;s aggregate data on how much tech startups ACTUALLY pay their execs. A lot of random speculation is thrown in, I don&#8217;t stand by most of it, [...]]]></description>
			<content:encoded><![CDATA[<p>This is in two parts &#8211; the problem that lead to me even caring, and then some very interesting conclusions that can be drawn from looking at last year&#8217;s aggregate data on how much tech startups ACTUALLY pay their execs. A lot of random speculation is thrown in, I don&#8217;t stand by most of it, but it&#8217;s interesting how much stands out just from looking at the aggregate data.</p>
<p>PS: to all the people reading this blog for the MMO tech stuff, I hope you don&#8217;t mind the shift to a lot more business stuff lately. This is what happens when you put together a new startup :). I promise there&#8217;ll be more MMO-specific stuff in future&#8230;<br />
<span id="more-255"></span></p>
<h4>Setting salaries for new startups is tough</h4>
<p>At some point in the not-distant future I&#8217;m going to have to provide projected financials for the first 3-5 years of our startup. I prepared this many weeks ago (how do you know how much funding you&#8217;re looking for if you don&#8217;t know what you&#8217;re spending it on? My advice: create your financial spreadsheet as one of your first activities, but keep it simple), and it was all straightforward (I know most of the data I need for these things off the top of my head by now) &#8211; except for salaries / compensation for the executives (both founders and any other senior management &#8211; CEO, CFO, CMO, CTO, etc).</p>
<p>I have 2 co-founders, so between us we&#8217;re covering CEO, CTO, CCO (Creative). At some point, we&#8217;ll want someone doing the job of CFO, and someone doing the job of CMO (whether they get those titles depends a lot on how much the company needs them to do). So, potentially half the executive-level management of the company will be founders (with appropriate levels of equity / ownership of the company), and half will be employees (although &#8211; depending on how valuable they are to the company &#8211; probably with significant equity of their own).</p>
<p>But &#8230; what *is* &#8220;appropriate&#8221;? What&#8217;s normal? In an annual salary (including some level of bonus) how do you balance cash, equity, vesting, and options? I&#8217;ve worked in startups where the directors were paid the average wage for the anyone in employment (circa $60k at the time), and their upside came through having higher allocations of options / accelerated vesting at year end and in bonus. I&#8217;ve even worked at one startup where directors were paid much less &#8211; around the level of a high-end graduate-salary in their respective professions (which caused some issues of its own). Those were both companies with very very young staff, though &#8211; in each case I think only 1 in 10 of the staff were over the age of 30 (including the directors &#8211; which, again, caused some issues of its own).</p>
<p>So, when putting together my spreadsheet, I tried to find details on &#8220;normal&#8221; levels for startups (whilse being very aware that every company &#8211; and, more importantly, every investor &#8211; has a different take on this; don&#8217;t assume this is standardized &#8211; it&#8217;s all negotiable). I found a lot less data than I expected, and in the end I created reasonable estimates based on the salaries people of the right level could guarantee getting themselves elsewhere, and factoring in a positive opportunity cost for the fact this is a startup where they&#8217;ll get to do a lot more cool stuff than elsewhere, and I ignored the equity levels. That was OK for my needs back then, but I&#8217;ll need to do it properly soon.</p>
<h4>StartupCFO, to the rescue&#8230;</h4>
<p>And then I spotted this 2007 <a href="http://www.wilmerhale.com/files/Publication/49c3d421-8ef2-4798-9c55-59cc052a2b42/Presentation/PublicationAttachment/15f7c7a8-dea7-4514-a317-bdf11c875fde/2007_Compstudy_IT_abridged.pdf" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.wilmerhale.com/files/Publication/49c3d421-8ef2-4798-9c55-59cc052a2b42/Presentation/PublicationAttachment/15f7c7a8-dea7-4514-a317-bdf11c875fde/2007_Compstudy_IT_abridged.pdf');">report of compensation / salaries for executives in IT and technology startups</a>, courtesy of Mark MacLeod (who blogs at <a href="http://startupcfo.ca/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://startupcfo.ca/');">TheStartupCFO</a>). This was very useful, and having a quick skim through, I noticed a few takeaways that I thought I&#8217;d blog now for future reference</p>
<h4>Cash Compensation</h4>
<ul>
<li>Base salaries for core execs are all very close to $150k, only big difference is that CEOs get a lot more ($215k)
<li>Averaged across companies, execs in all positions hit approx 2/3 of their bonus targets (very interesting when evaluating how much YOU might earn from your contract, or from the other side: when evaluating how high to set targets for your execs)
<li>Core execs all have a bonus that is 25-30% of base salary, big difference is Sales (but not marketing), who gets over 60% of base as bonus, and CEO/COO, who gets 40% for leading the company (?)
</ul>
<h4>Where Companies Locate Talent</h4>
<ul>
<li>Compared to average, Investors are more likely to refer / choose the CEO and/or CFO
<li>Compared to average, CEOs are less likely to refer / choose the CMO, CSO, and CFO (i.e. the sales/marketing side, and the finance side &#8211; interestingly, all of which are roles that traditionally fall on the CEOs shoulders in early stages; maybe they&#8217;re less keen to lose them?)
<li>Obviously &#8230; CEOs are less likely to refer CEOs (hey, want my job? here you go!), and massively likely to refer &#8220;President/COO&#8221; (due to the often ultra-close relationship between CEO and that position) &#8211; no news here
</ul>
<h4>Equity for Execs</h4>
<ul>
<li>President/COO position has massive discrepancy between average and median (this backsup to my theory that these two titles hide some very different meanings of the roles at different companies, and is part of why I discount the president/COO as being too vague in all the other results)
<li>When hiring a CEO, expect to give them 5% equity
<li>When hiring any other core exec (CFO CTO CMO CSO) expect to give them 1%-1.5% equity
<li>CTO and COO do a good job of aggregating some extra equity after being hired to the company, most other execs never get any more
<li>Most companies giving equity to execs when hiring them do it in the form of incentive stock options (two thirds) or non-qualified stock options (one seventh)
</ul>
<h4>Severance</h4>
<ul>
<li>CTO&#8217;s get the worst severance packages of any of the core execs (interesting given how in all other measures they tend to do in the top tier of the core execs &#8211; why? do they tend to be less inclined to leave, or be not so good at negotiating severance?)
<li>CTO and Head of Engineering are also the least likely to have any severace package at all (hmm&#8230;)
</ul>
<h4>Organizational Structure (which execs do you even have?)</h4>
<ul>
<li>Everyone has a CEO (duh!)
<li>Most have a CTO (duh!)
<li>CFO&#8217;s suddenly become VERY popular as soon as you raise a second round of funding, and remain so for future rounds
<li>Slightly more companies start with a head of Sales than a CFO, and although it switches round (still only small difference) when that all-important 2nd round funding comes in (and a CFO is foisted on the company, or the amount of money being dealt with simply now demands a dedicated senior exec to handle it) &#8230; if the company goes to future funding rounds, then the CSO / Head of Sales becomes massively popular &#8211; practically everyone has one! (i.e. the company becomes secure, no longer a startup, growth and profit becomes primarily through plain sales, like normal companies)
<li>Founders that were other execs tend to transition to becoming Head of Business Development as the company grows and goes through more and more funding rounds (no surprise &#8211; it ain&#8217;t a startup any more, so they get replaced by people more experienced with corporates; they also know the market/business better than anyone)
<li>Companies tend to shed their founding CEO &#8211; although a good third of them hang in there to make the company a massive one, with four or more rounds of funding
<li>Companies tend to retain their founding CTO&#8217;s, if the CTO survives the first round of funding
</ul>
<h4>Dilution</h4>
<ul>
<li>CEOs tend to start by owning almost half the company, even after one round of funding (less 10% &#8211; they probably sold 20% to an investor, losing 10% off their 50%, going down to 40%; the rest coming out of co-founders shares)
<li>Other core execs tend to start with a lot less &#8211; around 20% for the CTO, for instance (I think this is being skewed: we know all companies have CEOs, but where they are a 2-founder company, the other founder will vary among the core exec roles. So, CEOs averages get disproportionately more benefit from the 2-founder case; CTOs are often present in companies with 3 founders, hence starting with 20% &#8211; this suggests that in those cases, the CEO is also starting with 20% after first round funding)
<li>If the company goes to 2nd round funding (i.e. its doing well, becoming a real company), then the median ownership levels out at around 5% for each core exec &#8211; but a small cadre of CEOs hang on to a lot more, dragging the average up to 10% (c.f. above comment about skewing in the 2-founder case)
<li>Companies that go really big, and reach four funding rounds, the least well-off CEOs bottom out &#8211; the 25th percentile drops from 5% equity to a mere 2% equity &#8211; but the good ones all suddenly cluster tightly around %8 (I suspect this may be skewed by 2-founder companies reachign a 4th round that is more like the 3rd round for other companies? Reaching a 4th round of funding is pretty unusual)
<li>For those same companies, something odd happens with the core execs &#8211; the average equity ends up above the 75th percentile (is this because they have to pay really high equities to attract talent good enough to join someone else&#8217;s company instead of starting on their own? I have no idea, just guessing)
</ul>
<p>Anyway, go read the report for yourself &#8211; but some of the above figures (the real conclusions, rather than my random observations ;)) are useful enough for me to use directly in future as rules of thumb.</p>
]]></content:encoded>
			<wfw:commentRss>http://t-machine.org/index.php/2008/10/02/salaries-for-startup-directors-executives/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Writing games in Korean &#8211; part 3</title>
		<link>http://t-machine.org/index.php/2008/04/21/writing-games-in-korean-part-3/</link>
		<comments>http://t-machine.org/index.php/2008/04/21/writing-games-in-korean-part-3/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 10:41:01 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[agile]]></category>
		<category><![CDATA[devdiary]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://t-machine.org/?p=160</guid>
		<description><![CDATA[Computer grammars, Unicode in Eclipse, and problems with Java&#8217;s XML parsers&#8230;

Death to proprietary Grammars!
In my first attempts at writing Korean applications, before I had any font rendering up and running, and with no special XML editor to hand, I had a simple but nasty problem: how do you store Korean characters persistently? I wanted to [...]]]></description>
			<content:encoded><![CDATA[<p>Computer grammars, Unicode in Eclipse, and problems with Java&#8217;s XML parsers&#8230;<br />
<span id="more-160"></span></p>
<h4>Death to proprietary Grammars!</h4>
<p>In my first attempts at writing Korean applications, before I had any font rendering up and running, and with no special XML editor to hand, I had a simple but nasty problem: how do you store Korean characters persistently? I wanted to have to type out the vocabulary once and once only, and re-load it in multiple applications.</p>
<p>I knew lots of theory about how unicode &#8220;might&#8221; work, but also knew a lot of it was poorly implemented in practice, so I tried to avoid being dependent on everything working &#8220;as it is supposed to&#8221;. Instead, I went with a simple hack: I took the &#8220;standard&#8221; transliterations used in English/Korean today &#8211; a,i,o,eo,u,ya,yo,yeo,yu etc &#8211; and used them as an intermediate language that I could:</p>
<ol>
<li>write out to an ordinary ASCII file</li>
<li>read in from an ASCII file</li>
<li>guaranteed readable *correctly* in every IDE, tool, editor etc (everything speaks ASCII&#8230;)</li>
<li>100% correctly translate from this into Korean for display</li>
<li>100% correctly translate into this from typed Korean characters to check that the player typed the &#8220;correct&#8221; translation in-game</li>
</ol>
<p>But&#8230;that&#8217;s pretty nasty to write a grammar for, and yacc and lex and friends were still horrendously under-documented last time I checked (NB: years ago at University, back when the smorgasbord of Compiler Theory was still in my head, these apps were merely tricky to use, but I could manage. In the years since, as the knowledge faded from the front of my mind, and I&#8217;ve had reason to re-use those tools, I&#8217;ve found them a complete nightmare. The last few times I needed them, I actually didn&#8217;t use them at all and knowingly wrote *bad* source code that I knew to be buggy, fragile, and I even knew was taking me substantially longer to write than it would have taken just to use the tools. Why? Because they are so obtuse and weakly documented that I gave up all hope of working out / remembering how to use them. I felt pretty guilty. I also felt very frustrated. I hope things have improved by now, but I&#8217;m trying to write these Korean games as rapidly as possible, and didn&#8217;t want to risk the loss of time finding out)</p>
<p>So, I took the short-cut, and converted the standard transliterations into a context-free grammar (because context-free grammars are excessively easy to implement parsers for, by hand, by humans). This means I have a bunch of vocab files with things like:</p>
<blockquote><p>&#8220;ngaan1 n1yeong haa s2ay ngyo&#8221;</p></blockquote>
<p>where the real transliteration would have been:</p>
<blockquote><p>&#8220;an nyeong ha say yo&#8221;</p></blockquote>
<p>Similar enough to be workable, but confusing and, frankly, starting to get irritating &#8211; I know I&#8217;ll have to fix it sooner or later (assuming I ever want anyone else to write their own vocab files), and it&#8217;s such an ugly hack, and definitely not the best way to do things long-term.</p>
<p>Although, incidentally, there was an minor beneficial side-effect to this proprietary grammar: by accident, I ended up learning my consonants in Korean better &#8211; I learnt by accident which can conjoin together, which can be doubled, which are single-only, etc. This is mostly because I had to explicitly make each different letter unique in my grammar, and then whenever writing out vocab &#8211; or debugging my games &#8211; I had to remember what I&#8217;d named each letter, and also which letters were transliterated as one latin letter (e.g. h, which is only ever alone), and which as two latin letters (e.g. s which can be single or doubles, leading to two letters in my grammer: s1 and s2)).</p>
<p>But the time has come to &#8220;fix&#8221; this: my font rendering is, dare I say it, pretty good now, with my applications happily switching back and forth between conjoining jamos and single-ideograph rendering pipelines on the fly, and with auto-detection of fonts (they find the prettiest font you have installed when they startup, and adapt to use that one &#8211; or pop up an error message to tell you to go install some Korean fonts).</p>
<p>And now the fun starts. There&#8217;s only one correct way to do this: store Unicode characters directly in my vocab files (this is practically the raison d&#8217;etre for the existence of Unicode; it excels at doing this well)&#8230;</p>
<h4>Unicode, unicode everywhere, but ne&#8217;er a char to read</h4>
<p>&#8230;and this is where I had some good news, and some bad news.</p>
<p>Good news: Eclipse&#8217;s ultra-simple XML editor not only fully supports typing unicode Korean characters directly into its editing window, and automatically render them <strong>in a Korean font</strong>, but it even automatically <strong>correctly</strong> saves the entire XML file with whatever encoding you specify in the first line of the file (it notices when I change that line and silently changes the save format when I next save! Rocking!).</p>
<p>(NB: I thought this was one that I&#8217;d installed manually, but when I tried to find out what the name was and who wrote it so I could give them a link here, I could only find references in Eclipse&#8217;s plugin list to a generic, Eclipse-provided, XML plugin. Anyone want to confirm/deny?)</p>
<p>I had assumed I&#8217;d need to go and buy a commercial XML editor to get full unicode support (unicode support being something that most apps do &#8220;partially&#8221; these days &#8211; c.f. my first post on writing Korean apps, and the detailed look at how Microsoft&#8217;s unicode fonts get all the conjoined jamos wrong, so that they won&#8217;t even render Korean :( ). But instead, I just type direct into the IDE.</p>
<p>Although&#8230;I can&#8217;t type Korean characters in Windows yet (sadly, Windows comes with this functionality uninstalled by default, and has to be installed off the original CD &#8211; but my Windows CD is several hundred miles away :(). However, using Character Map, which is part of the base windows install, I can get it to type them, and then I can copy/paste them into the text editor, and mostly get by for now.</p>
<p>Bad news: Java&#8217;s standard libraries corrupted the unicode characters when reading them from disk; in some cases, they even outright refused to load the files at all (SAXParseException&#8217;s being thrown for invalid file data) &#8230; which was what gave the game away in the end. This took me a long time to figure out &#8230; it wasn&#8217;t until I started experimenting with different UTF encodings that I saw the parser crashes and worked it out. The root cause was the last thing I suspected: depending upon a very minor change in how you invoke it, the XML parser from the standard library completely ignores the encoding of the file. Argh.</p>
<p>Various exceptions that can be thrown that are symptoms of this problem (all depends which encoding you&#8217;ve used):</p>
<ul>
<li>
<pre>Exception in thread "main" org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.
	at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
</pre>
</li>
<li>
<pre>
Exception in thread "main" org.xml.sax.SAXParseException: Content is not allowed in prolog.
	at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
</pre>
</li>
</ul>
<p>Or, if you use UTF-8 encoding, you just get gibberish printing to the screen, such as this:</p>
<p><img src="https://t-machine.org/wp-content/uploads/2008/04/korean-unicode-utf8-gibberish.png" alt="utf8-gibberish" title="korean-unicode-utf8-gibberish" width="219" height="152" class="aligncenter size-full wp-image-161" /></p>
<p>For reference, once I fixed the problem, the same code rendered like this (as I intended):</p>
<p><img src="https://t-machine.org/wp-content/uploads/2008/04/korean-unicode-utf8-correct.png" alt="utf8-correct" title="korean-unicode-utf8-correct" width="219" height="152" class="aligncenter size-full wp-image-162" /></p>
<p>This is bad. Really bad. You get no warnings about this. Also, as far as I can remember, the way I&#8217;ve usually seen this library invoked in all the hundreds of times I&#8217;ve seen it in source-code on the web and in books and tutorials &#8230; is the way I was using it &#8211; which simply isn&#8217;t correct. It works in some situations, but it assumes too much. So long as you only ever read and write XML with US-ASCII, and only ever live in America or England, you&#8217;ll probably never even notice. The moment someone starts giving your app a 100% valid perfectly-formed XML file which just happens to have an encoding different from the one that your JVM uses (based on your OS settings and language settings) &#8230; BOOM!</p>
<p>This is documented in the library docs &#8211; as soon as I realised it was the parser doing something it shouldn&#8217;t be doing, it took literally only a couple of minutes to find the ref in the docs, see the problem, and fix it. Here&#8217;s the documentation:</p>
<blockquote><p>
org.xml.sax<br />
Class InputSource</p>
<p>The SAX parser will use the InputSource object to determine how to read XML input. If there is a character stream available, the parser will read that stream directly, disregarding any text encoding declaration found in that stream. If there is no character stream, but there is a byte stream, the parser will use that byte stream, using the encoding specified in the InputSource or else (if no encoding is specified) autodetecting the character encoding using an algorithm such as the one in the XML specification. If neither a character stream nor a byte stream is available, the parser will attempt to open a URI connection to the resource identified by the system identifier.</p></blockquote>
<p>So, where I had this line of code:</p>
<blockquote><p><code><br />
xpath.evaluate( "vocab/*", new InputSource( new FileReader( vocabFile ) ), XPathConstants.NODESET );</code>
</p></blockquote>
<p>I had to change it to this:</p>
<blockquote><p><code><br />
xpath.evaluate( "vocab/*", new InputSource( new FileInputStream( vocabFile ) ), XPathConstants.NODESET );</code>
</p></blockquote>
<p>The first line asks the Java standard library to automatically do byte-to-character conversions &#8211; and the JVM will typically buffer its reads from the hard-disk, providing (potentially) much better performance. The second line does raw byte reading from the hard disk, with no buffering. Java programmers who care about performance generally never use the second approach, unless forced to. And, in general, the first approach is the &#8220;right&#8221; one, because it causes the JVM to correctly perform all the character conversion too.</p>
<p>But in this case &#8230; raw bytes are the only way to go.</p>
<p>IMHO, this is a flaw in the XML parser &#8211; I would have expected it to at least notice when an incompatible encoding was being specified and signal an alert, perhaps output something to stderr? Or even throw an exception &#8211; if you get an incorrect encoding, that&#8217;s a pretty big sign that incorrect data is being fed in, and &#8220;do nothing, but crash a few thousand instructions later&#8221; doesn&#8217;t seem to me to be the most appropriate response&#8230;</p>
<h4>Conjoining revisited &#8211; more valuable than first thought?</h4>
<p>I mentioned in <a href="http://t-machine.org/index.php/2008/03/28/writing-games-in-korean-part-1writing-games-in-korean-part-1/" >my first post</a> the concept of Conjoining Jamos &#8211; a system of rendering Korean ideographs/glyphs  by assembling them from the individual letters that make them up (which works because Korean is an alphabet-based language, but the letters have a more interesting positioning scheme than Latin&#8217;s right,right,right-a-bit-more, etc). I pointed out that Microsoft&#8217;s Unicode fonts that provide Korean characters are fundamentally broken and can&#8217;t render conjoined characters at all (the tables of metadata inside the font itself have the wrong information). A commenter pointed out that in practice conjoined jamos may rarely get used anyway &#8211; instead, nearly all applications simply calculate the pre-made ideograph (because Unicode can have hundreds of thousands of &#8220;letters&#8221;, they&#8217;ve actually worked out every possible combination of letters into ideographs, and put ALL of them inside Unicode. Cool).</p>
<p>And, for completeness, I added an implementation using these pre-baked characters (which actually render correctly even with Microsoft fonts!). Lovely. Ah. But, when adding some new features to my game, I realised that maybe I *have* to use conjoining jamos. How the heck do you hilight individual letters within an ideograph if you&#8217;re NOT using conjoining jamos?</p>
<p>I would guess that in every situation where you can hilight text, you probably need to use conjoining jamos &#8211; which means a large percentage of computer applications. I&#8217;m not entirely sure (I can think of ways you could hack around it) but conjoining seems the only sensible way to do it.</p>
<p>All *I* want to do is change the colours of individual letter-groups within the ideographs. Because I&#8217;ve written a new minigame: words and phrases fly towards you, and you have to type them in Korean to nullify them before they collide with your avatar.</p>
<p>I haven&#8217;t worked out how I&#8217;m going to do this yet &#8211; I don&#8217;t have any fonts that I can really use. I need a font that is:</p>
<ul>
<li>Pre-installed on every windows PC, or easy to install
<ul>
<li>Only Microsoft can pre-install fonts on windows, and they don&#8217;t pre-install ANY Unicode fonts. If you have MS Office, that automatically installs some unicode fonts, so &#8230; &#8220;partial&#8221;</li>
<li>For everyone else, I recommend UnBatang, which I&#8217;ve been using. It&#8217;s free, but sadly until/unless I find a license I can&#8217;t include it in the game &#8211; you have to download it manually</li>
</ul>
</li>
<li>Includes all the letters, and renders them correctly
<ul>
<li>You may think this is guaranteed &#8211; but no, Microsoft&#8217;s fonts seem to be broken for the conjoining jamos. Non-conjoined characters render perfectly, but you&#8217;re out of luck with conjoining.
</li>
<li>
UnBatang renders ALL the characters correctly &#8211; but the conjoining jamos it has are extremely ugly, so low-resolution that they&#8217;re almost impossible to read a lot of the time
</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://t-machine.org/index.php/2008/04/21/writing-games-in-korean-part-3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
