<?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>Full of BS &#187; C/C++</title>
	<atom:link href="http://fullof.bs/category/programming/cc/feed/" rel="self" type="application/rss+xml" />
	<link>http://fullof.bs</link>
	<description>He just never stops talking</description>
	<lastBuildDate>Wed, 21 Mar 2012 05:14:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>c++0x standard finalized; now open for last international comment phase</title>
		<link>http://fullof.bs/c0x-standard-finalized-now-open-for-last-international-comment-phase/</link>
		<comments>http://fullof.bs/c0x-standard-finalized-now-open-for-last-international-comment-phase/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 22:20:04 +0000</pubDate>
		<dc:creator>John Haugeland</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[General Interest]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://fullof.bs/?p=419</guid>
		<description><![CDATA[It&#8217;s finally done!    And, thank god, &#8220;concepts&#8221; are officially in.]]></description>
			<content:encoded><![CDATA[<p><a href="http://herbsutter.wordpress.com/2008/10/28/september-2008-iso-c-standards-meeting-the-draft-has-landed-and-a-new-convener/" target="_blank">It&#8217;s finally done</a>!  <img src='http://fullof.bs/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />   And, thank god, &#8220;concepts&#8221; are officially in.</p>
]]></content:encoded>
			<wfw:commentRss>http://fullof.bs/c0x-standard-finalized-now-open-for-last-international-comment-phase/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gearing Up for Public SVN</title>
		<link>http://fullof.bs/gearing-up-for-public-svn/</link>
		<comments>http://fullof.bs/gearing-up-for-public-svn/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 16:01:46 +0000</pubDate>
		<dc:creator>John Haugeland</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[ECMA / Javascript]]></category>
		<category><![CDATA[ECMAScript]]></category>
		<category><![CDATA[Erlang]]></category>
		<category><![CDATA[Game Algorithms]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools and Libraries]]></category>
		<category><![CDATA[Web and Web Standards]]></category>
		<category><![CDATA[a*]]></category>
		<category><![CDATA[astar]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[embeddable]]></category>
		<category><![CDATA[htstub]]></category>
		<category><![CDATA[Public svn]]></category>
		<category><![CDATA[regression test]]></category>
		<category><![CDATA[scastar a star]]></category>
		<category><![CDATA[scutil]]></category>
		<category><![CDATA[stochastic test]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[unit test]]></category>
		<category><![CDATA[webserver]]></category>

		<guid isPermaLink="false">http://fullof.bs/?p=271</guid>
		<description><![CDATA[I&#8217;m going to be releasing a few new libraries in the next several days, both by archive and public subversion.  I&#8217;ve already bought the domains and built a forum for them.  I even wasted a couple hours subversion automating everything down to the line of having little library websites made automatically, with custom per-library color [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to be releasing a few new libraries in the next several days, both by archive and public subversion.  I&#8217;ve already bought the domains and built a forum for them.  I even wasted a couple hours subversion automating everything down to the line of having little library websites made automatically, with custom per-library color palettes.</p>
<p>I was a little bored.</p>
<p>So we&#8217;re going to have three libraries progressing in the immediate future, with quite a few more over time:</p>
<ol>
<li><a title="HtStub - an embeddable Erlang webserver" href="http://htstub.com/" target="_blank">HtStub</a> &#8211; An embeddable, zero-config, zero-behavior secure Erlang webserver</li>
<li><a title="StoneCypher's A* library, with tutorial" href="http://scastar.com/" target="_blank">SC A-Star</a> &#8211; An efficient, modular ECMAscript (flash/actionscript, javascript, jscript etc) A* implementation with support for custom grid geometries (<em>includes algorithm tutorial</em>)</li>
<li><a title="TestErl - an erlang library for unit, regression and stochastic testing" href="http://testerl.com/" target="_blank">TestErl</a> &#8211; unit, regression and stochastic testing for Erlang</li>
<li><a title="ScUtil - StoneCypher's erlang utility library" href="http://scutil.com/" target="_blank">ScUtil</a> &#8211; a fairly large list of gap filling functionality for Erlang</li>
</ol>
<p>In the near future, I will add C++ and PHP libraries, as well as many some libraries for more obscure languages like FormulaONE, Mozart-Oz, Factor and maybe (sadly) Delphi.  I have more than 30 libraries ready for release.</p>
<p>All those repos are pretty empty at the moment.  That will change in coming days, and I&#8217;m sure I&#8217;ll post lots of boring little snippets here about whatever minor new thing my crap does.</p>
<p>Yay!</p>
]]></content:encoded>
			<wfw:commentRss>http://fullof.bs/gearing-up-for-public-svn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eep.  Yasli::vector is on the move!</title>
		<link>http://fullof.bs/eep-yaslivector-is-on-the-move/</link>
		<comments>http://fullof.bs/eep-yaslivector-is-on-the-move/#comments</comments>
		<pubDate>Wed, 03 Jan 2007 00:26:47 +0000</pubDate>
		<dc:creator>John Haugeland</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.sc.tri-bit.com/archives/193</guid>
		<description><![CDATA[Yeah, I know I&#8217;ve been quiet for a long time. There&#8217;s a good reason, and it&#8217;ll all make sense soon. However, I just stumbled across an article that is so amazing that I just can&#8217;t wait, and I need to share it. Andrei Alexandrescu is a brain, but this one&#8217;s special, even for him. yasli::vector [...]]]></description>
			<content:encoded><![CDATA[<p>Yeah, I know I&#8217;ve been quiet for a long time.  There&#8217;s a good reason, and it&#8217;ll all make sense soon.  However, I just stumbled across an article that is so amazing that I just can&#8217;t wait, and I need to share it.  <a href="http://sc.tri-bit.com/Alexandrescu">Andrei Alexandrescu</a> is a brain, but this one&#8217;s special, even for him.</p>
<p><a href="http://erdani.org/publications/cuj-2004-06.pdf">yasli::vector is on the move</a> &#8211; read it or fail.  Miserably.</p>
<p>(Sorry about the PDF.  I hate them too.  Nothing I can do.)</p>
]]></content:encoded>
			<wfw:commentRss>http://fullof.bs/eep-yaslivector-is-on-the-move/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Checklist for Embedded IE</title>
		<link>http://fullof.bs/checklist-for-embedded-ie/</link>
		<comments>http://fullof.bs/checklist-for-embedded-ie/#comments</comments>
		<pubDate>Thu, 24 Aug 2006 02:13:56 +0000</pubDate>
		<dc:creator>John Haugeland</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[ECMA / Javascript]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools and Libraries]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web and Web Standards]]></category>

		<guid isPermaLink="false">http://blog.sc.tri-bit.com/archives/163</guid>
		<description><![CDATA[MSHTML is an awesome user interface tool, but it has a whole lot of standard behaviors, many of which aren&#8217;t what one wants for an application (since it&#8217;s designed for the web.) This is a list of stuff you need to do to embed IE COM and have it behave like a normal application. There&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>MSHTML is an awesome user interface tool, but it has a whole lot of standard behaviors, many of which aren&#8217;t what one wants for an application (since it&#8217;s designed for the web.)  This is a list of stuff you need to do to embed IE COM and have it behave like a normal application.  There&#8217;s more than a person might expect.</p>
<p><span id="more-153"></span></p>
<ul>
<li>Suppress the user interface.  IE starts with most of its interface turned off, but a few things aren&#8217;t.  Notable things to include are to suppress the context menu and keyboard navigation.</li>
<ul>
<li>There are several ways to suppress the context menu.  The easiest way is to do it in the html.  Add <u>oncontextmenu=&#8221;return false;&#8221;</u> to your &lt;body&gt; and the problem just goes away, and it&#8217;s easily manually overridden for specific elements later.</li>
<li>Alternately, you can override the interface programmatically through <a title="IDocHostUIHandler Interface" href="http://msdn.microsoft.com/workshop/browser/hosting/reference/ifaces/idochostuihandler/idochostuihandler.asp">IDocHostUIHandler</a>.</li>
</ul>
<li>Get rid of the OnNavigate noise (the clicking sound when you hit a link.)  <a title="Suppressing OnNavigate" href="http://blog.sc.tri-bit.com/archives/162">This is harder than it should be</a>.</li>
<li>Prevent keyboard navigation.  If you only ever navigate once, and then do everything else in DHTML, this isn&#8217;t an issue, because there&#8217;s nothing to go forward or back to.  However, if you need to, the way to do this is to capture <a title="BeforeNavigate2" href="http://windowssdk.msdn.microsoft.com/en-us/library/ms628868.aspx">DWebBrowserEvents2::BeforeNavigate2()</a> and fill its last parameter, VARIANT_BOOL*&amp; Cancel, to true.  For security reasons this can&#8217;t be done in HTML without a garish ugly dialog box confirmation.</li>
<li>Prevent dragging and dropping links.  Do this with BeforeNavigate2() just like keyboard navigation.</li>
<li>Prevent selection.  The easiest way to do that is in the HTML by adding <u>onselectstart=&#8221;return false;&#8221;</u> to the &lt;body&gt;, which is also easily overridden for child elements where appropriate.  If you need it programmatically, such as a block which can be turned from and to editability, that&#8217;s in IDocHostUIHandler.</li>
<li>Handle some keys directly.  Particularly often, control keys, tab and f-keys need very different interpretations in applications than are the defaults in IE.  Some keys can be reliably intercepted in JScript, but not all of them.  For lightweight stuff, use JScript; it&#8217;ll be less painful.  However, if you need real control, you need to provide an <a title="Handle keypresses" href="http://msdn.microsoft.com/workshop/browser/hosting/reference/ifaces/idochostuihandler/translateaccelerator.asp">IDocHostUIHandler::TranslateAccelerator()</a> implementation.</li>
<li>Suppress the interior border.  People are often surprised that they turn off the window border in IE, and yet it seems to still appear.  That&#8217;s because IE&#8217;s default stylesheet puts an inset bevel on every web page.  Turn that off in CSS by writing <u>body { border: 0; }</u>.</li>
<li>Begin to embed your images and other support media as resources, and access them with <a title="The res protocol" href="http://msdn.microsoft.com/workshop/networking/predefined/res.asp">the res:// protocol</a>.</li>
<ul>
<li>One ugly caveat: I have never found any variation of the DirectX PNG alpha filter hack which works with res://, and I&#8217;ve looked often and at some very weird variations.  It is my current belief that a PNG cannot be embedded through res:// and still be fixed for alpha.  This leads to the unfortunate case of requiring at least part of your resources on disk.  If anyone knows a way around this, a heads-up would be <em>greatly</em> appreciated.</li>
</ul>
<li>Set up a system to exchange messages between IE DOM/DHTML/JScript and your application.  There are a bujillion ways to do this, but I tend to use a combination of intercepted element events (mostly OnClick in <a title="NO U INVOKE" href="http://msdn.microsoft.com/workshop/browser/webbrowser/reference/ifaces/dwebbrowserevents/dwebbrowserevents.asp">WebBrowserEvents Invoke</a>,) DOM extension behaviors that allow me to call C++ directly from JScript through <a title="The missing link" href="http://msdn.microsoft.com/workshop/browser/hosting/reference/ifaces/idochostuihandler/getexternal.asp">IDocHostUIHandler::GetExternal()</a>, and executing scripts directly on the DOM object through <a title="Do what I say, DOM" href="http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/window2/execscript.asp">IHTMLWindow2::execScript()</a>.</li>
<li>Build everything in the to be inside a container; make the body itself <u>overflow: none</u>.  This prevents several ugly re-layout quirks which we&#8217;re used to on the web but not in applications, when content gets long.</li>
<ul>
<li>Start the container invisible, and make the black.  That way, during the lag while resources are being loaded, you have a reasonable appearance.  Black flashes look correct.  White flashes look broken.</li>
<li>Set an <u>onload=&#8221;HandleLoad();&#8221;</u> function for the &lt;body&gt;.  That way, you know when all resources are loaded, and thus when it&#8217;s safe to take the invisible clause off of the main container.</li>
<li>Set the main container <u>position:relative</u>, to make absolute positioning of contained elements easier.</li>
</ul>
<li>Build your web page in as a resource, and load it through <a title="How to load a document without about:blank and its white flash." href="http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/document2/write.asp">IHtmlDocument2::write()</a>.  This allows you to load a document at runtime without using about:blank (which most people use, but which causes a brief white flash before your application loads; very unprofessional looking.)  You&#8217;ll need <a title="SafeArrayAccessData" href="http://windowssdk.msdn.microsoft.com/en-us/library/ms221620.aspx">SafeArrayAccessData()</a> and <a title="SafeArrayUnaccessData" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/automat/html/61b482cb-f0a3-4efb-9a68-f373f241e89a.asp">SafeArrayUnaccessData()</a> to use write() safely.  When it comes time to skin or internationalize, and when you&#8217;re dealing with a compile cycle which is just linking, you&#8217;ll thank me for this.</li>
<li>Suppress dragging on links and buttons.  If you don&#8217;t, people will be able to drag them outside the app and onto the desktop as shortcuts, and when followed those shortcuts will lead into your HTML page from the outside (which is, surprisingly, legal.)</li>
<li>Consider compressing your executable, such as with <a title="Universal Packer for Executables" href="http://upx.sourceforge.net/">UPX</a>, which makes resources unreadable externally.</li>
<li>Set an id on your &lt;body&gt;.  The is considered the origin of most events which don&#8217;t have a clear origin, and that means that catching these events is a lot easier (catching by id is the most straightforward way to sort out sources.)</li>
<li>Resist the urge to use runtime styles.  They&#8217;re not worth the problems they cause.</li>
</ul>
<p>That should get the new IE user through some common foibles.  I&#8217;ve probably missed stuff; if you can think of something, lemme know.  I do not currently know of a way to embed flash, unfortunately, without leaving available an extra file.</p>
]]></content:encoded>
			<wfw:commentRss>http://fullof.bs/checklist-for-embedded-ie/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Oh, Neat: A Hack To Fix The IE Click Problem</title>
		<link>http://fullof.bs/oh-neat-a-hack-to-fix-the-ie-click-problem/</link>
		<comments>http://fullof.bs/oh-neat-a-hack-to-fix-the-ie-click-problem/#comments</comments>
		<pubDate>Thu, 24 Aug 2006 01:08:44 +0000</pubDate>
		<dc:creator>John Haugeland</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.sc.tri-bit.com/archives/162</guid>
		<description><![CDATA[I always wondered how applications suppressed that god-awful clicking sound in embedded IE. Usually you catch them screwing with user preferences, but there&#8217;s a utility I have which never showed any apparent method of getting rid of the goddamned noise. I always assumed they just styled text to look like a link. Well, I still [...]]]></description>
			<content:encoded><![CDATA[<p>I always wondered how applications suppressed that god-awful clicking sound in embedded IE.  Usually you catch them screwing with user preferences, but there&#8217;s a utility I have which never showed any apparent method of getting rid of the goddamned noise.  I always assumed they just styled text to look like a link.</p>
<p>Well, I still don&#8217;t know what he does, but I found a way.</p>
<p><span id="more-152"></span></p>
<p>Back in post #141, <a title="More IE Woes - This Time, from the Inside" href="http://blog.sc.tri-bit.com/archives/141">More IE Woes</a>, I documented several problems.  One was that <a title="LIES!  DIRTY LIES!" href="http://support.microsoft.com/default.aspx?scid=kb;en-us;201901">MSDN claims this noise cannot be suppressed</a>.  Indeed, by design, IE6 refuses to allow you to suppress that sound (god knows why.)  That MSDN article goes as far as to tell you to <em>override the user&#8217;s sound preferences to turn the noise off</em>.  How badbear is that?  Anyway, IE7 <strong>finally </strong>has an interface to turn that off, called <a title="It's about freaking time" href="http://msdn.microsoft.com/workshop/security/szone/overview/sec_featurecontrols.asp">FEATURE_DISABLE_NAVIGATION_SOUNDS</a>.  However, people like me who are reluctant to make their applications non-functional without IE7 will not like that answer.</p>
<p>It turns out there&#8217;s a better way.</p>
<p>There&#8217;s a moderately obscure interface from IE5 for IDocHostUIHandler called <a title="Pay attention, padamon." href="http://msdn.microsoft.com/workshop/browser/hosting/wbcustomization.asp#GetOptionKeyPath">GetOptionKeyPath</a>.  The superficial purpose of this is to allow the IE embedder to create a fake user, so that they can set defaults for IE like the basic font size, background color and so on.  This is generally completely ignored in favor of some CSS, but it turns out that this thing actually covers the sound effect scheme too.</p>
<p>All you need to do is use GetOptionKeyPath, create a fake user, override the OnNavigate sound (and maybe some others) to nothing, and let the rest alone, to default to the user&#8217;s preferences.</p>
<p>Bang: no more clicky noise, and no overriding preferences, breaking other applications and risking corrupting preferences on crash.</p>
<p>Very clean.  <img src='http://fullof.bs/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://fullof.bs/oh-neat-a-hack-to-fix-the-ie-click-problem/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>More IE Woes &#8211; This Time, from the Inside</title>
		<link>http://fullof.bs/more-ie-woes-this-time-from-the-inside/</link>
		<comments>http://fullof.bs/more-ie-woes-this-time-from-the-inside/#comments</comments>
		<pubDate>Fri, 23 Jun 2006 02:01:24 +0000</pubDate>
		<dc:creator>John Haugeland</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools and Libraries]]></category>
		<category><![CDATA[Web and Web Standards]]></category>

		<guid isPermaLink="false">http://blog.sc.tri-bit.com/archives/141</guid>
		<description><![CDATA[Wow.  I haven&#8217;t had such mixed feelings about IE in years. On the one hand, MSHTML &#8211; the COM component that implements IE &#8211; is actually pretty awesome.  I&#8217;ve been able to roll applications using it in hours that would normally have taken weeks.  It&#8217;s an impressive feat of engineering, and though I disagree with [...]]]></description>
			<content:encoded><![CDATA[<p>Wow.  I haven&#8217;t had such mixed feelings about IE in years.</p>
<p><span id="more-134"></span></p>
<p>On the one hand, MSHTML &#8211; the COM component that implements IE &#8211; is actually pretty awesome.  I&#8217;ve been able to roll applications using it in hours that would normally have taken weeks.  It&#8217;s an impressive feat of engineering, and though I disagree with some design decisions, the usability of the embeddable component is actually pretty spectacular, if you&#8217;re familiar with COM.  In particular, the res:// protocol strikes me as borderline brilliant; binary behaviors are awesome; extensible tags have a lot of untapped potential; BHOs would be great except there are too many spamming scum abusing them.</p>
<p>On the other hand, there are problems.  There&#8217;s one outright boneheaded mistake, and the documentation is sadly lacking.</p>
<ul>
<li>The OnNavigate sound &#8211; that click you hear when you get a link &#8211; <a title="I'm not joking - it's impossible" href="http://support.microsoft.com/default.aspx?scid=kb;en-us;201901" target="_blank">cannot be suppressed</a>.  I&#8217;m not joking &#8211; by design, IE refuses to let you get rid of it.  Their suggestions are to override the user&#8217;s global IE preferences, shut off sound, or to hide the browser before you follow any click and then re-show it after the click.  Given how much Microsoft blabbed about how this should be usable as a transparent control, it leaves me flabbergasted that they haven&#8217;t fixed this until IE7 with FEATURE_DISABLE_NAVIGATION_SOUNDS.  Just amazing.</li>
<ul>
<li><strong>Update: </strong><a title="MSDN is teh wrongs" href="http://blog.sc.tri-bit.com/archives/162"><strong>I found a way</strong></a><strong>.  MSDN is wrong about this; it is indeed fixable.</strong></li>
</ul>
<li>This bit about being unable to touch innerHTML on several tag types (notably table and tbody, where it&#8217;s hella useful) pisses me off, but since I can work through DOM, it&#8217;s annoying rather than important.</li>
<li>One of the particularly wootastic things MS did was to generate an interface called IDocHostUIHandler by which one can inject new functions into JS&#8217; purview through the DOM and window.external , allowing you to effectively provide new interfaces just by implementing a COM object with the automation interfaces in IDispatch.  Of course, I can&#8217;t find a complete example in pure-c++ without ATL, WTL, MFC or some other ignorant wrapper nonsense to save my life, so I&#8217;m pretty stuck.  I have a mostly-complete implementation, but when I try to install it, window.external turns to null, suggesting a flaw.  Of course, all the error handling is in window.external, where I can&#8217;t get at it, so your guess is as good as mine about what&#8217;s actually going on.</li>
</ul>
<p>With some extra documentation and if they hadn&#8217;t been such tards about that clicking noise, MSHTML would be a much more wonderful playground than it actually is.  (I&#8217;m pretty sure there is in fact a way to disable those noises &#8211; several commercial applications do it just fine &#8211; but MSDN insists it&#8217;s unpossible, which suggests it&#8217;s probably some undocumented interface somewhere.  Hell.)</p>
]]></content:encoded>
			<wfw:commentRss>http://fullof.bs/more-ie-woes-this-time-from-the-inside/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>On Shadowcasting</title>
		<link>http://fullof.bs/on-shadowcasting/</link>
		<comments>http://fullof.bs/on-shadowcasting/#comments</comments>
		<pubDate>Sun, 02 Apr 2006 06:09:18 +0000</pubDate>
		<dc:creator>John Haugeland</dc:creator>
				<category><![CDATA[Artificial Intelligence]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Game Algorithms]]></category>
		<category><![CDATA[Game Design]]></category>
		<category><![CDATA[Gaming]]></category>
		<category><![CDATA[Nintendo DS]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Southgate]]></category>

		<guid isPermaLink="false">http://blog.sc.tri-bit.com/?p=83</guid>
		<description><![CDATA[I haven&#8217;t written a roguelike in a long, long time. Last time, I used the traditional light-per-room model for lighting from the original Rogue; these days, I don&#8217;t find that at all satisfactory. It&#8217;s time for a proper shadowcaster. And, to be plain, I&#8217;d forgotten how much of a hassle a shadowcaster actually is. I [...]]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t written a roguelike in a long, long time.  Last time, I used the traditional light-per-room model for lighting from the original Rogue; these days, I don&#8217;t find that at all satisfactory.  It&#8217;s time for a proper shadowcaster.<br />
<span id="more-107"></span></p>
<p>And, to be plain, I&#8217;d forgotten how much of a hassle a shadowcaster actually is.  I went to dig up maybe some example code, but the good answers were few and far between; there are several each at various roguelike sites like <a title="Dungeondweller's development section" href="http://roguelikedevelopment.org/development/">Dungeondweller</a>, but the articles are written to widely varying levels of quality, most without source, and with no apparent method to compare between methods.  Most of them an experienced programmer can ignore out of hand, but one of the algorithms up there is just repeated line of sight, which is dead slow.  It&#8217;s enough to make a man think about writing another <a title="My empty-ish tutorial page" href="http://sc.tri-bit.com/Category:Tutorials">tutorial</a>&#8230;</p>
<p>Luckily, I know what&#8217;s up, so I&#8217;m going to implement recursive shadowcasting.  There&#8217;s a not-half-bad implementation in this tutorial by <a title="Gordon Lipford's LOS tutorial" href="http://sc.tri-bit.com/Computing_LOS_for_Large_Areas">Gordon Lipford</a>, but in several places he sacrifices efficiency or power for readability.  Right thing to do for a tutorial.  Wrong thing to do for production code.  (He also has several unexplained actions here and there, writes pseudocode where interactions aren&#8217;t clear, and requires the reader to reimplement several structures from explanations, but whatever.)  At any rate, his method is efficient, flexible, and less painful to implement than some of its competition, so I&#8217;m running with it.</p>
<p>One of the very cool things about Lipford&#8217;s method is that it&#8217;s arc-angle based.  As a result, objects don&#8217;t actually have to fit a tile; rays are radiated.  That means that anti-aliasing one&#8217;s shadows is in fact realistic; I&#8217;m halfway done with that in my shadowcaster now.  Other things could be added, but I&#8217;ve decided to skip them for now.  One of the <strong>really</strong> neat things about this modified method, though, which uprises from the line of sight algorithm is that I have accurate overhead cover rules and a good set of premise data to work in the notion of &#8220;perception.&#8221;</p>
<p>Simulating perception accurately is traditionally a problem for AI behavior, but in a Roguelike it&#8217;s a bigger problem than usual.  Because roguelikes offer such complex tactical situations, and because speed in varying environments is such an issue, players often want to &#8220;lose&#8221; the predators by hiding.  Lots of the common methods for handling roguelike behavior involve simple distance calculations, meaning monsters can semi-effectively follow you through visual obstacles which otherwise should confuse them, such as walls.  Sometimes this is of great tactical advantage to the player; s/he can use slight speed or distance advantages to get around a wall with a u-turn, then rely on the monster keeping the nearest mathematical distance and walk the other way down the wall, acquiring some safety.</p>
<p>Now, I&#8217;m all for cheating on the player&#8217;s behalf; one of these days I&#8217;ll blog about it at length.  However, there&#8217;s cheating and there&#8217;s cheating.  Some of it keeps little nagging things from ruining gameplay; that&#8217;s good cheating.  Being lax on player bullet collision, and being overstrict on player personal collision, means that the player &#8220;just barely gets by&#8221; when oftentimes they shouldn&#8217;t, and &#8220;just barely makes the shot&#8221; when oftentimes they shouldn&#8217;t.  You can just crank the game difficulty to compensate, and it leads to a player never feeling like they were ripped off or cheated.  The Japanese game company <a title="Treasure" href="http://www.treasure-inc.co.jp/index01.html">Treasure</a> are absolute masters of this careful balance (sorry, AFAIK they don&#8217;t have an English-language page.  Just pretend you can read it.)  But, there&#8217;s another kind of cheating that game programmers do.  Actually, there are several others; I&#8217;m gonna skip stuff like giving opponent AI information it shouldn&#8217;t have to keep it competitive.  Right now, what I&#8217;m going to talk about is sacrificing realism for computation time.</p>
<p>There are several problems with cheating to save computation time.  Some of them are reconcilable; others aren&#8217;t.  Generally the least controllable issue here is that oftentimes you just can&#8217;t afford the raw horsepower to do what you want to do correctly.  First person shooters in the 286/386 era are a prime example; Wolfenstein and DooM got by just fine with blitting, but given modern standards they look positively silly.  The important bit here, though, is that Wolfenstein and DooM&#8217;s approximations were good enough™ they did not adversely impact the game, and until they were made outdated by the horsepower required for a more accurate solution, the impositions their techniques created generally didn&#8217;t impact the game.  (There are a few exceptions, notably the 2d+height map preventing truly 3d maps, but that was more of an engine issue than an issue of approach, so whatever.)</p>
<p>Horsepower aside, though, there are also issues of sloth or ignorance.  In fact, field of view algorithms provide an excellent example even compounded above the previous example.  Gee, can you guess what I&#8217;m gonna start going on about?</p>
<p>The fact of the matter is that on a complex 2d planar map, even implemented well, field of vision code is moderately expensive.  <a title="Hansjörg Malthaner" href="http://www.simugraph.com/en/aboutme.html">Hansjörg  Malthaner</a> brags, and rightfully so, that his <a title="FOV in H-World" href="http://h-world.simugraph.com/docs/fov.html">field of view implementation</a> can crank out a 59&#215;59 area in under 2ms on a 400mHz k6/2.  Whereas that may sound like hopelessly antiquated equipment by today&#8217;s standards, please remember that that&#8217;s talking about the field of view for just one creature; even dealing with a machine that can push 16x what that does, when you&#8217;re dealing with (say) 256 creatures &#8211; and that&#8217;s not terribly unlikely in a Roguelike at deeper levels &#8211; you&#8217;re still looking at around 32ms, just to figure out what monsters can see what.  That&#8217;s before you consider anything like, say, what the monsters&#8217; responses would be.  And, to put that in perspective, we&#8217;re talking about a full two frames at 60fps (the rate at which most console hardware runs) &#8211; that&#8217;s slow enough to see a stutter, even on modern hardware.</p>
<p>And &#8211; <em>I cannot emphasize this enough</em> &#8211; Hansjörg&#8217;s implementation is <u>good</u>.  This is not the upshot of some naïve bumbling.  This is what kind of speeds one should expect.</p>
<p>Now, granted, this is a fairly severe situation.  For one, 59&#215;59 implies sight radius 29, which is big by anyone&#8217;s standards, and since we&#8217;re talking about area which is exponential and a workload tied to a surface unit instead of an edge, and since that workload is also exponential, then having an area that big is pretty serious.  Also, games other than roguelikes don&#8217;t usually have low to middling hundreds of active, thinking opponents at a time (well, inasfar as roguelike creatures think, really, but that&#8217;s beside the point.)  But, as we all know, I&#8217;m working on the Nintendo DS, which is a 67mHz ARM9; when we&#8217;re there, we&#8217;re just not talking about cutting edge computational power, and therefore speed seriously matters to me.  Granted that the field of view in my game is much smaller, it&#8217;s still a pretty big issue.</p>
<p>This is where the kung-fu comes in.  See, there are other repurcussions to choosing a field of vision mechanism other than speed.  Granted speed is what we&#8217;re interested in here, but there are other things to be considered.  That is, for example, why I&#8217;m not implementing the <a title="It's honestly kinda slick, despite being kinda sick" href="http://jwelton.v-space.org/discuss/LOSSpaghetti.html">giant goto map generator</a> of Jesse Welton&#8217;s.  Instead, what I&#8217;m doing is going to give me view regions for specific tiles; that information will be enough to implement a much, much stronger perception algorithm, by gauging what fraction of a tile is visible.  That way I can have monsters with very long sight who won&#8217;t notice you sneaking up on them around corners, or monsters who only see six or seven tiles away, but who notice absolutely everything in range.  It should make far more satisfactory AI chase behavior, especially since I&#8217;m going to be tracking actual creature knowledge.</p>
<p>Anyway, that&#8217;s just what I&#8217;m working on in Southgate at the moment.  New topics soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://fullof.bs/on-shadowcasting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Container Selection Posters</title>
		<link>http://fullof.bs/container-selection-posters/</link>
		<comments>http://fullof.bs/container-selection-posters/#comments</comments>
		<pubDate>Sun, 12 Mar 2006 04:52:20 +0000</pubDate>
		<dc:creator>John Haugeland</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[My Stores]]></category>

		<guid isPermaLink="false">http://blog.sc.tri-bit.com/?p=33</guid>
		<description><![CDATA[So I put up a new store, for programmers who need reference charts, and I&#8217;ve even put one whole product into it (well, three, because I made three different sizes, but whatever.) There will be more soon, which is to say &#8220;when I get around to it.&#8221; But, for now I&#8217;ve put up one thing, [...]]]></description>
			<content:encoded><![CDATA[<p>So I put up <a title="Code Resource - one stop shopping for reference posters, tables and grids" href="http://www.cafepress.com/CodeResource">a new store</a>, for programmers who need reference charts, and I&#8217;ve even put one whole product into it (well, three, because I made three different sizes, but whatever.)</p>
<p><span id="more-70"></span></p>
<p>There will be more soon, which is to say &#8220;when I get around to it.&#8221;  But, for now I&#8217;ve put up one thing, and that thing you shall buy.  This is the fifth store joining my panoply of pointless shopping options, alongside my <a title="Stone Sudoku - quality puzzle books and merchandise" href="http://cafepress.com/StoneSudoku">sudoku store</a>, my <a title="Bad Bad Bush" href="http://cafepress.com/BadBadBush">anti-Bush store</a>, my <a title="Go Supplies" href="http://cafepress.com/GoSupplies">go store</a> and my <a title="Uncle Fatty's Bookstore" href="http://sc.tri-bit.com/Category:Uncle_Fatty%27s_Book_List">programmers&#8217; bookstore</a>.</p>
<p>Buy, my monkeys, buy!</p>
]]></content:encoded>
			<wfw:commentRss>http://fullof.bs/container-selection-posters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C Problems For The Poser Programmer In Your Life</title>
		<link>http://fullof.bs/c-problems-for-the-poser-programmer-in-your-life/</link>
		<comments>http://fullof.bs/c-problems-for-the-poser-programmer-in-your-life/#comments</comments>
		<pubDate>Fri, 10 Mar 2006 09:15:05 +0000</pubDate>
		<dc:creator>John Haugeland</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[problems]]></category>
		<category><![CDATA[puzzle]]></category>
		<category><![CDATA[Puzzles]]></category>

		<guid isPermaLink="false">http://blog.sc.tri-bit.com/?p=26</guid>
		<description><![CDATA[Someone happened to give me a link to a set of interesting C problems, which though not intensely difficult are enough to make a novice take pause. Some of them are even eye opening for novices. It&#8217;s an interesting read. As an aside I&#8217;ve been looking for documents like this for various languages. I&#8217;ve also [...]]]></description>
			<content:encoded><![CDATA[<p>Someone happened to give me a link to a set of <a title="Interesting C Questions" href="http://www.gowrikumar.com/c/cquestions.html">interesting C problems</a>, which though not intensely difficult are enough to make a novice take pause.  Some of them are even eye opening for novices.  It&#8217;s an interesting read.</p>
<p><span id="more-62"></span></p>
<p>As an aside I&#8217;ve been looking for documents like this for various languages.  I&#8217;ve also got the excellent <a title="The C++ FAQ Lite, hosted by Parashift" href="http://www.parashift.com/c++-faq-lite/">Parashift C++ FAQ Lite</a>, the <a title="C++ FAQ List" href="http://www.faqs.org/faqs/C++-faq/">FAQs.org list</a>, and lord knows <a title="Uncle Fatty's Bookstore" href="http://sc.tri-bit.com/Category:Uncle%20Fatty%27s%20Book%20List">more than enough books</a>; still, other good documents from which to derive tutorial material would be highly appreciated.</p>
]]></content:encoded>
			<wfw:commentRss>http://fullof.bs/c-problems-for-the-poser-programmer-in-your-life/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

