<?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>Kalimat al-Mutafalsif &#187; Programming</title>
	<atom:link href="http://thesnarky.com/category/interests/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://thesnarky.com</link>
	<description>The Words of the One Who Calls Himself a Philosopher</description>
	<lastBuildDate>Tue, 26 Oct 2010 22:57:56 +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>Ray Casting in Scheme</title>
		<link>http://thesnarky.com/2010/02/23/ray-casting-in-scheme/</link>
		<comments>http://thesnarky.com/2010/02/23/ray-casting-in-scheme/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 04:50:26 +0000</pubDate>
		<dc:creator>Snarky</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scheme]]></category>

		<guid isPermaLink="false">http://thesnarky.com/?p=424</guid>
		<description><![CDATA[My last post was about getting started picking up Scheme again for use in the 7 Day Roguelike contest. Of note I mentioned that I had decided on using Gambit as I could nicely tie Scheme and C libraries together, which I wanted so that I could use ncurses to do all my terminal control [...]]]></description>
			<content:encoded><![CDATA[<p>My<a href="http://thesnarky.com/2010/02/23/library-7drl-import-rnrs/"> last post</a> was about getting started picking up Scheme again for use in the <a href="http://groups.google.com/group/rec.games.roguelike.development/browse_thread/thread/96fae2f059d0b2b2/88349386000aaa8b?lnk=raot">7 Day Roguelike contest</a>. Of note I mentioned that I had decided on using <a href="http://dynamo.iro.umontreal.ca/~gambit/wiki/index.php/Main_Page">Gambit</a> as I could nicely tie Scheme and C libraries together, which I wanted so that I could use <a href="http://en.wikipedia.org/wiki/Ncurses">ncurses</a> to do all my terminal control (output and reading user input). </p>
<p>I got ncurses working, and managed to get a simple little walk around demo going. However I wanted something a bit deeper than just having the entire map visible from the start, so I poked back at some test code <a href="http://push.cx/">Harkins</a> wrote last year for Ruby (when I had aspirations of learning another language), and read up on <a href="http://http://roguebasin.roguelikedevelopment.org/index.php?title=Main_Page">Rogue Basin</a> for various examples. In the end I stole Harkin's map, and went with the pseudo code Elig created <a href="http://roguebasin.roguelikedevelopment.org/index.php?title=Eligloscode">here</a>.</p>
<p>Without further ado, the code busted apart into a few sections. (Full version can be found <a href="http://pastebin.com/WBDsz8Re">here</a>).</p>
<pre class="scheme">&nbsp;
<span style="color: #808080; font-style: italic;">;;Scheme ray casting/FOV demo</span>
<span style="color: #808080; font-style: italic;">;;Adapted from pseudo code found at</span>
<span style="color: #808080; font-style: italic;">;;http://roguebasin.roguelikedevelopment.org/index.php?title=Eligloscode</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Prep work for 7DLR 2010 (to brush back up on my Scheme)</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Global defines</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> char-x <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;;x coordinate for the fake character</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> char-y <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;;y coordinate for the fake character</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> VIEW-RADIUS <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;;View radius for FOV demo</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;List of tiles we don't want to walk through (Walls and water)</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> IMPASSABLE-TILES <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">list</span> #\# #\~<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #808080; font-style: italic;">;;List of tiles that will break the ray casting (walls)</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> OPAQUE-TILES <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">list</span> #\#<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> 
&nbsp;
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> test-env <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">list</span>
                    <span style="color: #ff0000;">&quot;###################&quot;</span>
                    <span style="color: #ff0000;">&quot;#...#.............#&quot;</span>
                    <span style="color: #ff0000;">&quot;#...#...#~~~~~....#&quot;</span>
                    <span style="color: #ff0000;">&quot;#.......#~~~~~....#&quot;</span>
                    <span style="color: #ff0000;">&quot;###################&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;</pre>
<p>First I set up some variables to work with.</p>
<pre class="scheme">&nbsp;
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span>
<span style="color: #808080; font-style: italic;">;;Functions to create the environment;;</span>
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function to create our working environment given an array of strings such as test-env</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> create-env
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">null?</span> env<span style="color: #66cc66;">&#41;</span>
            '<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cons</span> <span style="color: #66cc66;">&#40;</span>create-env-row <span style="color: #66cc66;">&#40;</span>string-&gt;list <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> env<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>create-env <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cdr</span> env<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function that helps create-env by creating a given row</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> create-env-row
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env-row<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">null?</span> env-row<span style="color: #66cc66;">&#41;</span>
            '<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cons</span> <span style="color: #66cc66;">&#40;</span>create-env-cell <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> env-row<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>create-env-row <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cdr</span> env-row<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function to create a given env cell, helps create-env-row</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> create-env-cell
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env-cell<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">list</span> env-cell #f<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;</pre>
<p>Next I define some functions to get a map (which is really a list of strings) to something we can work with (nested lists that act like a two dimensional array).</p>
<pre class="scheme">&nbsp;
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span>
<span style="color: #808080; font-style: italic;">;;Functions to display the environment;;</span>
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function to write the env</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> write-env
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>write-env-help env <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function that does the brunt of the env write</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> write-env-help
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env x y<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">null?</span> env<span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">newline</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">begin</span>
                <span style="color: #66cc66;">&#40;</span>write-env-row <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> env<span style="color: #66cc66;">&#41;</span> x y<span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#40;</span>write-env-help <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cdr</span> env<span style="color: #66cc66;">&#41;</span> x <span style="color: #66cc66;">&#40;</span>+ y <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function that writes a given row of the env</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> write-env-row
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env-row x y<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">null?</span> env-row<span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">newline</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">begin</span>
                <span style="color: #66cc66;">&#40;</span>write-env-cell <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> env-row<span style="color: #66cc66;">&#41;</span> x y<span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#40;</span>write-env-row <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cdr</span> env-row<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>+ x <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function that writes out a given cell of the env</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> write-env-cell
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env-cell x y<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>char <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> env-cell<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;;The symbol we'll possibly display</span>
              <span style="color: #808080; font-style: italic;">;;The boolean bit of the env cell that holds if its visible or not</span>
              <span style="color: #66cc66;">&#40;</span>visible <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cadr</span> env-cell<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> visible <span style="color: #808080; font-style: italic;">;;If this cell was marked to be seen</span>
                <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">and</span> <span style="color: #66cc66;">&#40;</span>= x char-x<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>= y char-y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;;Check if its where the character is</span>
                    <span style="color: #66cc66;">&#40;</span>print <span style="color: #ff0000;">&quot;@&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;;If so, lets show an @ symbol</span>
                    <span style="color: #66cc66;">&#40;</span>print char<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;;Else show whatever character should be displayed</span>
                <span style="color: #66cc66;">&#40;</span>print <span style="color: #ff0000;">&quot; &quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;;If this cell wasn't marked to be shown, just put a space</span>
            <span style="color: #66cc66;">&#40;</span>print <span style="color: #ff0000;">&quot; &quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;;Put a space after it for pretty printing</span>
&nbsp;</pre>
<p>Naturally you need some way to nicely see what's going on in your environment. That's what these functions do.</p>
<pre class="scheme">&nbsp;
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span>
<span style="color: #808080; font-style: italic;">;;Functions for the FOV demo;;</span>
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function to update the FOV as a whole</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> update-fov
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env char-x char-y<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>update-fov-help env char-x char-y <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function that does the actual work of updating the FOV</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> update-fov-help
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env char-x char-y x y<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">not</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">null?</span> env<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">begin</span>
                <span style="color: #66cc66;">&#40;</span>update-fov-row <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> env<span style="color: #66cc66;">&#41;</span> char-x char-y x y<span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#40;</span>update-fov-help <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cdr</span> env<span style="color: #66cc66;">&#41;</span> char-x char-y x <span style="color: #66cc66;">&#40;</span>+ y <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function that updates the FOV for a given row</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> update-fov-row
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env-row char-x char-y x y<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">not</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">null?</span> env-row<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">begin</span>
                <span style="color: #66cc66;">&#40;</span>update-fov-cell <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> env-row<span style="color: #66cc66;">&#41;</span> char-x char-y x y<span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#40;</span>update-fov-row <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cdr</span> env-row<span style="color: #66cc66;">&#41;</span> char-x char-y <span style="color: #66cc66;">&#40;</span>+ x <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function that does the real work to update a given cell's FOV</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> update-fov-cell
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env-cell char-x char-y x y<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>set-cell-visible env-cell #f<span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;;Set visible to false</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span>* <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>dx <span style="color: #66cc66;">&#40;</span>- x char-x<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
               <span style="color: #66cc66;">&#40;</span>dy <span style="color: #66cc66;">&#40;</span>- y char-y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
               <span style="color: #808080; font-style: italic;">;;Get the distance between the character and the cell</span>
               <span style="color: #66cc66;">&#40;</span>distance <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">sqrt</span> <span style="color: #66cc66;">&#40;</span>+ <span style="color: #66cc66;">&#40;</span>* dx dx<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>* dy dy<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>&lt; distance VIEW-RADIUS<span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;;If we're within out viewing radius</span>
                <span style="color: #66cc66;">&#40;</span>set-cell-visible env-cell #t<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;;set the cell to be shown</span>
&nbsp;</pre>
<p>Finally we get to the good stuff. This code is for the Field of View demo, which just shows everything within the sight radius. What it does, basically, is loops through every cell on the map, sets it to invisible (aka sets the cdr of the env-cell to be #f), and then checks to see how far from the player it is. If its within our view-radius, it then flips the visibility to true. Slow for big maps, but simple to implement.</p>
<pre class="scheme">&nbsp;
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span>
<span style="color: #808080; font-style: italic;">;;Function for the Ray casting demo;;</span>
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function to clear the entire env</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> clear-cells
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">not</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">null?</span> env<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">begin</span>
                <span style="color: #66cc66;">&#40;</span>clear-cells-row <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> env<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#40;</span>clear-cells <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cdr</span> env<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function that clears a row of the env</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> clear-cells-row
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env-row<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">not</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">null?</span> env-row<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">begin</span>
                <span style="color: #66cc66;">&#40;</span>clear-cells-cell <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> env-row<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#40;</span>clear-cells-row <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cdr</span> env-row<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function to clear a cell in the env</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> clear-cells-cell
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env-cell<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>set-cell-visible env-cell #f<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function to do the ray-cast</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> cast-rays
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env char-x char-y<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>clear-cells env<span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;;Clear everything first</span>
        <span style="color: #66cc66;">&#40;</span>cast-rays-help env char-x char-y <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function to do the real work of casting some rays</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> cast-rays-help
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env char-x char-y i<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>&lt;= i <span style="color: #cc66cc;">360</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>x <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cos</span> <span style="color: #66cc66;">&#40;</span>* i <span style="color: #cc66cc;">0.01745</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                  <span style="color: #66cc66;">&#40;</span>y <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">sin</span> <span style="color: #66cc66;">&#40;</span>* i <span style="color: #cc66cc;">0.01745</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                  <span style="color: #66cc66;">&#40;</span>trace-ray env char-x char-y x y <span style="color: #66cc66;">&#40;</span>+ char-x .<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>+ char-y .<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
                  <span style="color: #66cc66;">&#40;</span>cast-rays-help env char-x char-y <span style="color: #66cc66;">&#40;</span>+ i <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function to trace the specific ray to its end</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> trace-ray
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env char-x char-y x y dx dy i<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">not</span> <span style="color: #66cc66;">&#40;</span>&gt; i VIEW-RADIUS<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span>* <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>cell-x <span style="color: #66cc66;">&#40;</span>round dx<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                   <span style="color: #66cc66;">&#40;</span>cell-y <span style="color: #66cc66;">&#40;</span>round dy<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                   <span style="color: #66cc66;">&#40;</span>cell <span style="color: #66cc66;">&#40;</span>get-cell env cell-x cell-y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> cell
                    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">begin</span>
                        <span style="color: #66cc66;">&#40;</span>set-cell-visible cell #t<span style="color: #66cc66;">&#41;</span>
                        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>cell-opaque? cell<span style="color: #66cc66;">&#41;</span>
                            <span style="color: #66cc66;">&#40;</span>trace-ray env char-x char-y x y <span style="color: #66cc66;">&#40;</span>+ dx x<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>+ dy y<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>+ i <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;</pre>
<p>The first three functions simply clear all the cells on the map. Unlike FOV our work functions aren't visiting every cell (we hope) and so we have to go through ahead of time and clear them out.</p>
<p>The rest of the functions do the ray casting. Starting at the character's position, it draws a line (trace-ray) out in a given direction. If it gets either past the view radius, or to a cell considered opaque, it doesn't recur. Otherwise it calls itself and continues stepping out. Trace-ray is called once per every 16 degrees around the circle. Its not entirely accurate, but its a lot faster than using 1 as the increment and drawing 360 rays. </p>
<pre class="scheme">&nbsp;
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;</span>
<span style="color: #808080; font-style: italic;">;;Random helper functions;;</span>
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;;;;;;;;;;;;;;;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function to get a given cell</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> get-cell
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env x y<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>get-cell-help env x y <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function does most of the real work to get a given cell</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> get-cell-help
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env new-x new-y y<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">not</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">null?</span> env<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>= y new-y<span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#40;</span>get-cell-x <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> env<span style="color: #66cc66;">&#41;</span> new-x new-y <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#40;</span>get-cell-help <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cdr</span> env<span style="color: #66cc66;">&#41;</span> new-x new-y <span style="color: #66cc66;">&#40;</span>+ y <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
            #f<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Final helper to get a given cell</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> get-cell-x
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env-row new-x new-y x<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">not</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">null?</span> env-row<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>= x new-x<span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> env-row<span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#40;</span>get-cell-x <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cdr</span> env-row<span style="color: #66cc66;">&#41;</span> new-x new-y <span style="color: #66cc66;">&#40;</span>+ x <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
            #f<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function to tell if a cell is passable</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> cell-passable?
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>cell<span style="color: #66cc66;">&#41;</span>
         <span style="color: #808080; font-style: italic;">;;Check to see if symbol is in our list of impassable tiles</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">not</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">member</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> cell<span style="color: #66cc66;">&#41;</span> IMPASSABLE-TILES<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> 
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function to tell if a cell is opaque</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> cell-opaque?
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>cell<span style="color: #66cc66;">&#41;</span>
        <span style="color: #808080; font-style: italic;">;;Check to see if symbol is in our list of opaque tiles</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">not</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">member</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">car</span> cell<span style="color: #66cc66;">&#41;</span> OPAQUE-TILES<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> 
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function to 'move' our 'character' to another cell</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> move-to
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env x y<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>cell-passable? <span style="color: #66cc66;">&#40;</span>get-cell env x y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;;Check to make sure they can move there</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">begin</span>
                <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">set!</span> char-x x<span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;;'Move' them by changing our global vars</span>
                <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">set!</span> char-y y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Function to set a given cell's visibility to the given boolean</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> set-cell-visible
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>cell bool<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>set-<span style="color: #b1b100;">cdr</span>! cell <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">list</span> bool<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;</pre>
<p>These functions simply help the above code look prettier. The first make the environment which is really just a list (in true Scheme form) behave more like a two dimensional array. Cell-passable? and opaque? check to see if a cell can be traveled into or seen through. Move-to moves the character, and set-cell-visible helps quickly toggle a cell's visibility.</p>
<pre class="scheme">&nbsp;
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;</span>
<span style="color: #808080; font-style: italic;">;;Test code;;</span>
<span style="color: #808080; font-style: italic;">;;;;;;;;;;;;;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Setup the environment</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> our-env <span style="color: #66cc66;">&#40;</span>create-env test-env<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Run the fov-demo</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> fov-demo
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>print <span style="color: #ff0000;">&quot;FOV demo, use h, j, k, and l to move, q to quit<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>update-fov our-env char-x char-y<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>write-env our-env<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> read-loop <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>x <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">read-char</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">not</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">or</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">char=?</span> x #\q<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">char=?</span> x #\<span style="color: #b1b100;">newline</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">begin</span>
                    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">case</span> x
                        <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>#\<span style="color: #b1b100;">l</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>new-x <span style="color: #66cc66;">&#40;</span>+ char-x <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                                     <span style="color: #66cc66;">&#40;</span>new-y char-y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                                    <span style="color: #66cc66;">&#40;</span>move-to our-env new-x new-y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
                        <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>#\k<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>new-x char-x<span style="color: #66cc66;">&#41;</span>
                                     <span style="color: #66cc66;">&#40;</span>new-y <span style="color: #66cc66;">&#40;</span>- char-y <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                                    <span style="color: #66cc66;">&#40;</span>move-to our-env new-x new-y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
                        <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>#\j<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>new-x char-x<span style="color: #66cc66;">&#41;</span>
                                     <span style="color: #66cc66;">&#40;</span>new-y <span style="color: #66cc66;">&#40;</span>+ char-y <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                                    <span style="color: #66cc66;">&#40;</span>move-to our-env new-x new-y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
                        <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>#\h<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>new-x <span style="color: #66cc66;">&#40;</span>- char-x <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                                     <span style="color: #66cc66;">&#40;</span>new-y char-y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                                    <span style="color: #66cc66;">&#40;</span>move-to our-env new-x new-y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>
                    <span style="color: #66cc66;">&#40;</span>update-fov our-env char-x char-y<span style="color: #66cc66;">&#41;</span>
                    <span style="color: #66cc66;">&#40;</span>write-env our-env<span style="color: #66cc66;">&#41;</span>
                    <span style="color: #66cc66;">&#40;</span>read-loop <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">read-char</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">case</span> x
                    <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>#\q<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>print <span style="color: #ff0000;">&quot;--End of FOV Demo--<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
                    <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>#\<span style="color: #b1b100;">newline</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>read-loop <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">read-char</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Run the ray-casting-demo</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> ray-casting-demo
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>env<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>print <span style="color: #ff0000;">&quot;Ray casting demo, use h, j, k, and l to move, q to quit<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>cast-rays our-env char-x char-y<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>write-env our-env<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> read-loop <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>x <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">read-char</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">not</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">or</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">char=?</span> x #\q<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">char=?</span> x #\<span style="color: #b1b100;">newline</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">begin</span>
                    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">case</span> x
                        <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>#\<span style="color: #b1b100;">l</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>new-x <span style="color: #66cc66;">&#40;</span>+ char-x <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                                     <span style="color: #66cc66;">&#40;</span>new-y char-y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                                    <span style="color: #66cc66;">&#40;</span>move-to our-env new-x new-y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
                        <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>#\k<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>new-x char-x<span style="color: #66cc66;">&#41;</span>
                                     <span style="color: #66cc66;">&#40;</span>new-y <span style="color: #66cc66;">&#40;</span>- char-y <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                                    <span style="color: #66cc66;">&#40;</span>move-to our-env new-x new-y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
                        <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>#\j<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>new-x char-x<span style="color: #66cc66;">&#41;</span>
                                     <span style="color: #66cc66;">&#40;</span>new-y <span style="color: #66cc66;">&#40;</span>+ char-y <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                                    <span style="color: #66cc66;">&#40;</span>move-to our-env new-x new-y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
                        <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>#\h<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>new-x <span style="color: #66cc66;">&#40;</span>- char-x <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                                     <span style="color: #66cc66;">&#40;</span>new-y char-y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                                    <span style="color: #66cc66;">&#40;</span>move-to our-env new-x new-y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>
                    <span style="color: #66cc66;">&#40;</span>cast-rays our-env char-x char-y<span style="color: #66cc66;">&#41;</span>
                    <span style="color: #66cc66;">&#40;</span>write-env our-env<span style="color: #66cc66;">&#41;</span>
                    <span style="color: #66cc66;">&#40;</span>read-loop <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">read-char</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">case</span> x <span style="color: #808080; font-style: italic;">;;Enter or q was pressed</span>
                    <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>#\q<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>print <span style="color: #ff0000;">&quot;--End of Ray casting demo--<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #808080; font-style: italic;">;;If q, lets quit</span>
                    <span style="color: #808080; font-style: italic;">;;If enter just read the next char, it happens</span>
                    <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>#\<span style="color: #b1b100;">newline</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>read-loop <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">read-char</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> 
&nbsp;
<span style="color: #808080; font-style: italic;">;;Run our demos</span>
<span style="color: #66cc66;">&#40;</span>fov-demo our-env<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>ray-casting-demo our-env<span style="color: #66cc66;">&#41;</span>
&nbsp;</pre>
<p>And finally the test code. Both of these loops behave the same, they use typical roguelike controls to move up (k), down (j), left (h), and right (l), as well as (q) to quit. You'll notice I also had to catch enter or read-char would spit out the map twice. At the end we call both of these functions so we can show off both types, back to back.</p>
<p>So there you have it, simple ray casting done in Scheme. I'll note that its not exceptionally fast, in fact for my test map the FOV demo was far quicker, but by degrading the accuracy and reducing the number of rays drawn the speed gets back up to something decent. I suspect that may also have to do with drawing it all out to the terminal, and will see what happens when I plug this into my ncurses code at a later point.</p>
<p>Hope that's commented well enough in the code. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://thesnarky.com/2010/02/23/ray-casting-in-scheme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>(library 7DRL (import (rnrs))</title>
		<link>http://thesnarky.com/2010/02/23/library-7drl-import-rnrs/</link>
		<comments>http://thesnarky.com/2010/02/23/library-7drl-import-rnrs/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 23:40:09 +0000</pubDate>
		<dc:creator>Snarky</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scheme]]></category>

		<guid isPermaLink="false">http://thesnarky.com/?p=413</guid>
		<description><![CDATA[7DRL Some friends were discussing the upcoming 7 Day Roguelike contest and I thought it'd be a fun thing to do after completing a browser based game in a month contest just a week back. However, I wanted to use something besides something besides the PHP I've been using for so very long, and somehow [...]]]></description>
			<content:encoded><![CDATA[<p><strong>7DRL</strong></p>
<p>Some friends were discussing the upcoming <a href="http://groups.google.com/group/rec.games.roguelike.development/browse_thread/thread/96fae2f059d0b2b2/88349386000aaa8b?lnk=raot">7 Day Roguelike contest </a> and I thought it'd be a fun thing to do after completing a <a href="http://community.bbgamezone.net/index.php/topic,2612.0.html">browser based game in a month contest</a> just a week back. However, I wanted to use something besides something besides the PHP I've been using for so very long, and somehow in the same IRC channel <a href="http://www.r6rs.org/">Scheme</a> came up.</p>
<p>Scheme is a LISP language that I learned back in college and very quickly grew a nice love/hate relationship. I love seeing the beauty of recursion expressed so easily, and I just hate to see so many parenthesis all over the place. Seriously they make your eyes bleed. But the idea hit me that it'd be fun to try to do the roguelike in Scheme, and I decided to enter. I most likely won't finish, and I'm not too happy with the idea I have, but it'll be fun nonetheless.</p>
<p><strong>Flavors</strong></p>
<p>To that end, I've been playing in Scheme for the past week to familiarize myself with a language I haven't touched in a few years and which has had some nice advances since that time. First job was getting it installed on Ubuntu. I'd recommend playing with various flavors and seeing what you like best. I tried <a href="http://www.gnu.org/software/mit-scheme/">Mit-Scheme</a>, <a href="http://scheme.com/">Chez Scheme</a>, <a href="http://www.plt-scheme.org/">PLT Scheme</a> (Dr Scheme), <a href="http://tinyscheme.sourceforge.net/home.html">Tiny Scheme</a>, and <a href="http://dynamo.iro.umontreal.ca/~gambit/wiki/index.php/Main_Page">Gambit</a>. These can all be installed under Linux (fairly) easily, and all have upsides and downsides. </p>
<ul>
<li>MIT Scheme - I had used this a tad during school, but sadly they're not supporting R6RS, and don't have a full implementation of R5RS, so its essentially useless.</li>
<li>Chez Scheme - What my school used primarily. Has a copy of the <a href="http://www.amazon.com/Scheme-Programming-Language-4th/dp/026251298X/ref=sr_1_1?ie=UTF8&s=books&qid=1266964867&sr=8-1">Scheme Programming Language Version 4</a> free <a href="http://scheme.com/tspl4/">on their site</a> which is a big plus. They support all three major OS's and include an RPM/instructions for Debian installation.</li>
<li>PLT Scheme - The other product we used at school, it comes as a Scheme IDE with the ability to select from a variety of language subsets. The Ubuntu 9.04 package isn't up to date, but the package available on their site includes R6RS, so grab their install script and forgo synaptic. Big plus of being a fully featured IDE.</li>
<li>Tinyscheme - From the command line I actually liked this flavor the best. Sadly its a subset of the R5RS standard so it won't do everything you need, but for small proof-of-concept or test code, its nice and fast. I know it'd defeat the purpose, but I wish there was an R6RS version.</li>
<li>Gambit Scheme - This is a flavor I only came across this past week, had no prior experience with it. I love it. Again the version in the 9.04 Ubuntu repos is a bit old, so grab the newest version (4.6 as of now) <a href="http://www.iro.umontreal.ca/~gambit/download/gambit/v4.6/source/gambc-v4_6_0.tgz">here</a>. If you just want to use Gambit as an interpreter/REPL you're good to go. If you want to use it to spit out C code as well, you may need to make sure your gambit.h file is in the right location.</li>
</ul>
<p><strong>Gambit</strong></p>
<p>Yes, I said spit out C, as Gambit-C compiles your Scheme nicely into C files that gcc will then happily compile for you along with real C to use both languages. This is going to play greatly into my 7DRL as I wanted to use the NCurses library to handle my screen output and to I can easily include that now. An example of Hello World in Gambit Scheme with NCurses:</p>
<pre class="scheme">&nbsp;
<span style="color: #808080; font-style: italic;">;;Hello World example for Gambit/NCurses</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Include our headers</span>
<span style="color: #66cc66;">&#40;</span>c-declare <span style="color: #ff0000;">&quot;#include &lt;ncurses.h&gt;&quot;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Define the function</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> hello-world
    <span style="color: #808080; font-style: italic;">;;C lambda performs c commands, this is a basic ncurses</span>
    <span style="color: #808080; font-style: italic;">;;example that inits the screen, prints our string, waits</span>
    <span style="color: #808080; font-style: italic;">;;for input so it stays on the screen, and then kills the window</span>
    <span style="color: #66cc66;">&#40;</span>c-<span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> int <span style="color: #ff0000;">&quot;initscr(); printw(<span style="color: #000099; font-weight: bold;">\&quot;</span>Hello World<span style="color: #000099; font-weight: bold;">\&quot;</span>); refresh(); getch(); endwin();&quot;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;Gotta remember to call it!</span>
<span style="color: #66cc66;">&#40;</span>hello-world<span style="color: #66cc66;">&#41;</span>
&nbsp;</pre>
<p>Now link, compile, and run it:</p>
<pre>
snarky@Reaper$ gsc -link ncurses.scm
snarky@Reaper$ gcc ncurses_.c ncurses.c -lgambc -lncurses -o ncurses
snarky@Reaper$ ./ncurses
Hello World
</pre>
<p>(Of course, the above output is slightly tweaked as I'm opting not to take a screenshot of a terminal empty save for one string)</p>
<p>It should be noted that once you start including C in your scheme you can no longer use the Gambit Scheme Interpreter to test your code, so I'd recommend breaking those bits out into other files if possible. </p>
<p>There are some other great additions within the Gambit system, such as the ability to have optional arguments in your functions, keyed variables passed to functions, and some random extensions like vector-copy, as well as, obviously, in-lining C in your Scheme. I highly recommend checking our their <a href="http://www.iro.umontreal.ca/~gambit/doc/gambit-c.html">manual</a> if you're at all interested. </p>
<p><strong>Gotchas</strong></p>
<p>I did get bit by a few things in Gambit, that I feel I should clarify. Even after reading through the manual, I missed that the compiler is spitting out linked files, not actual executables. To make sure you're getting an executable out of it make sure you do something akin to:</p>
<pre>
snarky@Reaper$ gsc -link file.scm
snarky@Reaper$ gcc file_.c file.c -lgambc
</pre>
<p>I very quickly just made a make file to handle it to simply forget about what steps go into it.</p>
<p>The big thing that bit me, however, was when I got out of the nice usual functions and into some higher syntax, specifically define-syntax. Gambit has a bunch of functionality turned off by default and requires that you turn it all on to use it. However I didn't feel like the documentation beat that into my head enough, so here's what you have to do:</p>
<p>For the interpreter:</p>
<pre>
snarky@Reaper$ gsi -:s
</pre>
<p>And for the compiler:</p>
<pre>
snarky@Reaper$ gsc -:s -link file.scm

OR

snarky@Reaper$ gsc -link -e '(load "/usr/local/Gambit-C/lib/syntax-case.scm")' file.scm
</pre>
<p>The top example turns a whole bunch of syntactic sugar on, while the bottom I believe just turns on some of the syntax. I could be wrong there.</p>
<p>I'm quite looking forward to playing with Gambit more and getting to know Scheme as I used to. Hopefully someone else can find a new sadistic language out of this post.</p>
]]></content:encoded>
			<wfw:commentRss>http://thesnarky.com/2010/02/23/library-7drl-import-rnrs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Thieves Tavern Beta</title>
		<link>http://thesnarky.com/2008/10/23/thieves-tavern-beta/</link>
		<comments>http://thesnarky.com/2008/10/23/thieves-tavern-beta/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 02:02:03 +0000</pubDate>
		<dc:creator>Snarky</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Three Planets Software]]></category>

		<guid isPermaLink="false">http://thesnarky.com/?p=237</guid>
		<description><![CDATA[Its been a few months since I announced I was going to try to write a <a href="http://thesnarky.com/2008/06/28/thieves-tavern-where-all-the-cool-kids-play/">PHP based Mafia game</a> and in that time I've learned a decent amount. 

First off, if you want a project done, you can't be getting distracted. Since I've started <a href="http://thievestavern.com">Thieves Tavern</a> I've also fallen in love with motorcycles and started gun smithing. Both of those have stolen major programming time away from this project. Its only through the weather being downright cold lately, and parts for the gun being on back order that I've had the time to get gung ho on this project again. 

Secondly, when dealing with databases, its really easy to tailor the database so that the game works. In fact, that's the whole point of editing the database: To test this bit, or that bit... but not the overall product. Earlier this week I'd reached a point where I thought I could push my code live, and invite some friends to beta test it. I figured, at the time that clearing out my database would make stuff work better, get rid of all the random edge cases I'd built up along the way. Well, after clearing out the database, nothing worked. I couldn't start games, I couldn't chat, nada. This is when I learned that it doesn't get easier after removing test data, only harder. It took another two days of testing, clearing, testing some more, as well as cleaning up my code, before I got it back to the 'working' beta state. Thankfully, now I know its working as intended (minus the obvious beta bugs, of course). 

So now its off to beta test Thieves Tavern. I'm kind of excited to be playing this, I had loads of fun while playing myself in local tests, and I can  imagine it being even better taking out friends online. If you'd like to help test, get ahold of me (in real life, I'll ask for signups for a public beta later on) and I'll send you an invite.

(And in the 10 minutes it took to write this I already have a laundry list of fixes/stuff I just plumb forgot)]]></description>
			<content:encoded><![CDATA[<p>Its been a few months since I announced I was going to try to write a <a href="http://thesnarky.com/2008/06/28/thieves-tavern-where-all-the-cool-kids-play/">PHP based Mafia game</a> and in that time I've learned a decent amount. </p>
<p>First off, if you want a project done, you can't be getting distracted. Since I've started <a href="http://thievestavern.com">Thieves Tavern</a> I've also fallen in love with motorcycles and started gun smithing. Both of those have stolen major programming time away from this project. Its only through the weather being downright cold lately, and parts for the gun being on back order that I've had the time to get gung ho on this project again. </p>
<p>Secondly, when dealing with databases, its really easy to tailor the database so that the game works. In fact, that's the whole point of editing the database: To test this bit, or that bit... but not the overall product. Earlier this week I'd reached a point where I thought I could push my code live, and invite some friends to beta test it. I figured, at the time that clearing out my database would make stuff work better, get rid of all the random edge cases I'd built up along the way. Well, after clearing out the database, nothing worked. I couldn't start games, I couldn't chat, nada. This is when I learned that it doesn't get easier after removing test data, only harder. It took another two days of testing, clearing, testing some more, as well as cleaning up my code, before I got it back to the 'working' beta state. Thankfully, now I know its working as intended (minus the obvious beta bugs, of course). </p>
<p>So now its off to beta test Thieves Tavern. I'm kind of excited to be playing this, I had loads of fun while playing myself in local tests, and I can  imagine it being even better taking out friends online. If you'd like to help test, get ahold of me (in real life, I'll ask for signups for a public beta later on) and I'll send you an invite.</p>
<p>(And in the 10 minutes it took to write this I already have a laundry list of fixes/stuff I just plumb forgot)</p>
]]></content:encoded>
			<wfw:commentRss>http://thesnarky.com/2008/10/23/thieves-tavern-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New LJ Crossposting script</title>
		<link>http://thesnarky.com/2008/09/26/new-lj-crossposting-script/</link>
		<comments>http://thesnarky.com/2008/09/26/new-lj-crossposting-script/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 19:46:19 +0000</pubDate>
		<dc:creator>Snarky</dc:creator>
				<category><![CDATA[Annoyances]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://thesnarky.com/?p=228</guid>
		<description><![CDATA[I nabbed a plugin to fix my borked LJ Crossposting script... mine was not behaving nicely. So this is mainly a test to see if/how it works. Test. Test 2... Big Test Now we're testing an edit, and adding in a link to the plugin's home.]]></description>
			<content:encoded><![CDATA[<p>I nabbed a plugin to fix my borked LJ Crossposting script... mine was not behaving nicely. So this is mainly a test to see if/how it works.</p>
<p>Test.</p>
<p>Test 2...</p>
<p><strong>Big Test</strong></p>
<p>Now we're testing an edit, and adding in a link to the <a href="http://lj-xp.com/">plugin's home</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://thesnarky.com/2008/09/26/new-lj-crossposting-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Head First&#8230;. Mechanics and Gun smithing?</title>
		<link>http://thesnarky.com/2008/09/10/head-first-mechanics-and-gun-smithing/</link>
		<comments>http://thesnarky.com/2008/09/10/head-first-mechanics-and-gun-smithing/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 03:43:22 +0000</pubDate>
		<dc:creator>Snarky</dc:creator>
				<category><![CDATA[Gun smithing]]></category>
		<category><![CDATA[Interests]]></category>
		<category><![CDATA[Motorcycles]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Three Planets Software]]></category>

		<guid isPermaLink="false">http://thesnarky.com/?p=208</guid>
		<description><![CDATA[Its been a long time since I've written anything, I've kept busy at work and at play. On the work side I'm going to look into what it will take for me to actually run Three Planets as a real company, mainly for tax purposes and my own sanity. On the play side, there's been a LOT more developments.

I just picked up a motorcycle about two months back since one thing I love to do while stuck on some code is drive. Naturally I figured that riding would be an even better escape. It turns out it is, but I'm concentrating too much on the riding to be able to head-code. The upside is, this is probably the most fun activity I've ever found. So, meet Kari:

<img src="http://thesnarky.com/html/pictures/motorcycles/Kari/SANY1662_tiny.JPG" alt="" />

I realized on Sunday that I've put 1000 miles on her in the month and the week since I got my license, not too shabby considering I probably spent on the low side of $100 of gas for that entire time! Since she's an older bike, I'm doing as much of the maintenance as I can, so that I'll only need a mechanic for major operations. More on that later.

I also (very, very recently) decided to get into Gun smithing. To that end, I'm going to be making an AR-15 over the next month(s), and keeping track of my progress here. 

So, what do the two new activities have in common? Both of them stem at least partially from an interest to be reliant upon only myself for work. This comes from the programming I do, where I have chided others for not thinking outside of the box, and really doing anything they want with the code. It finally dawned on me that that goes in all walks of life, and you can even approach it in the same way.

Lets take the Gun smithing, for example. I'm approaching this from a design perspective first. I laid out what I want to use the gun for, then set my constraints (money), and planned out the parts. This is exactly the same method I take for programming: First I'll plan out how I want it to look/act, figure out what corners I have to cut to keep it within my memory/CPU/bandwidth bounds, then start with the functions. 

In this case I decided I want something for (eventually) match target shooting, for medium ranges (100-600 yards). My constraints were that I wanted to build it all myself, short of fabricating the parts, and that i didn't want to spend more than $700 on the total cost. So far I've decided on the following:
<ul>
	<li>DPMS Lower Receiver, stripped (already purchased)</li>
	<li>DPMS Lower Receiver parts (already purchased)</li>
	<li>Advanced Technology 6-position collapsible stock</li>
	<li>Ergonomic pistol grip</li>
	<li>20" chrome lined barrel (not sure of manufacturer yet)</li>
	<li>Flat top upper receiver with rails</li>
	<li>Generic bolt/bolt carrier, stripped</li>
</ul>

It should be a really fun project, I look forward to learning a new machine and how it all works. This will also mean that from now on my firearms will be like my computers, completely unique, and I'll have an intimate working knowledge of each and every part.

So why now? Why am I trying to learn all this new stuff once I get out of college, and not while I was in it? The answer here stems from some conversations I've had about why I enjoy firearms, and thoughts I've had after them. The short answer is: "I'd rather learn how to shoot now, when I don't need to, than later when I need to, but don't know how." I don't think carrying rifles in public is necessary, though I am a vocal defender of the 2nd amendment, however I do think it is very short-sighted to assume you'll never need to use a firearm, and therefor write them off. Didn't you learn how to change a tire, even though you may never need to, perform CPR in gym class, or how to balance an equation in science (or for the scientist, write in plain English, or not blow up the world)? Sure, all of those will be needed a whole lot more than shooting, but other than CPR shooting might be the most important to know if any of those situations came up.

Now, I considered myself set once I learned safety, and how to aim properly. But lately I've been thinking that its really short-sighted of me to assume the rifle will work perfectly all the time. More importantly, I don't know when its not working at 100%, because I don't understand it all. Just like the sorority girls whose computers I'd clean up at the end of the school year, I might not realize all the junk that is building up inside my gun. So, I've decided that I need to know at least basic gun smithing, just in case. Knowing this will keep me, and those around me when I shoot, a whole lot safer in the long run, plus save me money!

The motorcycle is the same story. I have no idea what's going on, and if you read up on an inline-4 engine, there's really no excuse for that. So again, I'm teaching myself basic mechanics in order to keep my machines running as smoothly and safely as possible.

And if you think about it, these skills of checking the usual fail points, oiling the squeaky parts, and throwing your own custom parts in, are the same across many fields, not just mechanics, gun smithing, and programming. So get out there, and get yourself head first into a new field today!]]></description>
			<content:encoded><![CDATA[<p>Its been a long time since I've written anything, I've kept busy at work and at play. On the work side I'm going to look into what it will take for me to actually run Three Planets as a real company, mainly for tax purposes and my own sanity. On the play side, there's been a LOT more developments.</p>
<p>I just picked up a motorcycle about two months back since one thing I love to do while stuck on some code is drive. Naturally I figured that riding would be an even better escape. It turns out it is, but I'm concentrating too much on the riding to be able to head-code. The upside is, this is probably the most fun activity I've ever found. So, meet Kari:</p>
<p><img src="http://thesnarky.com/html/pictures/motorcycles/Kari/SANY1662_tiny.JPG" alt="" /></p>
<p>I realized on Sunday that I've put 1000 miles on her in the month and the week since I got my license, not too shabby considering I probably spent on the low side of $100 of gas for that entire time! Since she's an older bike, I'm doing as much of the maintenance as I can, so that I'll only need a mechanic for major operations. More on that later.</p>
<p>I also (very, very recently) decided to get into Gun smithing. To that end, I'm going to be making an AR-15 over the next month(s), and keeping track of my progress here. </p>
<p>So, what do the two new activities have in common? Both of them stem at least partially from an interest to be reliant upon only myself for work. This comes from the programming I do, where I have chided others for not thinking outside of the box, and really doing anything they want with the code. It finally dawned on me that that goes in all walks of life, and you can even approach it in the same way.</p>
<p>Lets take the Gun smithing, for example. I'm approaching this from a design perspective first. I laid out what I want to use the gun for, then set my constraints (money), and planned out the parts. This is exactly the same method I take for programming: First I'll plan out how I want it to look/act, figure out what corners I have to cut to keep it within my memory/CPU/bandwidth bounds, then start with the functions. </p>
<p>In this case I decided I want something for (eventually) match target shooting, for medium ranges (100-600 yards). My constraints were that I wanted to build it all myself, short of fabricating the parts, and that i didn't want to spend more than $700 on the total cost. So far I've decided on the following:</p>
<ul>
<li>DPMS Lower Receiver, stripped (already purchased)</li>
<li>DPMS Lower Receiver parts (already purchased)</li>
<li>Advanced Technology 6-position collapsible stock</li>
<li>Ergonomic pistol grip</li>
<li>20" chrome lined barrel (not sure of manufacturer yet)</li>
<li>Flat top upper receiver with rails</li>
<li>Generic bolt/bolt carrier, stripped</li>
</ul>
<p>It should be a really fun project, I look forward to learning a new machine and how it all works. This will also mean that from now on my firearms will be like my computers, completely unique, and I'll have an intimate working knowledge of each and every part.</p>
<p>So why now? Why am I trying to learn all this new stuff once I get out of college, and not while I was in it? The answer here stems from some conversations I've had about why I enjoy firearms, and thoughts I've had after them. The short answer is: "I'd rather learn how to shoot now, when I don't need to, than later when I need to, but don't know how." I don't think carrying rifles in public is necessary, though I am a vocal defender of the 2nd amendment, however I do think it is very short-sighted to assume you'll never need to use a firearm, and therefor write them off. Didn't you learn how to change a tire, even though you may never need to, perform CPR in gym class, or how to balance an equation in science (or for the scientist, write in plain English, or not blow up the world)? Sure, all of those will be needed a whole lot more than shooting, but other than CPR shooting might be the most important to know if any of those situations came up.</p>
<p>Now, I considered myself set once I learned safety, and how to aim properly. But lately I've been thinking that its really short-sighted of me to assume the rifle will work perfectly all the time. More importantly, I don't know when its not working at 100%, because I don't understand it all. Just like the sorority girls whose computers I'd clean up at the end of the school year, I might not realize all the junk that is building up inside my gun. So, I've decided that I need to know at least basic gun smithing, just in case. Knowing this will keep me, and those around me when I shoot, a whole lot safer in the long run, plus save me money!</p>
<p>The motorcycle is the same story. I have no idea what's going on, and if you read up on an inline-4 engine, there's really no excuse for that. So again, I'm teaching myself basic mechanics in order to keep my machines running as smoothly and safely as possible.</p>
<p>And if you think about it, these skills of checking the usual fail points, oiling the squeaky parts, and throwing your own custom parts in, are the same across many fields, not just mechanics, gun smithing, and programming. So get out there, and get yourself head first into a new field today!</p>
]]></content:encoded>
			<wfw:commentRss>http://thesnarky.com/2008/09/10/head-first-mechanics-and-gun-smithing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Thieves Tavern &#8211; Where all the cool kids play</title>
		<link>http://thesnarky.com/2008/06/28/thieves-tavern-where-all-the-cool-kids-play/</link>
		<comments>http://thesnarky.com/2008/06/28/thieves-tavern-where-all-the-cool-kids-play/#comments</comments>
		<pubDate>Sat, 28 Jun 2008 19:03:09 +0000</pubDate>
		<dc:creator>Snarky</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Interests]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Three Planets Software]]></category>

		<guid isPermaLink="false">http://thesnarky.com/?p=207</guid>
		<description><![CDATA[For about two weeks now I've been working on a PHP version of the game Mafia. If you don't know it, mayhaps you know the name Werewolf, or Assassin (not Assassin's Creed, like I had some people guess.... there's no way I could port that to PHP). If you're still in the dark, check the [...]]]></description>
			<content:encoded><![CDATA[<p>For about two weeks now I've been working on a PHP version of the game Mafia. If you don't know it, mayhaps you know the name Werewolf, or Assassin (not Assassin's Creed, like I had some people guess.... there's no way I could port that to PHP). If you're still in the dark, check the <a href="http://en.wikipedia.org/wiki/Mafia_Game">Wikipedia</a> page, or <a href="http://mafiascum.net">MafiaScum</a>, one of the best forums for it. <a href="http://push.cx">Harkins</a> and I wrote it into <a href="http://mud.simud.org/">Simud</a> a year or two back, and I've wanted to see an automated version on the Internet for a while now (read: Not needing forum software, or a human moderator). The closest I could find is an email list, which of course I can't find now that I want a link, and frankly doesn't fit my description of 'browser based'. </p>
<p>So what I'm creating is a PHP/AJAX based version of the game, where players can create games of (so far) between 5 and 8 players. Upon creating the game, a random set of roles (random in terms of which roleset, NOT in terms of a hodge podge of random roles that could be very unfair) is doled out, and it goes immediately into the night phase. Each phase will last 24 hours, if everyone does their actions sooner, it'll end, but if you don't ready yourself before the time is up you'll forfeit your action. Game ends based on the roleset... typically once there's only town, or bad guys left, but in terms of Silent Killers it gets more interesting, but will be checked for after every kill, and after every lynching. Chat will allow for anyone to read it, and once the game is over all messages become public.</p>
<p>Unfortunately work has slowed down a bit since buying my motorcycle a week ago, but I'm still hoping to have a closed beta up in a short(ish) amount of time. I actually could put one up already, but am hoping to have a much higher degree of a product before the beta than I usually do. </p>
<p>The site will go live at <a href="http://thievestavern.com">Thieves Tavern</a>, a site I got a long time ago for a gaming clan that is appropriately named, I think. Once it goes up, I'll put out a call for about 10-16 closed beta players, and then probably a week later another open invitation for open beta players. once it seems both stable, and a good recreation of the game, based on the opinion of all players, it'll become a public game. </p>
<p>You can follow the development either through <a href="http://twitter.com/thievestavern">Twitter</a>, or in the #thievestavern room on irc.freenode.net, thanks to <a href="https://github.com">GitHub</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://thesnarky.com/2008/06/28/thieves-tavern-where-all-the-cool-kids-play/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dungeon Runners Character Sheet Library</title>
		<link>http://thesnarky.com/2008/03/15/dungeon-runners-character-sheet-library/</link>
		<comments>http://thesnarky.com/2008/03/15/dungeon-runners-character-sheet-library/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 21:21:11 +0000</pubDate>
		<dc:creator>Snarky</dc:creator>
				<category><![CDATA[DRCSL]]></category>
		<category><![CDATA[Dungeon Runners]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Three Planets Software]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thesnarky.com/2008/03/15/dungeon-runners-character-sheet-library/</guid>
		<description><![CDATA[I took the past week off work for a final Spring Break, since I graduated early. When the friends visiting me left a day early I decided to use Friday to catch up on my programming. My goal was to finally create a library for people wishing to create character sheets for <a href="http://dungeonrunners.com">Dungeon Runners</a> (that popular MMO I've been playing about once a month). The result is <a href="http://threeplanetssoftware.com/software/php_dr_library/">DRCSL</a>, the Dungeon Runners Character Sheet Library, which gives web site owners an easy way to create character sheets or just pull random character data quickly. I used the DRCSL this morning to create a quick MediaWiki extension that spits out a pre-formatted character sheet. Lets discuss:

<strong>DRCSL</strong>
DRCSL is a php library written using PHP 5 and PHP objects. At its core it is currently just one file, Character.php, that upon its creation fetches the character XML from NCSoft's servers, and stores all the data. Once the data is stored, the Character can spit out its information with just a few commands. What's required to use this library is a web server with PHP 5 on it, along with wget to fetch the XML. A default Linux PHP install works just fine, though if your host blocks exec() callouts you're out of luck. I'm on my first release, so the paths are hard coded for Linux delimiters which will be fixed in the future (of course, the Windows host will still need wget installed). 

An example: 

<code>
&#60;?php
   //Include this file to have it include everything ya need.
   include "drcsl.php"; 
   //Create a new Character
   $billy = new Character&#40;"Segfault"&#41;; 
   //Store the character's name
   $name = $billy->get_char_info&#40;"Name"&#41;; 
   //Store the character's title
   $title = $billy->get_char_info&#40;"Title"&#41;; 
   //Display some info
   echo "$name is a $title\\n"; 
?&#62;
</code>

This would print something to the effect of:
"Segfault is a Coordinated Practiced Poison Ranger"

<b>MediaWiki Extension</b>
The MWE became real easy after I created the DRCSL. Rather than include a ton of the code from my Character Viewer into the Extension, now all I had to do was include drcsl.php and come up with a default view. It looks something like <a href="http://threeplanetssoftware.com/software/php_dr_library/images/mediawiki_drcsl_extension.png">this</a>, by the way. In all it took about an hour from the time I woke up this morning and decided to finally create one to having a test version out for TheTownstons to test. 

To use the MWE one just creates a page and includes the drcsl function.
<code>
{{ #drcsl: Segfault }}
</code>

<strong>Further Reading</strong>
More details on both of these projects can be found at the <a href="http://threeplanetssoftware.com/software/php_dr_library/">DRCSL website</a>. I was going to write more but there's something bugging in my Code Highlighter plugin (hence why the code looks like non-highlighted junk) and I'm fighting the urge to go fix it.]]></description>
			<content:encoded><![CDATA[<p>I took the past week off work for a final Spring Break, since I graduated early. When the friends visiting me left a day early I decided to use Friday to catch up on my programming. My goal was to finally create a library for people wishing to create character sheets for <a href="http://dungeonrunners.com">Dungeon Runners</a> (that popular MMO I've been playing about once a month). The result is <a href="http://threeplanetssoftware.com/software/php_dr_library/">DRCSL</a>, the Dungeon Runners Character Sheet Library, which gives web site owners an easy way to create character sheets or just pull random character data quickly. I used the DRCSL this morning to create a quick MediaWiki extension that spits out a pre-formatted character sheet. Lets discuss:</p>
<p><strong>DRCSL</strong><br />
DRCSL is a php library written using PHP 5 and PHP objects. At its core it is currently just one file, Character.php, that upon its creation fetches the character XML from NCSoft's servers, and stores all the data. Once the data is stored, the Character can spit out its information with just a few commands. What's required to use this library is a web server with PHP 5 on it, along with wget to fetch the XML. A default Linux PHP install works just fine, though if your host blocks exec() callouts you're out of luck. I'm on my first release, so the paths are hard coded for Linux delimiters which will be fixed in the future (of course, the Windows host will still need wget installed). </p>
<p>An example: </p>
<p><code><br />
&lt;?php<br />
   //Include this file to have it include everything ya need.<br />
   include "drcsl.php";<br />
   //Create a new Character<br />
   $billy = new Character&#40;"Segfault"&#41;;<br />
   //Store the character's name<br />
   $name = $billy->get_char_info&#40;"Name"&#41;;<br />
   //Store the character's title<br />
   $title = $billy->get_char_info&#40;"Title"&#41;;<br />
   //Display some info<br />
   echo "$name is a $title\\n";<br />
?&gt;<br />
</code></p>
<p>This would print something to the effect of:<br />
"Segfault is a Coordinated Practiced Poison Ranger"</p>
<p><b>MediaWiki Extension</b><br />
The MWE became real easy after I created the DRCSL. Rather than include a ton of the code from my Character Viewer into the Extension, now all I had to do was include drcsl.php and come up with a default view. It looks something like <a href="http://threeplanetssoftware.com/software/php_dr_library/images/mediawiki_drcsl_extension.png">this</a>, by the way. In all it took about an hour from the time I woke up this morning and decided to finally create one to having a test version out for TheTownstons to test. </p>
<p>To use the MWE one just creates a page and includes the drcsl function.<br />
<code><br />
{{ #drcsl: Segfault }}<br />
</code></p>
<p><strong>Further Reading</strong><br />
More details on both of these projects can be found at the <a href="http://threeplanetssoftware.com/software/php_dr_library/">DRCSL website</a>. I was going to write more but there's something bugging in my Code Highlighter plugin (hence why the code looks like non-highlighted junk) and I'm fighting the urge to go fix it.</p>
]]></content:encoded>
			<wfw:commentRss>http://thesnarky.com/2008/03/15/dungeon-runners-character-sheet-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dungeon Runners Website on Linux</title>
		<link>http://thesnarky.com/2007/12/23/dungeon-runners-website-on-linux/</link>
		<comments>http://thesnarky.com/2007/12/23/dungeon-runners-website-on-linux/#comments</comments>
		<pubDate>Sun, 23 Dec 2007 21:53:54 +0000</pubDate>
		<dc:creator>Snarky</dc:creator>
				<category><![CDATA[Annoyances]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://thesnarky.com/2007/12/23/dungeon-runners-website-on-linux/</guid>
		<description><![CDATA[For those that use Linux, read my post yesterday, and decided to check out the website for <a href="http://dungeonrunners.com/">Dungeon Runners</a>, I apologize. I should have pointed out that their site is very, very unusable on Linux (ok, to be exact, I haven't gotten it to work with any version of Ubuntu, and Firefox). That changed today when I cooked up a small <a href="https://addons.mozilla.org/en-US/firefox/addon/748">GreaseMonkey</a> script which hides their Flash "movie" that plays in the background. Its not really a movie, its actually just a static image, but its loaded as a Flash movie. Anyways, its quite easy, go install GreaseMonkey, then the following script:


<pre lang="javascript">
// ==UserScript==
// @name           Dungeon Runners Linux Compliant
// @namespace      http://thesnarky.com
// @description    This removes the flash "movie" which blocks the main site for Dungeon Runners
// @include        http://dungeonrunners.com/*
// @include        http://boards.dungeonrunners.com/*
// ==/UserScript==

var objects = document.getElementsByTagName("object");
for(i=0; i<objects.length; i++) {
	var flash = objects[i];
	if(flash.getAttribute("id") == "bg_chars") {
		flash.style.display='none';
	}
}
</pre>

Can download it by clicking here: <a href="http://thesnarky.com/wp-admin/dungeonrunnerslinuxniceuser.js">http://thesnarky.com/wp-admin/dungeonrunnerslinuxniceuser.js</a>

This finds the one Flash object named bg_chars (which is the offender in this case) and tells him to go quietly sit in the corner. And such, all is right in the world, I don't need to boot into Windows to troll the forums (just to play the game).]]></description>
			<content:encoded><![CDATA[<p>For those that use Linux, read my post yesterday, and decided to check out the website for <a href="http://dungeonrunners.com/">Dungeon Runners</a>, I apologize. I should have pointed out that their site is very, very unusable on Linux (ok, to be exact, I haven't gotten it to work with any version of Ubuntu, and Firefox). That changed today when I cooked up a small <a href="https://addons.mozilla.org/en-US/firefox/addon/748">GreaseMonkey</a> script which hides their Flash "movie" that plays in the background. Its not really a movie, its actually just a static image, but its loaded as a Flash movie. Anyways, its quite easy, go install GreaseMonkey, then the following script:</p>
<pre class="javascript">&nbsp;
<span style="color: #009900; font-style: italic;">// ==UserScript==</span>
<span style="color: #009900; font-style: italic;">// @name           Dungeon Runners Linux Compliant</span>
<span style="color: #009900; font-style: italic;">// @namespace      http://thesnarky.com</span>
<span style="color: #009900; font-style: italic;">// @description    This removes the flash &quot;movie&quot; which blocks the</span>
<span style="color: #009900; font-style: italic;">//                      main site for Dungeon Runners</span>
<span style="color: #009900; font-style: italic;">// @include        http://dungeonrunners.com/*</span>
<span style="color: #009900; font-style: italic;">// @include        http://boards.dungeonrunners.com/*</span>
<span style="color: #009900; font-style: italic;">// ==/UserScript==</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> objects = document.<span style="color: #006600;">getElementsByTagName</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;object&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000066; font-weight: bold;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #CC0000;">0</span>; i&lt;objects.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> flash = objects<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>flash.<span style="color: #006600;">getAttribute</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #3366CC;">&quot;bg_chars&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		flash.<span style="color: #006600;">style</span>.<span style="color: #006600;">display</span>=<span style="color: #3366CC;">'none'</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>Can download it by clicking here: <a href="http://thesnarky.com/wp-content/uploads/2007/12/dungeonrunnerslinuxniceuser.js">Script</a></p>
<p>This finds the one Flash object named bg_chars (which is the offender in this case) and tells him to go quietly sit in the corner. And such, all is right in the world, I don't need to boot into Windows to troll the forums (just to play the game).</p>
]]></content:encoded>
			<wfw:commentRss>http://thesnarky.com/2007/12/23/dungeon-runners-website-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dungeon Runners</title>
		<link>http://thesnarky.com/2007/12/22/dungeon-runners/</link>
		<comments>http://thesnarky.com/2007/12/22/dungeon-runners/#comments</comments>
		<pubDate>Sun, 23 Dec 2007 04:38:10 +0000</pubDate>
		<dc:creator>Snarky</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Three Planets Software]]></category>

		<guid isPermaLink="false">http://thesnarky.com/2007/12/22/dungeon-runners/</guid>
		<description><![CDATA[I've taken to playin <a href="http://dungeonrunners.com">Dungeon Runners</a> as of late, trying to scratch that itch that leaving WoW created. Actually, I'm quite happy to be done with WoW, and Dungeon Runners is casual enough that I can play and not get pressured into sticking on for long hours for "Just one more Ony raid". In addition, Dungeon Runners is free, so long as you put up with ads you barely even notice! 

As always I get distracted from playing games by writing stuff for them and DR is no different. They just released a service where you can nab an XML version of a player's data and though it has some bugs its quite a yummy service. I spent the day hacking up a viewer for it, and this is what I came up with:
<a href="http://threeplanetssoftware.com/software/dr/">
http://threeplanetssoftware.com/software/dr/</a>

Its fairly empty right now, but the character stuff works as well as NCSoft will allow. In fact better, as I've solved an issue the other developers of these viewers hasn't, the fact that some icons have the wrong name. So, anywho if you want to see it work, you could check my stats: the character's name is Segfault. 

Oh and just to satisfy the geeks out there: This is built in PHP, using simplexml to chew though the data. Pretty URLs are (obviously) done with mod_rewrite and javascript on the form. Tooltips are made using the <a href="http://www.walterzorn.com/tooltip/tooltip_e.htm">Walter Zorn tooltip library</a>.]]></description>
			<content:encoded><![CDATA[<p>I've taken to playin <a href="http://dungeonrunners.com">Dungeon Runners</a> as of late, trying to scratch that itch that leaving WoW created. Actually, I'm quite happy to be done with WoW, and Dungeon Runners is casual enough that I can play and not get pressured into sticking on for long hours for "Just one more Ony raid". In addition, Dungeon Runners is free, so long as you put up with ads you barely even notice! </p>
<p>As always I get distracted from playing games by writing stuff for them and DR is no different. They just released a service where you can nab an XML version of a player's data and though it has some bugs its quite a yummy service. I spent the day hacking up a viewer for it, and this is what I came up with:<br />
<a href="http://threeplanetssoftware.com/software/dr/"></p>
<p>http://threeplanetssoftware.com/software/dr/</a></p>
<p>Its fairly empty right now, but the character stuff works as well as NCSoft will allow. In fact better, as I've solved an issue the other developers of these viewers hasn't, the fact that some icons have the wrong name. So, anywho if you want to see it work, you could check my stats: the character's name is Segfault. </p>
<p>Oh and just to satisfy the geeks out there: This is built in PHP, using simplexml to chew though the data. Pretty URLs are (obviously) done with mod_rewrite and javascript on the form. Tooltips are made using the <a href="http://www.walterzorn.com/tooltip/tooltip_e.htm">Walter Zorn tooltip library</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://thesnarky.com/2007/12/22/dungeon-runners/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I can has vote pictures!</title>
		<link>http://thesnarky.com/2007/12/03/i-can-has-vote-pictures/</link>
		<comments>http://thesnarky.com/2007/12/03/i-can-has-vote-pictures/#comments</comments>
		<pubDate>Tue, 04 Dec 2007 03:28:59 +0000</pubDate>
		<dc:creator>Snarky</dc:creator>
				<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://thesnarky.com/2007/12/03/i-can-has-vote-pictures/</guid>
		<description><![CDATA[You may recall I like <a href="http://thesnarky.com/2007/10/14/i-can-has-pictures/">cute cat pictures with captions</a>. I've been really into viewing the voting pages lately because there's LOTS more pictures every day that you don't get to see otherwise. Unfortunately these pictures don't have individual links given with them so I couldn't paste into relevant conversations, and lets face it, every conversation can be relevant to a cute cat so I hit this problem daily. That is, until now. Have a go at <a href="http://threeplanetssoftware.com/software/lolcats/vote_link.php">this page</a>. Ugly as heck, but leads to cuteness. 

To use it, lets say you're browsing the voting page when you find something adorable. To get its link, right-click on the picture, and copy the image's location. Paste that link into the URL field on the vote_link page, then hit 'Find'. At the top you'll be given the first link you gave (to make sure it's working), and the link I generate to its individual page. Click on the second 'here' and there's your link!]]></description>
			<content:encoded><![CDATA[<p>You may recall I like <a href="http://thesnarky.com/2007/10/14/i-can-has-pictures/">cute cat pictures with captions</a>. I've been really into viewing the voting pages lately because there's LOTS more pictures every day that you don't get to see otherwise. Unfortunately these pictures don't have individual links given with them so I couldn't paste into relevant conversations, and lets face it, every conversation can be relevant to a cute cat so I hit this problem daily. That is, until now. Have a go at <a href="http://threeplanetssoftware.com/software/lolcats/vote_link.php">this page</a>. Ugly as heck, but leads to cuteness. </p>
<p>To use it, lets say you're browsing the voting page when you find something adorable. To get its link, right-click on the picture, and copy the image's location. Paste that link into the URL field on the vote_link page, then hit 'Find'. At the top you'll be given the first link you gave (to make sure it's working), and the link I generate to its individual page. Click on the second 'here' and there's your link!</p>
]]></content:encoded>
			<wfw:commentRss>http://thesnarky.com/2007/12/03/i-can-has-vote-pictures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

