<?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</title>
	<atom:link href="http://thesnarky.com/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>Wed, 24 Feb 2010 04:50:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<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>Pretty Things are Dangerous</title>
		<link>http://thesnarky.com/2009/10/24/pretty-things-are-dangerous/</link>
		<comments>http://thesnarky.com/2009/10/24/pretty-things-are-dangerous/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 15:10:57 +0000</pubDate>
		<dc:creator>Snarky</dc:creator>
				<category><![CDATA[Motorcycles]]></category>

		<guid isPermaLink="false">http://thesnarky.com/?p=409</guid>
		<description><![CDATA[Pretty things are always dangerous, you heard me right. You can see the truth in this everywhere you look. In nature most animals have learned that if whatever they're trying to eat is pretty, it usually has some form of poison. Look at deep sea creatures, get drawn to a light and its always a [...]]]></description>
			<content:encoded><![CDATA[<p>Pretty things are always dangerous, you heard me right. You can see the truth in this everywhere you look. In nature most animals have learned that if whatever they're trying to eat is pretty, it usually has some form of poison. Look at deep sea creatures, get drawn to a light and its always a predator. As humans we can even see this in bars, the prettier she is the quicker and more painful the shoot down will be. (Ok, I kid on the last one, but felt I needed a third example). </p>
<p>The same principle goes for riding motorcycles, if its pretty it ends up being dangerous. A specific example is the fall. I love riding in the fall as it reminds me of when I was learning how to ride and there's a nice crispness in the air. That throttle snaps just a tad quicker than in the hot mugginess of summer. The roar of your pipes carry just a tad further across the still morning, scattering herds of deer that a few months ago would have been asleep and off the roads by this time. Finally you get to ride in the most beautiful display of foliage fireworks you'll get all year. Explosions of red and yellow and orange flash past as you lean through the turns and push that crisp air just a tad harder than you did during the summer, racing to get one more run in before your tires are too cold to really lean.</p>
<p>And that's when it gets you, you round a corner, blast through that patch of leaves that you expect to fly up around you like in the commercials and all of a sudden you're sliding off into the trees which aren't quite as pretty when you're hurtling headfirst through branches and road signs. What happened? Well, those pretty leaves which you were enjoying happened to still be wet underneath from the rains yesterday or the day before. As you were mid corner your rear wheel caught a pocket of wet leaves that acted exactly like ice and you lost the rear, leading to a good fast low side and gear check. Its exactly like riding a bicycle over a crushed water bottle, all of a sudden something's stuck under your wheel and instead of being connected to the road you're sliding. And once you lose the rear, its game over on a motorcycle. </p>
<p>Yes, riding in the fall is gorgeous, and I love it. Had a great ride today (in the wet) with leaves showering down around my helmet (the road appears completely different on two, you're surrounded by the leaves swirling around you) and a gray sky bringing out the difference in colors all around. But you always have to remember, if its pretty its probably more dangerous. So ride just a tad easier when you come to a leaf filled road, as fun as the commercials are you don't want to take the chance of hitting a wet patch underneath the top layer, or a pothole that's been covered, or a sewer grate that might still be cold, wet, metal that will love to just eat your wheel for dinner.</p>
<p>Ride to live, period. </p>
]]></content:encoded>
			<wfw:commentRss>http://thesnarky.com/2009/10/24/pretty-things-are-dangerous/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Diamond in the Rough &#8211; Part 1</title>
		<link>http://thesnarky.com/2009/09/03/diamond-in-the-rough-part-1/</link>
		<comments>http://thesnarky.com/2009/09/03/diamond-in-the-rough-part-1/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 02:42:46 +0000</pubDate>
		<dc:creator>Snarky</dc:creator>
				<category><![CDATA[Firearms]]></category>
		<category><![CDATA[Gun smithing]]></category>

		<guid isPermaLink="false">http://thesnarky.com/?p=391</guid>
		<description><![CDATA[Thanks to the Nation's Gunshow that was held a few weeks ago my brother ended up with an SKS. He'd been talking about them for a bit, and the price was right ($275, cash). It was bought with no knowledge of SKS's beyond when they were designed (way long ago), or what to look for [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to the <a href="http://www.google.com/url?sa=t&source=web&ct=res&cd=1&url=http%3A%2F%2Fwww.thenationsgunshow.com%2F&ei=AmJzSs35JpTANpaqkbEM&rct=j&q=nations+gunshow&usg=AFQjCNHwUPS_7ep11ku4A9a98WkLkX-lrg">Nation's Gunshow</a> that was held a few weeks ago my brother ended up with an <a href="http://en.wikipedia.org/wiki/Sks">SKS</a>. He'd been talking about them for a bit, and the price was right ($275, cash). It was bought with no knowledge of SKS's beyond when they were designed (way long ago), or what to look for (serial numbers, marker's marks, etc). Now, it didn't look all that pretty, but the important bits were on it (firing pin, magazine, barrel), and it was $100 cheaper than any other SKS at the show, so it was bought.</p>
<p>As my brother was headed out of the country on a trip, I decided to take the gun to my place and clean it up a tad while he was gone, and see how good it could look. Then I'll give him the cleaned up version when he gets back and see if he recognizes it. I picked up a small SKS manual, enough to show basic disassembly and cleaning, cracked open Google for the rest of the bits, and sat down to start.</p>
<p><strong>What is it?</strong></p>
<p><img src="http://lh6.ggpht.com/_FeJTFvmV4A8/SnD2lFL9HkI/AAAAAAAAA_4/iaWQGxbxrXg/s512/0727091847a.jpg" alt="" /></p>
<p>My first desire was to find out exactly what this rifle was. It resembles a typical SKS, 20" barrel, knife style bayonet, wood stock, only difference was a detachable magazine, which wasn't in the original design. Next step was to find all the serials I could, which yielded the following:</p>
<p>Receiver/Trigger Group: K4992 (with a marker's mark of '26' inside of a triangle)<br />
Stock: 33616<br />
Bolt carrier: 05676<br />
Bolt: 35505<br />
Barrel: (Odd character) 3276</p>
<p>So we obviously have parts from at least five separate rifles. I'm taking the receiver serial as the firearm's serial (since that's usually where firearms put the serial) and the others as just references to figure out where it came from. I used a great SKS site: <a href="http://www.yooperj.com/SKS.htm">Yooper John's SKS information</a>.</p>
<p><img src="http://lh5.ggpht.com/_FeJTFvmV4A8/SnD2mXTzo6I/AAAAAAAABAo/cktrkQ7_ziE/s640/0727091849a.jpg" alt="" /></p>
<p>The receiver's serial was the easiest to track down. It has a few distinctive marks: The lack of Chinese or Cyrillic characters on the receiver, the obvious maker's mark of '26' inside a triangle. This fast narrowed it down to the Jianshe Armory in 1956. Why 1956? Because I believe in late 1956, or in 1957 the Chinese started serializing their weapons with more than 4 digits, and using no Roman characters. So the receiver/trigger group are all original parts from the same rifle, a Chinese Type 56, built in 1956 at Jianshe. The barrel appears to be the same numbering scheme as the others, (1 character, 4 digits) so I'm again taking this to be a Jianshe Sino-Soviet part, just replaced at a later time.</p>
<p><img src="http://lh3.ggpht.com/_FeJTFvmV4A8/SnD2l8PznZI/AAAAAAAABAY/mWYv_hItPXA/s512/0727091848c.jpg" alt="" /></p>
<p>The stock is from a [presumably Chinese] replacement, however most Chinese stocks had a side mount for the sling, and this has a bottom mount so I'm thinking it may be Russian or Yugoslavian just tossed on there at some point in a repair shop. There is a marker's mark of a 6 in a triangle, and googling seems to suggest this is a Chinese mark, so I don't know. I do know it has to be younger than the receiver, and most likely is a result of the gun going back for service at some point. Whatever the case may be, serial number is 33616, which would be the last 5 digits from a longer serial (only place the full serial would be stamped is on the receiver). </p>
<p><img src="http://lh4.ggpht.com/_FeJTFvmV4A8/SnD2m9UcO9I/AAAAAAAABAw/jnlCVdQoDTU/s512/0727091850.jpg" alt="" /></p>
<p>The bolt carrier bears the number 05676, which does match the bolt, or any other bit on the rifle. There are no other identifiable markings. The bolt itself has a few markings, a '2', an 'A', what looks to be another 'A'. then a '5' overlaid on an 'I'. I couldn't track down any of these.</p>
<p>My best guess is that these parts are all Chinese, and at some point the stock became damaged, leading to replacing it, and later on replacing the bolt/carrier. They could also have been touched by someone much further on down the line, trying to make one working rifle from a few spare rifles. </p>
<p>Next up, cleaning!</p>
]]></content:encoded>
			<wfw:commentRss>http://thesnarky.com/2009/09/03/diamond-in-the-rough-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ghandi on Firearms</title>
		<link>http://thesnarky.com/2009/08/03/ghandi-on-firearms/</link>
		<comments>http://thesnarky.com/2009/08/03/ghandi-on-firearms/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 02:29:00 +0000</pubDate>
		<dc:creator>Snarky</dc:creator>
				<category><![CDATA[Firearms]]></category>
		<category><![CDATA[Real Life Rights]]></category>

		<guid isPermaLink="false">http://thesnarky.com/?p=399</guid>
		<description><![CDATA[I've been reading through the Heller decision (also known as The District of Columbia v. Heller, the Supreme Court case last summer that decided handgun bans were unconstitutional) and it has been *very* enlightening. I consider myself well read on gun laws, statistics and all that, but man, this is good stuff. Both sides have [...]]]></description>
			<content:encoded><![CDATA[<p>I've been reading through the Heller decision (also known as The District of Columbia v. Heller, the Supreme Court case last summer that decided handgun bans were unconstitutional) and it has been *very* enlightening. I consider myself well read on gun laws, statistics and all that, but man, this is good stuff. Both sides have good arguments, this is one of the few times I've actually understood the reasoning behind a 'Lets ban all guns' argument, as presented by the Stevens [don't completely agree with] and Breyer [see much more eye to eye with] dissents. I highly recommend picking up a copy of <a href="http://www.palladiumpress.com/store/Scripts/prodView.asp?idproduct=1737">this book</a>, nice and concise with the full majority and dissenting opinions.</p>
<p>But its had me wondering about various facts, googling around to see what data I can dig up, and what opinions I can find. I stumbled across two great quotes tonight I just had to pass on.</p>
<p>The first is Ghandi, in his autobiography:</p>
<blockquote><p>"Among the many misdeeds of the British rule in India, history will look upon the Act depriving a whole nation of arms, as the blackest." (page 238 according to the site I found it on)</p></blockquote>
<p>The Act in this case is referring to (I believe) the Indian Arms Act of 1878. This act made it impossible for a non-British citizen to get a weapon unless they could prove they were loyal. Something about making sure British rule (which was in place by force) wasn't overthrown by the legitimate subjects, or some such. So, we can see that Ghandi recognized that even though he preferred non-violent means, a population without arms cannot fight against an oppressor.</p>
<p>The second is another bastion of peacefulness, the 14th Dalai Lama, Tenzin Gyatso:</p>
<blockquote><p>"If someone has a gun and is trying to kill you, it would be reasonable to shoot back with your own gun. Not at the head, where a fatal wound might result. But at some other body part, such as a leg." (<a href="http://www.thefreelibrary.com/Students+urged+to+shape+world+Dalai+Lama+preaches+peace+in+Portland.-a074555192">Seattle Times, May 15, 2001</a>)</p></blockquote>
<p>This was apparently in response to a question about a student turning a gun on another student. I will let go the argument for giving students the right to carry, but just focus on his words. Here we see a (mainly) peaceful man arguing on behalf of the right to use guns in self defense.</p>
<p>Amazing how even those who choose non-violence recognize the inherent need for weapons in our culture. </p>
]]></content:encoded>
			<wfw:commentRss>http://thesnarky.com/2009/08/03/ghandi-on-firearms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First Blood!</title>
		<link>http://thesnarky.com/2009/07/24/first-blood/</link>
		<comments>http://thesnarky.com/2009/07/24/first-blood/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 01:13:40 +0000</pubDate>
		<dc:creator>Snarky</dc:creator>
				<category><![CDATA[Firearms]]></category>
		<category><![CDATA[Interests]]></category>

		<guid isPermaLink="false">http://thesnarky.com/?p=383</guid>
		<description><![CDATA[No, this isn't about Unreal Tournament, sadly, although now I really wanna go play that game again. 
Took the AR I built with the intent of getting into competitive shooting out to a match for the first time last Saturday. Since this was a Garand shoot, I was made fun of until I ripped off [...]]]></description>
			<content:encoded><![CDATA[<p>No, this isn't about Unreal Tournament, sadly, although now I really wanna go play that game again. </p>
<p>Took the AR I built with the intent of getting into competitive shooting out to a match for the first time last Saturday. Since this was a Garand shoot, I was made fun of until I ripped off the optics and bipod, in favor of good old iron sights (<a href="http://www.brownells.com/.aspx/pid=21358/Product/GAS_BLOCK_FRONT_FLIP_SIGHT">Yankee Hill</a> Flip-up sights) and a sling (GI-web, standard issue [for Vietnam]). I had one morning of practice last week, first time shooting the AR with iron sights, and the first time ever shooting with a sling (turns out, no, it doesn't go over your shoulder). It was hot (turns out showing up in a t-shirt and shorts isn't competitive enough), it was long (35 minutes are averaging about 1 shot a minute), and quite discouraging (sighting in at 100 yards, standing, I hit paper 5 out of 20 shots). </p>
<p>I wanted to practice most of the week with the sling and my positions (prone, supported by the sling, sitting, support by the sling, and standing off hand), but work and prior commitments got in the way every day! Come Friday night I had just enough time to load my mags, strip/oil the gun (my bolt catch sticks something awful), and get everything in one pile before going to bed. And waking up every, single, hour, thanks to a dog I'm babysitting. Not that big of a deal except for the fact that I had to be up by 4:45am. My thoughts that night were that I'd be happy if I could average 5's (the largest circle), satisfied if all my shots were on paper, and really happy if I knocked in a bull. </p>
<p>Morning came, way too early. In fact, it was still dark, and neither I nor the dog were awake for our walk. Got down to the range without eating breakfast, figuring we'd be gone by lunch, and was feeling pretty good as I headed off into the pits at 8:45.</p>
<p>Let me explain how this works. This was a Garand match, but very laid back, so there was a few other service rifles that weren't Garands (they were older), and two ARs. The distance was 200 yards, we all had open sights (no scopes), and were shooting with slings. Now, at 200 yards its hard to tell if you hit a bull that's two inches wide, so half the shooters were back in the pits, imagine a concrete trench back at the business end of the range, just under the targets. As they shot, we could pull the targets down, mark where the hit was, and mark what point value it was. </p>
<p>The targets were standard 200 yard targets, pasted onto a cardboard target that expanded it. The X ring is about 2 inches in diameter, and I believe each additional ring was about two more inches. So it went X - 10 - 9 - 8 - 7 - 6 - 5, and everything outside of that was a miss. Scoring was whatever that zone was numbered, Xs count as 10, but in the event of a tie, its the number of Xs that determines the winner. </p>
<p>The course of fire was the opposite of a 'normal' order. It was prone slow fire 25 shots (5 were sight-ins, 20 counted), prone rapid fire 10 shots, sitting rapid fire 10 shots, standing slow fire 10 shots. Slow fires were alloted one minute per shot, rapid prone was 80 seconds, rapid sitting was 70 seconds. For the slow fire, the pits pull down the target after every shot, marking where the hit was, and marking what it was worth. For the rapid fire, the target is only pulled after the time limit is up, and all hits are marked. </p>
<p>We had 4 teams with 4 people each, so there was going to be 4 'relays' firing. Each team sent two guys to the pits, and left two at the line to shoot. My team was two guys I knew from the church I grew up in (my partner was easily in his 70s.... he took third), one of their co-workers, and me. My partner and I went to the pits first, which was nice as the sun hadn't risen enough to warm the concrete, and we had shade. </p>
<p>I tell you what, it was quite intimidating to watch one of our guys, who shoots at Camp Perry every year, get misses. Made me think I had no shot. One shocking thing I learned (and for all I study firearms, never thought about) is just how loud a bullet it. Not the report from the gun, but the bullet going over you. Its traveling in excess of 3000 feet per second, well over the speed of sound, so you get a nice sonic boom as it whips over top of you. At 200 yards I couldn't hear the report of the guns over the bullet coming by. Another thing that's easy to forget at indoor ranges, is just how destructive bullets are. The rounds going over were hitting about 10-20 yards up and in front of us, and yet I'd still get showered by dirt occasionally. Amazing.</p>
<p>Shooting commenced around 9AM, first shooter was done around 10:30, and we were changing pits with the firing line around 1145. Yes, it takes a LONG time. The old guy with me shot first, so I could see what the rhythm is how it all works. He took his time getting prone, and into sitting, complaining of some cataracts and a touch of mono.... Proceeded to run up a string of 9's in the rapid fire that were almost touching. To give you an idea of how good that is, an 'accurate' weapon might shoot '1/2 MOA [minutes of accuracy]'. 1 MOU is roughly 1 inch at 100 yards. So to shoot with 1 MOU accuracy at 200 yards means your bullets should be spread out over an inch. So for him to have them just about touching, that's good shooting. </p>
<p>Finally around 1pm, with some nice heat exhaustion (didn't bring more than one bottle of water) and no food all day other than two granola bars, I got my chance on the line. I basically just wanted to shoot my 55 rounds, and get the heck out of dodge. Being sighted in at 100 yards, I wasn't even sure where I'd be hitting for my sight in shots, but, thankfully, they were right on!</p>
<p>5 sight-ins went down range, and I started into my 'for record' slow fire shots. After about 10 (loaded one by one) I was ready to call it quits. But, I was still hitting good numbers, so I pushed through the exhaustion, and just ended up rushing the last 4 shots... with a solid 12 minutes to go! So I stripped out of my gear (sweatshirt and shooting jacket/glove) and bummed some water from people, happy with the three bulls I nailed in the last 10 shots. </p>
<p>Rapid fire I just BLEW through, went wide the first two shots (6's) but the second magazine (you shoot 2 rounds from one mag, then 8 rounds from the next) was all pretty good. Finished that about 10-15 seconds early. </p>
<p>Rapid fire sitting is more uncomfortable, so again, I was just rushing to get it done with. As I finished up I debated just skipping the standing off hand bit, seeing as I couldn't hit anything last week, and the fact that I could barely pick the weapon up in between sitting and standing. I sucked it up, prayed for just 10 more minutes of not-passing-out, and started shooting. Well, the other guys must have thought me crazy. I spent my 'prep' time sitting on the ground, in a t-shirt, not geared up getting a good stance. I was getting gear on as the load command was given, not really caring what happened, as I was already really happy with my three bulls from prone. Took my first shot, started reloading immediately, just wanting the rounds out of my hands, when the spotter called a 10! I turned around said "Could you recheck?" Sure enough, its a 10. A little heartened, I took a second shot. "9". Dang... after the first few shots I actually started trying, which made my scores start to slip, but wow. I scored a 54 total, which means that even on my worst position I met my hopes of scoring an average of 5's. Huzzah. Miracles DO happen!</p>
<p>In the end, I shot a 389, an average of 7s, or just outside the black. I had one 'M' that was agreed upon my the experienced shooters to have been a 'blown jacket', or a bullet that wasn't made correctly, and blew itself apart. They saw no hits from the pits, and it was in the middle of a string of 10s so *shrug*. I'm quite happy with that outcome, and have to thank my dad for giving me the instruction he did on BB guns in the basement, its the only teaching I've had. Other than the guy helping us sight in last week, of course. </p>
<p>I'd embellish more, and add some pictures, but Firefox keeps crashing so I'll just hit publish. </p>
]]></content:encoded>
			<wfw:commentRss>http://thesnarky.com/2009/07/24/first-blood/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruger 10/22</title>
		<link>http://thesnarky.com/2009/07/07/ruger-1022/</link>
		<comments>http://thesnarky.com/2009/07/07/ruger-1022/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 22:07:27 +0000</pubDate>
		<dc:creator>Snarky</dc:creator>
				<category><![CDATA[Firearms]]></category>
		<category><![CDATA[Real Life Rights]]></category>

		<guid isPermaLink="false">http://thesnarky.com/?p=379</guid>
		<description><![CDATA[I'm currently in a nasty quandary: I'm at a time in my life when I want to pursue shooting as a sport and a hobby, going down an amateur competition road, and I'm also at arguably the worst time to afford shooting since, oh, probably WWII when all spare metal was going to the military. [...]]]></description>
			<content:encoded><![CDATA[<p>I'm currently in a nasty quandary: I'm at a time in my life when I want to pursue shooting as a sport and a hobby, going down an amateur competition road, and I'm also at arguably the worst time to afford shooting since, oh, probably WWII when all spare metal was going to the military. The price of firearms is incredibly inflated, and the price of ammo is outrageous. </p>
<p>"Assault Rifles" that were around $600 might now fetch $1200, and a complete package with goodies can easily top $2000. Cheap WWII surplus that may have been picked up sub $100 at a gun show is now being auctioned above $300. A box of 20 rounds of 30-30 has gone up from around $10 to $20, and more, since I started shooting that rifle, and some calibers (such as .50) have gone up as much as 3-5 times the previous cost just 5 years ago. This is due to a number of factors (fear, low supply due to fear, some crazy shenanigans trying to change how ammo is produced as to outlaw guns, and the rising cost of metal in the cases), but the fact remains, its a sucky time to try to get into shooting.</p>
<p>5 months ago I was looking at building a <a href="http://thesnarky.com/2008/11/12/just-need-a-name/">second AR-15</a> but the cost of the stripped lower receiver had almost doubled in just 7 months (I paid $120ish after tax last summer, and was looking at paying over $200 to $250 for the same receiver in February), and I really couldn't justify my purchases. I wandered into the local <a href="http://www.basspro.com/homepage.html?CMID=&cm_mmc=&cm_guid=&hvarAID=&hvarEID=&cm_ven=&cm_cat=&cm_pla=&cm_ite=">Bass Pro Shops</a> just to see what I could get for the same price, on a whim. I asked around about what they might have that I could afford to shoot on a regular basis, specifically looking for a .22 caliber rifle (.22LR rounds currently run around $20 for 500 rounds). </p>
<p>The man helping me said that <a href="http://www.ruger-firearms.com">Ruger</a> had good stuff, and the <a href="http://www.ruger-firearms.com/Firearms/FAFamily?type=Rifle&subtype=Autoloading&famlst=39">10/22</a> started around $220 (note for those who opened the link... this is cheaper than the website price as dealers always buy under MSRP). I asked about one, was informed they were out of stock, then the guy checked in back and they had one left. Pulled it out, waved it around a bit, and decided "Why not?" So I walked out with it that day, with some ammo, for about $250 total, as opposed to $220 for one piece of one gun. </p>
<p>Took it out to the range, and wasn't immediately impressed, it put rounds down range, but made the tiniest of sounds (its a .22) and was just OK. </p>
<p>Fast forward to the summer. Now I'm going to the range a lot more (once a week), shooting a lot more (few hundred rounds a week, mainly .22 and 9mm), and getting a lot more into it (treating it as 'practice', concentrating on my posture, breathing, control, getting smaller groups). In the last week I've had the 10/22 out three times to the local indoor range, and tossed 800ish rounds through it. </p>
<p>First night was around 250 (of my ammo, more with his) with my roommate, fairly easy (taking our time, not really concentrating). We had two failures to eject the spent case, both with his (cheap) ammo, and I'm attributing it to the ammo being fairly weak (noticeable sound difference between his cheap, and my cheap). </p>
<p>The next night I took it out with another friend, and we proceeded to do a very fast rate of fire, with one of us loading the spare mag as the other emptied the first, maybe a 3 second turn around time in between every 10 shots, just pounding them. Was also staying fairly accurate. After 200 rounds the barrel got too hot to hold, but she was still accurate as we could be. After 340 rounds in 30 minutes we'd had no failures to feed or eject, no problems whatsoever, in fact. It was still accurate by the end, though dirty dirty dirty (told you it was cheap ammo). </p>
<p>After that night, I was very impressed. For a $220 piece of metal, I did not expect it to stand up to that kind of punishment.</p>
<p>Finally yesterday I took her out and blew through the rest of my 200ish rounds, taking my time and focusing on accuracy. She actually had some nice groups when I worked at it, much better than I expected from a bottom of the line .22 rifle. </p>
<p>I highly recommend this rifle. The 10/22 family consists of (currently) 35 models, so there's something for everyone. Bottom of the line is a wood stock, simply open sights, nothing to speak of. Goes up to some serious marksmanship pieces, good platforms for amateur shooting, as well as pretty pink models to get the girls interested. The prices are rock bottom (for this economy) and its an American company (made in the USA as well). </p>
<p>I like it so much when I was looking for a .22 pistol I just picked up a Ruger Mark 3, as I know I can trust the manufacturing and quality.</p>
<p>So if anyone's looking for something small, something to try out shooting with minimal investment and easy shooting (girlfriends that are scared of big bangs will even like them [although I prefer the ones who don't mind tossing an AR around]), look no further than the Ruger 10/22.</p>
]]></content:encoded>
			<wfw:commentRss>http://thesnarky.com/2009/07/07/ruger-1022/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Official Collector</title>
		<link>http://thesnarky.com/2009/06/16/official-collector/</link>
		<comments>http://thesnarky.com/2009/06/16/official-collector/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 02:04:52 +0000</pubDate>
		<dc:creator>Snarky</dc:creator>
				<category><![CDATA[Interests]]></category>

		<guid isPermaLink="false">http://thesnarky.com/?p=374</guid>
		<description><![CDATA[A *long* time ago I filed paperwork to become an official firearms collector in my state of residence. Paperwork finally came through few days back! Huzzah!
For those that aren't up with gun laws, regulated firearms can only be purchased once per 30-days. These are not the federally regulated firearms, such as short-barreled rifles, machine guns, [...]]]></description>
			<content:encoded><![CDATA[<p>A *long* time ago I filed paperwork to become an official firearms collector in my state of residence. Paperwork finally came through few days back! Huzzah!</p>
<p>For those that aren't up with gun laws, regulated firearms can only be purchased once per 30-days. These are not the <a href="http://en.wikipedia.org/wiki/National_Firearms_Act">federally regulated firearms</a>, such as short-barreled rifles, machine guns, or silencers, but the state ones, such as handguns. </p>
<p>Why should I (and/or you) care? Because parts of firearms that include serial numbers are treated as firearms themselves, and unless its something like a barrel that has it, are treated as handguns due to their size (under X" length). Of note here, is that AR-15 <a href="http://www.dpmsinc.com/store/products/?prod=863&cat=1867">stripped lower receivers</a>, which I'll need to purchase if I want to build <a href="http://thesnarky.com/2008/09/10/head-first-mechanics-and-gun-smithing/">another AR</a>, are among those counted as handguns, even though they're literally a chunk of metal that could only hurt someone if you threw it at them. </p>
<p>I absolutely plan on building at least one more AR sometime in the (nearish, I hope) future, and when I put in the order for the lower receiver, I'll order a few, due to the time it takes to get them shipped (anywhere up to 6 months last I checked), and the fact that you never know when these guys are going to be made <a href="http://en.wikipedia.org/wiki/Federal_Assault_Weapons_Ban">illegal again</a>. As already purchased and assembled rifles will usually be grandfathered in, I want to have the serialized parts on hand.</p>
<p>So, in summary, I'm quite excited the paperwork finally came through, now I just have to watch my bank account to make sure I don't make too much use of this. *grin*.</p>
]]></content:encoded>
			<wfw:commentRss>http://thesnarky.com/2009/06/16/official-collector/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Practice Pays Off</title>
		<link>http://thesnarky.com/2009/06/11/practice-pays-off/</link>
		<comments>http://thesnarky.com/2009/06/11/practice-pays-off/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 21:13:33 +0000</pubDate>
		<dc:creator>Snarky</dc:creator>
				<category><![CDATA[Annoyances]]></category>
		<category><![CDATA[Motorcycles]]></category>
		<category><![CDATA[Qarina]]></category>
		<category><![CDATA[Ride Reports]]></category>

		<guid isPermaLink="false">http://thesnarky.com/?p=369</guid>
		<description><![CDATA[My last post was about getting out on a dirt bike to do stuff I felt completely uncomfortable doing, for the sake of practice. It turns out this is more important than I thought. 
Last night I went to a local shop that was having a seminar on tires and chains, and it was awesome. [...]]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://thesnarky.com/2009/06/06/playing-in-the-dirt/">last post</a> was about getting out on a dirt bike to do stuff I felt completely uncomfortable doing, for the sake of practice. It turns out this is more important than I thought. </p>
<p>Last night I went to a local shop that was having a seminar on tires and chains, and it was awesome. Now, I knew as I was leaving that I'd be hitting rain, but it didn't look like it'd get terribly nasty, and, hey, I have the gear for it! When I left I packed everything up (zip-lock bags for everything I care about, rain pants on over my jeans and pads, plastic bags inside my boots) in case I hit rain before getting to the shop. Only bit that I carried with without wearing was my rain jacket as it was HOT out (in all black leather). I learned all this on my trip back from Indiana, and how important staying dry is for maintaining your concentration. The last 5 miles or so of my trip to the shop was a mad dash through the rain, rather than putting my jacket on, as I was close enough that I didn't want to stop. However, I got there almost on time, and mostly dry. </p>
<p>The seminar was great, I learned a ton, but some people kept asking questions, and I saw the sky outside get darker, and darker. Finally we got to the end (checking out the bikes of the few people that road) and I got mine in second. After thanking everyone for putting it on (free of charge!) I geared up to roll out.</p>
<p>To set the stage, it was about 9:15, pitch black, and thunder storming, but I assumed that I was good to go. I had all my gear (except for rubber kitchen gloves under my leathers, as I felt I'd be done soon enough) on and had 240 miles of rainy riding at Interstate speeds with rain gear, and forced myself to experience riding without rain gear for about 10-15 miles in pouring rain just in case. I was fairly confident that if I just stayed off the major highways I'd be fine. That little instinct probably saved me a world of hurt.</p>
<p>As I pulled out onto the first road I flipped my face shield down to block out the rain, and was a bit annoyed at how dirty it was. I tried to wipe it off, but it didn't help. With rain on there, and probably all the bug guts and dirt from my Indiana trip, any ambient light washed out my vision completely. Cars coming towards me rendered my vision useless. I started to experiment with opening the face shield slightly over the next mile, but I simply couldn't see any signs well enough to read them, or judge distances in the best of circumstances, and couldn't even see my speedometer in the worst. </p>
<p>50 miles from home, that late at night, there's not too many options. I could have stopped, tried to clean my helmet (with what?), tried to figure out how to cut down on glare from cars (it has a built in sun visor), or kept riding and opened the shield. I kept riding and opened the shield. </p>
<p>From my experience coming home from Rolling Thunder I knew what rain felt like on bare skin, and hard rain through leathers, but I'd yet to be smacked in the face by it at speed. Its not fun without goggles, as every time you turn your head to check a cross street, look down to check your speedometer, or look up to read a sign rain blasts into your eyes, and of course you can't close them, you're moving at speed. In addition, simply looking forwards your face is getting smacked by rain... and water at 50mph stings. </p>
<p>After a few miles on the outskirts of the town this shop was in, it started to really suck. The street lights started disappearing, the street moved down to one lane, and my glasses were well and truly soaking wet. My vision was maybe at 100 feet, and for pot holes and debris in the road it was literally when I hit it, I'd know. I basically picked a mini-van, and stayed behind it, following their lights into the darkness. Then we got into tree-lined on both sides, and there was no ambient light, I actually preferred this, as with no cars coming I could actually see! However, with cars coming I was again unable to see anything but the car's headlights. </p>
<p>Around here, sucky turned worse. My engine started sputtering when I'd idle. So the first stop light I pulled up to, I saw my RPMs start dropping, the engine coughed, and she shut off. Not this again. This happened in the rain storm after Rolling Thunder, and the only solution was to keep RPMs up around 5-7k (idle is around 2k). As I'd rev, great spouts of steam would come flying out the front of my bike like a pissed off dragon coming awake (it'd be colored red from the car tail lights in front of me). Naturally this means that to stop I couldn't clutch in, drop to first gear, and brake. I had to clutch in, set my throttle quickly to about 50% and brake (using on the front brake in the water) while holding the throttle in the same hand. <a href="http://www.crampbuster.com/">Cramp Buster</a> saved my life... maybe literally. Oh, and fun fact, if your glasses' lenses are at the temperature of air moving at 30mph, and soaking wet, what happens when you stop at a light? That's right, completely fogged up. One hand on the clutch, one on the throttle/brake... there's no way to take them off and nothing to clean them with if you could.</p>
<p>So the rest of the 30 miles to home is a blur of adrenaline influenced memories of lighting cracking overhead, thunder rolling by (only at stop lights, couldn't hear it as I was moving), pot holes barely avoided and not avoided, shoulders ridden on, medians missed by inches, and me screaming the Dropkick Murphies' version of Amazing Grace into the night. I had two guys try to take me out, one caught himself, the other I had time to avoid.... I'm sure he saw me, simply didn't care. Ate water from a semi cab hitting a pot hole next to me, and nearly caught a deer (it crossed in front of the car behind me).</p>
<p>Most terrifying ride of my life. </p>
<p>But... I'd experienced riding in the rain, so that didn't scare me. I'd experienced what rain feels like on bare skin, so while it stung it didn't phase me past the first 5 minutes. I'd ridding at night and in thunder storms, so those weren't the bits that bugged me. What scared me was not knowing what was more than a second in front of me for more than 90% of that ride, and knowing that if something did come up I had no escape options. Thanks to the practice I forced on myself earlier in my riding career (and someone looking out for me), this situation turned out alright. I made it home within an hour and a half, I didn't hit a single object, and I think my bike isn't very messed up. When I arrived home, I got off the bike, looked up into the sky, and pulled a Shawshank Redemption, amazed and thankful that I was home, and in one piece.</p>
<p>So the next time you think "Gee, I could do X, but its a little not good for it right now" ask yourself if you might ever be caught in the same situation without experiencing it. Then go out and experience it so you can have some control over the circumstances, I'm so thankful I did.</p>
]]></content:encoded>
			<wfw:commentRss>http://thesnarky.com/2009/06/11/practice-pays-off/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing in the Dirt</title>
		<link>http://thesnarky.com/2009/06/06/playing-in-the-dirt/</link>
		<comments>http://thesnarky.com/2009/06/06/playing-in-the-dirt/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 23:56:58 +0000</pubDate>
		<dc:creator>Snarky</dc:creator>
				<category><![CDATA[Motorcycles]]></category>
		<category><![CDATA[Ride Reports]]></category>
		<category><![CDATA[Tina]]></category>

		<guid isPermaLink="false">http://thesnarky.com/?p=366</guid>
		<description><![CDATA[I bought Tina a little less than a month ago, she's my Yamaha XT350 dual sport (also called an enduro) which is a dirt bike that can also be used on the street, depending on what tires you put on.I'm enjoying her aside from two small problems.
The first is she is kick start. Now, this [...]]]></description>
			<content:encoded><![CDATA[<p>I bought Tina a little less than a month ago, she's my Yamaha XT350 dual sport (also called an enduro) which is a dirt bike that can also be used on the street, depending on what tires you put on.I'm enjoying her aside from two small problems.</p>
<p>The first is she is <a href="http://en.wikipedia.org/wiki/Kick_start">kick start</a>. Now, this shouldn't be a shock as she's older than I am, but its different than the electric start I'm used to. Meaning, I actually have to work. For those that have never had the honor of trying to kick start a bike, its all technique, and before you have it down, its all frustration. You sit there and crank, crank, crank, trying to figure out where top dead center is, where the start of the combustion cycle is, and how much gas to feed in. </p>
<p>The other issue is, well... I'm only comfortable on a nice smooth road, perfect riding conditions and not much traffic around. Which leads to at least a small bit of nervousness when you remove any of the above conditions and replace it with something a little worse. Say, rain.... or a poorly paved road... or a dirt track that's NOT a road. When I got my first bike, I had to force myself to get on it... I'd enjoy it when riding, but before hand the idea of cars around me, or learning to turn faster made me not want to ride. So to buy a dirt bike was a promise to myself to suck it up, and try more of riding that scares me. </p>
<p>Naturally with a bike that I have problems starting and not liking to ride on anything worse than, oh, Pennsylvania interstate roads, I decided to go hit up a local rock (too big to call them gravel) road to get some practice. That's the sane thing to do, right?</p>
<p><img src="http://lh6.ggpht.com/_FeJTFvmV4A8/Sir8WshxTaI/AAAAAAAAA6I/mo1EaMv98aw/s512/0606091902a.jpg" alt="" /></p>
<p>Rode down the "road" once, and found a nice paved road on the other side. Figured I might just take that road home, my practice complete. Then I realized that on the 65th anniversary of D-Day, heralding our entry into World War II, I was going to take the cheap and easy way out. After that I had a better idea, I'd ride back up the rock road, STOP (forcing myself to practice breaking on a poor surface), then turn the bike off to take pictures.</p>
<p>With that in mind, I rode back up the road, skirted some water, came to a stop, and flicked the kill switch. I have to say it felt good to know I wasn't going the easy way, and the silence was quite nice. I took 10 minutes to walk around, take some pictures, and enjoy the gorgeous afternoon. Finally I got back on, took a few stabs at starting the bike, got her going, and rolled on home. </p>
<p>Practice makes perfect, and I intend to practice as much as it takes to feel comfortable on the dirt and comfortable starting the bike, even if I'll all alone in the middle of no where.</p>
]]></content:encoded>
			<wfw:commentRss>http://thesnarky.com/2009/06/06/playing-in-the-dirt/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
