Nile Online

Post by: on October 26th, 2010 | Filed Under Game Review, Games

A year ago (roughly) a few friends were talking about another browser-based game (BBG). I asked which it was, and they pointed me at Nile Online. So began a year (roughly) long experiment.

Initial Feelings
At the start I was just looking for a new BBG as I'd ended whatever it was I was playing before. I didn't have an exceptional amount of time for games, so my PS3 wasn't being used that much. A BBG I could play before and after work, just poke in now and then.

The initial appeal for me was (in my opinion) Nile's unique focus. It's somewhat collaborative, based on trading between cities located along the Nile river in Egypt (although you can play without trading) and entirely focused on entombing yourself in the nicest tomb on the Nile. That's it, you're playing to try to kill off your character. That sounded like fun, and a solid end condition compared to the RPGs I normally play.

The first month or so was mainly just a race building up my initial infrastructure. You need to be producing clay, reeds, and wheat so that you can produce bricks, baskets, and bread. Initial building upgrades are on the order of minutes to an hour, so you're just sitting there upgrading and planning. At this point I was just gunning for entombment.

Challenges
One friend was playing based on the One City Challenge, completing the game while building only one (of a possible four) cities. The advantages to multiple cities is you can be creating up to four natural resources for goods, to do it on one city means you have to rely a LOT more on trading and smart worker management.

I did not go that route, as I wanted to finish the game in a decent amount of time. However, as the months wore on, friends started dying off and I realized I was still pressing on. Sometime around the third month my goal switched to being the lowest possible rank when I died off. And that's how I played for the next 8 months.

Strategy
My strategy stayed mostly the same for the game, I had two key changes, however. Initially I was simply trying to bulk up my main city center so I could entomb myself (have to max out one city center to level 22). The other cities, as I founded them, were founded to support my build speed, and ship goods back to the capital to be sold/used in the build process. If you're smart about producing the other luxury goods needed you can keep your capital upgrading constantly without much buying at the market.

This worked for a while, I was constantly dropping ranks and the city center was well on its way to being ready to entomb me. However, when the time came to pull the trigger, I wanted to drop just a few more levels and realized I wasn't sure the best way. That's when I recognized that the average level of your structures in the city is a solid determining factor for rank. So I had a level 22 city center and really low other buildings, which was really hurting my rank.

Therefore, the first change I made was to next focus on building all my buildings up simultaneously. This really sped up my rank dropping, I'd frequently lose 20 or so every update. In fact, it worked awesomely until around rank 200. I probably spent two months trying to get from 200 down below 100. Why? Because of the other caveat to ranking, "average rank of buildings and total resources on hand."

*THWAP*

So while I had four fairly done cities, I couldn't get anywhere on rankings because my stockpiles were empty! This was my second tactic shift, going from a race to build, to a race to build and squirrel away. I kept upgrading anything that I could, but also started buying massive amounts of anything I didn't produce natively. I maxed out my bread (used as currency) production in every city and simply bought all the time. This helped a lot, although ranking up was still slow as I had to spend bread to get other goods, and I'd spend some time building my stores back up before I could gain any ground in the rankings.

Conclusion
Finally I reached my (new) goal: Entomb myself under level 100. Specifically, I made it to 99 after 68 'years' in game. I could have done that better if I'd focused more on stockpiling the entire game, but hey, live and learn. Fun game, worth a peek if you only want to devote a few minutes spread out through the day.

Comments (No responses yet)

Diamond in the Rough – Part 2

Post by: on August 5th, 2010 | Filed Under Firearms, Gun smithing

(Part 2 of the Diamond in the Rough series, cleaning the SKS)

Where to begin?
Now that I had an idea of what it was, I decided to start cleaning. I had no idea where to begin, there was grease covering every surface, so I started by tearing it down according to field stripping, and wiping grease off the bits as I got them out.

First I found the accessory compartment in the stock, almost stuck closed from gunk. Pushing in yielded the cleaning kit... soaked in grease, it literally came out brown. I wiped it down, pulled the jag, brush, and tap out... in one bunch! They were stuck together! Wiped the outside down, and got this shot.

I soaked them for a while in hot water and after a little scrubbing all the grease was off.

Then came the really icky part, stripping the whole thing down. I wanted everything apart before I could clean each part individually and put it back together perfectly clean.

First you have to remove receiver cover and recoil spring assembly:

Then you remove the handguard/gas tube (make sure NOT to rotate the takedown lever too much, and/or watch your eyes.. you have been warned):

After this you pull out the bolt/bolt carrier, gas piston, and set them aside. At the end of the first day I had this (a stock with a trigger):

On day two I wasn't as interested in photographing everything, as my hands were icky all day from grease and solvent. But essentially what happened is I gave everything I'd taken out a THOROUGH cleaning, then popped out the trigger group and receiver, and cleaned the stock. Finally it was time for the barrel and bayonet, both much easier than the stock as I could simply use a strong solvent and some scrubbing.

At the end of the second day I had this (a sparkling clean gun!):

I had a lot of issues with the magazine, hence my not speaking of it. It seems like someone before me took it and either put the wrong follower (the bit the bullets ride up on) in, or intentionally bent the top of the magazine. it never, ever, ever fed properly, not one round. Jammed every time. As such, it still sits next to me in abject failure, until such time as I deem it worthy to try to fix. After replacing the magazine, she shot beautifully.

What's the take away from all this?

First off, if you're going to start a blog series, make sure to finish it!

Secondly, old guns can be great finds, both in terms of fun to shoot, and in terms of history (I found this Type 56 to be really cool).

Third, gun shows are great places to pick up decent deals. This should have been $75 10 years ago, but I'm happy with what I paid considering the current gun economy. I spent just about nothing cleaning it, was able to make it look incredibly better. Don't be scared of the ugly!

(Oh, and my brother really liked it, which was the important part. It looked like a different rifle!)

Comments (No responses yet)

Communist Sci-Fi GTA

Post by: on May 23rd, 2010 | Filed Under Game Review, Games, PS3

It's been a while since I posted a game review, partially due to life catching up with me, and partially sticking with some old favorites on the PS3. Then two weeks ago I got Red Faction: Guerrilla used from Gamefly for $5 after some rebates. I'll pay $5 to try a game, not too worried about wasting that money, especially when the online media made it look fairly yummy.

The Premise
So what's it all about? If I had to summarize the game in three words or less it'd be: "Communist Sci-fi GTA".Yes, I cheated by using some abbreviations, but still, that sums it up quite nicely. The game starts out with you meeting your brother on Mars, sometime in the not so close future. Mars has been colonized by Earth, and is controlled by a military group named the Earth Defense Force (EDF). They maintain control and security because at this point in the future we've ravaged Earth's resources, and we have to get our metals from Mars.

Of course, the game wouldn't have a plot without strife, and naturally the EDF has taken a turn for the totalitarian regime. This regime manifests itself in the typical ways, forcing workers to work long hours, illegal search and seizure, and, of course, executions. Naturally this angers you in the bottom of your 'just wanted to come and earn a living' soul, and you join up with the Red Faction. Red Faction being the stereotypical worker uprising, complete with pick-up trucks for APCs, mining tools for weapons, and cheesy lines on the underground radio broadcasts designed to uplift the huddled masses.

The Game
Enough about the background, you'll learn all that and more in the opening cut-scene, how's the game play? I liked it... a lot. I'd even go so far as to say I loved it, if in a guilty-pleasure kinda way.

Controls
The controls were for the most part intuitive and par for the course for a PS3 game. A few tidbits caught me, such as having a more accurate look at your targeting reticle be a toggle, rather than just a mode you'll drop out of after releasing the button. My biggest concern was the variance found amongst vehicle controls. In a normal car R2 goes forwards and L2 goes backwards (mostly). If you get into a car with a turret and shoot, it'll track to the nearest enemy... sorta. But, let's say you get into a tank? Now left thumb stick moves you forwards and backwards, right thumbstick is turret control, and you shoot with L1/R1. Oh, you're in a walker? Well if it has jump packs you'll be using the X button, though if it has rockets those will be L1/L2... ARG!

A unified control scheme there is not! Thankfully, the 3rd person perspective was as I'd expect, and most ordinary vehicles behaved correctly, most of the time.

Physics
In a word, "fun". If I got two, perhaps "non-so realistic," but I'll stick with "fun". This game uses the Havok engine, which allows for a lot of fun stuff, such as an almost completely destructible environment. You can't impact the ground, but just about every building, vehicle, and sign can and will go kerblooey if met with sufficient force.

The buildings react fairly correctly, as far as I'd know having never taken down a building using det mines and a well placed dump truck. They teach you throughout the game how to take down buildings using more and more elaborate means, but basically if you find a building supported by anything, take out the anything and it'll crash down. They crash in the direction of the supports you removed, and if you're quick enough it'll come straight down.

Vehicle physics... not so good. Throughout the game I had issues with vehicles. I couldn't figure out why, but backing up in a car seemed it or miss. I always had to gas it a little forwards, then switch into reverse to get moving! Plus, you can climb many, many surfaces that you shouldn't be able to... things that are 75% grades that let you drive up them, for instance. Sure, "it's Mars" but still, all you ever had to do if you were stuck, was turn your tires slightly, and hit the gas. This technique, plus a dump truck, levels most buildings in fairly short order. Further, there were times I'd somehow ramp a vehicle over a small bump and find myself achieving darn near escape velocity, in my opinion. That said, it was awesome the time it happened on my way into an EDF camp and I smashed through a few buildings before coming to rest.

Overall, the physics were fun, and I'd say the quirks actually added to the fun, rather than detracting from it.

Environment
The graphics weren't at the level of some games that can, say, load a new level before you drive across a continent, but they were quite good considering some of the vistas you can look at. Mars is fairly well done, lots of red, lots of dust, and, uh, somehow a breathable atmosphere. You can even stumble across the Mars rover if you go hunting for ore deposits, and no... it's not destructible :( .

The buildings are not very varied. After you destroy 5-10, you'll know exactly how to take them down in 30 seconds or less.

Plot
The plot was kind of a typical Sci-Fi deal... you have colonists, oppressive military, easily predictable twists, but enjoyable overall.

Combat
Combat I'm torn on. On the one hand it was fun once you started building up a repertoire of weapons. My typical load out for most of the game was my sledgehammer, det mines, grenade launcher, and an assault rifle. That let me deal with infantry (rifle/sledge, and yes, you'll use the sledge the entire game, and no, it never gets old), armor (mines/grenades), buildings (see previous), and buildings (all of the above). The controls for combat made sense, although felt a little simplistic coming from a lot of Call of Duty: Modern Warfare 2.

My big issue was the difficulty. I played through on 'Normal', but even then I was dying a... freaking... lot. What's more, I got the feeling the game was designed that way, as the death penalty was measly in my opinion. Not that I'm bothered by frequent deaths, but when the loading times after a death were 30 seconds or a minute, I'd keep a book on my table just in case.

And the last level? Let me just say this flat out: Take your time, do it right, it's designed to kill you.

Missions
One of the game's strong points to me. There are a few main types of missions (Raids, Defense, Convoys, Couriers, and Heavy Metal). Heavy Metal was my favorite, and a great example of the diversity in the game. The basis is just "Kill X amount of Y EDF," where X is a number between 25 and 150, and Y is a vehicle or soldier. Sounds simple, but every one is different. In one you get a rocket turret, in another a tank, in a third a combat walker. They never get old. The same holds for raids, where you go in to either blow up a building or kill all defenders so they can blow it up. In some missions you'll hit an office building, or maybe a garage, or maybe a warehouse type building. Bottom line is while, yes, you can easily solve them all with one well placed theremobolic rocket, you'll need to adapt to the situation as you reach it.

Overall
Overall I'd recommend the game off of Gamefly or used. I'll probably keep playing through (after beating the game they unlock a harder difficulty, and reopen all the missions to replay), so I'm glad to have my own copy. I can easily see this game becoming repetitive to some, and others getting annoyed at the vehicles and their controls, so maybe don't buy it right off.

There's a lot I didn't touch on for brevity's sake, and I need sleep. Salvage that you blow stuff up to get to upgrade your gear for instance. But then, some needs to be left up to the reader to find out.

Oh, and if you're looking for a multiplayer game, keep looking. I've spent a full two minutes in the lobby queue without enough people to start a game.

Comments (2 responses so far)

Ray Casting in Scheme

Post by: on February 23rd, 2010 | Filed Under Games, Programming, Scheme

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 (output and reading user input).

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 Harkins wrote last year for Ruby (when I had aspirations of learning another language), and read up on Rogue Basin for various examples. In the end I stole Harkin's map, and went with the pseudo code Elig created here.

Without further ado, the code busted apart into a few sections. (Full version can be found here).

 
;;Scheme ray casting/FOV demo
;;Adapted from pseudo code found at
;;http://roguebasin.roguelikedevelopment.org/index.php?title=Eligloscode
 
;;Prep work for 7DLR 2010 (to brush back up on my Scheme)
 
 
;;Global defines
(define char-x 1) ;;x coordinate for the fake character
(define char-y 1) ;;y coordinate for the fake character
(define VIEW-RADIUS 3) ;;View radius for FOV demo
 
;;List of tiles we don't want to walk through (Walls and water)
(define IMPASSABLE-TILES (list #\# #\~)) 
;;List of tiles that will break the ray casting (walls)
(define OPAQUE-TILES (list #\#)) 
 
(define test-env (list
                    "###################"
                    "#...#.............#"
                    "#...#...#~~~~~....#"
                    "#.......#~~~~~....#"
                    "###################"))
 

First I set up some variables to work with.

 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;Functions to create the environment;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
;;Function to create our working environment given an array of strings such as test-env
(define create-env
    (lambda (env)
        (if (null? env)
            '()
            (cons (create-env-row (string->list (car env))) (create-env (cdr env))))))
 
;;Function that helps create-env by creating a given row
(define create-env-row
    (lambda (env-row)
        (if (null? env-row)
            '()
            (cons (create-env-cell (car env-row)) (create-env-row (cdr env-row))))))
 
;;Function to create a given env cell, helps create-env-row
(define create-env-cell
    (lambda (env-cell)
        (list env-cell #f)))
 

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).

 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;Functions to display the environment;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
;;Function to write the env
(define write-env
    (lambda (env)
        (write-env-help env 0 0)))
 
;;Function that does the brunt of the env write
(define write-env-help
    (lambda (env x y)
        (if (null? env)
            (newline)
            (begin
                (write-env-row (car env) x y)
                (write-env-help (cdr env) x (+ y 1))))))
 
;;Function that writes a given row of the env
(define write-env-row
    (lambda (env-row x y)
        (if (null? env-row)
            (newline)
            (begin
                (write-env-cell (car env-row) x y)
                (write-env-row (cdr env-row) (+ x 1) y)))))
 
;;Function that writes out a given cell of the env
(define write-env-cell
    (lambda (env-cell x y)
        (let ((char (car env-cell)) ;;The symbol we'll possibly display
              ;;The boolean bit of the env cell that holds if its visible or not
              (visible (cadr env-cell))) 
            (if visible ;;If this cell was marked to be seen
                (if (and (= x char-x) (= y char-y)) ;;Check if its where the character is
                    (print "@") ;;If so, lets show an @ symbol
                    (print char)) ;;Else show whatever character should be displayed
                (print " ")) ;;If this cell wasn't marked to be shown, just put a space
            (print " ")))) ;;Put a space after it for pretty printing
 

Naturally you need some way to nicely see what's going on in your environment. That's what these functions do.

 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;Functions for the FOV demo;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
;;Function to update the FOV as a whole
(define update-fov
    (lambda (env char-x char-y)
        (update-fov-help env char-x char-y 0 0)))
 
;;Function that does the actual work of updating the FOV
(define update-fov-help
    (lambda (env char-x char-y x y)
        (if (not (null? env))
            (begin
                (update-fov-row (car env) char-x char-y x y)
                (update-fov-help (cdr env) char-x char-y x (+ y 1))))))
 
;;Function that updates the FOV for a given row
(define update-fov-row
    (lambda (env-row char-x char-y x y)
        (if (not (null? env-row))
            (begin
                (update-fov-cell (car env-row) char-x char-y x y)
                (update-fov-row (cdr env-row) char-x char-y (+ x 1) y)))))
 
;;Function that does the real work to update a given cell's FOV
(define update-fov-cell
    (lambda (env-cell char-x char-y x y)
        (set-cell-visible env-cell #f) ;;Set visible to false
        (let* ((dx (- x char-x))
               (dy (- y char-y))
               ;;Get the distance between the character and the cell
               (distance (sqrt (+ (* dx dx) (* dy dy))))) 
            (if (< distance VIEW-RADIUS) ;;If we're within out viewing radius
                (set-cell-visible env-cell #t))))) ;;set the cell to be shown
 

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.

 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;Function for the Ray casting demo;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
;;Function to clear the entire env
(define clear-cells
    (lambda (env)
        (if (not (null? env))
            (begin
                (clear-cells-row (car env))
                (clear-cells (cdr env))))))
 
;;Function that clears a row of the env
(define clear-cells-row
    (lambda (env-row)
        (if (not (null? env-row))
            (begin
                (clear-cells-cell (car env-row))
                (clear-cells-row (cdr env-row))))))
 
;;Function to clear a cell in the env
(define clear-cells-cell
    (lambda (env-cell)
        (set-cell-visible env-cell #f)))
 
;;Function to do the ray-cast
(define cast-rays
    (lambda (env char-x char-y)
        (clear-cells env) ;;Clear everything first
        (cast-rays-help env char-x char-y 0)))
 
;;Function to do the real work of casting some rays
(define cast-rays-help
    (lambda (env char-x char-y i)
        (if (<= i 360)
            (let ((x (cos (* i 0.01745)))
                  (y (sin (* i 0.01745))))
                  (trace-ray env char-x char-y x y (+ char-x .0) (+ char-y .0) 0)
                  (cast-rays-help env char-x char-y (+ i 16))))))
 
;;Function to trace the specific ray to its end
(define trace-ray
    (lambda (env char-x char-y x y dx dy i)
        (if (not (> i VIEW-RADIUS))
            (let* ((cell-x (round dx))
                   (cell-y (round dy))
                   (cell (get-cell env cell-x cell-y)))
                (if cell
                    (begin
                        (set-cell-visible cell #t)
                        (if (cell-opaque? cell)
                            (trace-ray env char-x char-y x y (+ dx x) (+ dy y) (+ i 1)))))))))
 
 

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.

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.

 
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;Random helper functions;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
;;Function to get a given cell
(define get-cell
    (lambda (env x y)
        (get-cell-help env x y 0)))
 
;;Function does most of the real work to get a given cell
(define get-cell-help
    (lambda (env new-x new-y y)
        (if (not (null? env))
            (if (= y new-y)
                (get-cell-x (car env) new-x new-y 0)
                (get-cell-help (cdr env) new-x new-y (+ y 1)))
            #f)))
 
;;Final helper to get a given cell
(define get-cell-x
    (lambda (env-row new-x new-y x)
        (if (not (null? env-row))
            (if (= x new-x)
                (car env-row)
                (get-cell-x (cdr env-row) new-x new-y (+ x 1)))
            #f)))
 
;;Function to tell if a cell is passable
(define cell-passable?
    (lambda (cell)
         ;;Check to see if symbol is in our list of impassable tiles
        (not (member (car cell) IMPASSABLE-TILES)))) 
 
;;Function to tell if a cell is opaque
(define cell-opaque?
    (lambda (cell)
        ;;Check to see if symbol is in our list of opaque tiles
        (not (member (car cell) OPAQUE-TILES)))) 
 
;;Function to 'move' our 'character' to another cell
(define move-to
    (lambda (env x y)
        (if (cell-passable? (get-cell env x y)) ;;Check to make sure they can move there
            (begin
                (set! char-x x) ;;'Move' them by changing our global vars
                (set! char-y y)))))
 
;;Function to set a given cell's visibility to the given boolean
(define set-cell-visible
    (lambda (cell bool)
        (set-cdr! cell (list bool))))
 

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.

 
;;;;;;;;;;;;;
;;Test code;;
;;;;;;;;;;;;;
 
;;Setup the environment
(define our-env (create-env test-env))
 
;;Run the fov-demo
(define fov-demo
    (lambda (env)
        (print "FOV demo, use h, j, k, and l to move, q to quit\n")
        (update-fov our-env char-x char-y)
        (write-env our-env)
        (let read-loop ((x (read-char)))
            (if (not (or (char=? x #\q) (char=? x #\newline)))
                (begin
                    (case x
                        [(#\l) (let ((new-x (+ char-x 1))
                                     (new-y char-y))
                                    (move-to our-env new-x new-y))]
                        [(#\k) (let ((new-x char-x)
                                     (new-y (- char-y 1)))
                                    (move-to our-env new-x new-y))]
                        [(#\j) (let ((new-x char-x)
                                     (new-y (+ char-y 1)))
                                    (move-to our-env new-x new-y))]
                        [(#\h) (let ((new-x (- char-x 1))
                                     (new-y char-y))
                                    (move-to our-env new-x new-y))])
                    (update-fov our-env char-x char-y)
                    (write-env our-env)
                    (read-loop (read-char)))
                (case x
                    [(#\q) (print "--End of FOV Demo--\n")]
                    [(#\newline) (read-loop (read-char))])))))
 
 
;;Run the ray-casting-demo
(define ray-casting-demo
    (lambda (env)
        (print "Ray casting demo, use h, j, k, and l to move, q to quit\n")
        (cast-rays our-env char-x char-y)
        (write-env our-env)
        (let read-loop ((x (read-char)))
            (if (not (or (char=? x #\q) (char=? x #\newline)))
                (begin
                    (case x
                        [(#\l) (let ((new-x (+ char-x 1))
                                     (new-y char-y))
                                    (move-to our-env new-x new-y))]
                        [(#\k) (let ((new-x char-x)
                                     (new-y (- char-y 1)))
                                    (move-to our-env new-x new-y))]
                        [(#\j) (let ((new-x char-x)
                                     (new-y (+ char-y 1)))
                                    (move-to our-env new-x new-y))]
                        [(#\h) (let ((new-x (- char-x 1))
                                     (new-y char-y))
                                    (move-to our-env new-x new-y))])
                    (cast-rays our-env char-x char-y)
                    (write-env our-env)
                    (read-loop (read-char)))
                (case x ;;Enter or q was pressed
                    [(#\q) (print "--End of Ray casting demo--\n")] ;;If q, lets quit
                    ;;If enter just read the next char, it happens
                    [(#\newline) (read-loop (read-char))]))))) 
 
;;Run our demos
(fov-demo our-env)
(ray-casting-demo our-env)
 

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.

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.

Hope that's commented well enough in the code. Enjoy!

Comments (No responses yet)

(library 7DRL (import (rnrs))

Post by: on February 23rd, 2010 | Filed Under Games, Programming, Scheme

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 in the same IRC channel Scheme came up.

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.

Flavors

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 Mit-Scheme, Chez Scheme, PLT Scheme (Dr Scheme), Tiny Scheme, and Gambit. These can all be installed under Linux (fairly) easily, and all have upsides and downsides.

  • 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.
  • Chez Scheme - What my school used primarily. Has a copy of the Scheme Programming Language Version 4 free on their site which is a big plus. They support all three major OS's and include an RPM/instructions for Debian installation.
  • 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.
  • 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.
  • 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) here. 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.

Gambit

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:

 
;;Hello World example for Gambit/NCurses
 
;;Include our headers
(c-declare "#include <ncurses.h>")
 
;;Define the function
(define hello-world
    ;;C lambda performs c commands, this is a basic ncurses
    ;;example that inits the screen, prints our string, waits 
    ;;for input so it stays on the screen, and then kills the window
    (c-lambda () int "initscr(); printw(\"Hello World\"); refresh(); getch(); endwin();" ))
 
;;Gotta remember to call it!
(hello-world)
 

Now link, compile, and run it:

snarky@Reaper$ gsc -link ncurses.scm
snarky@Reaper$ gcc ncurses_.c ncurses.c -lgambc -lncurses -o ncurses
snarky@Reaper$ ./ncurses
Hello World

(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)

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.

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 manual if you're at all interested.

Gotchas

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:

snarky@Reaper$ gsc -link file.scm
snarky@Reaper$ gcc file_.c file.c -lgambc

I very quickly just made a make file to handle it to simply forget about what steps go into it.

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:

For the interpreter:

snarky@Reaper$ gsi -:s

And for the compiler:

snarky@Reaper$ gsc -:s -link file.scm

OR

snarky@Reaper$ gsc -link -e '(load "/usr/local/Gambit-C/lib/syntax-case.scm")' file.scm

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.

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.

Comments (One response so far)

Pretty Things are Dangerous

Post by: on October 24th, 2009 | Filed Under Motorcycles

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).

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.

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.

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.

Ride to live, period.

Comments (No responses yet)

Diamond in the Rough – Part 1

Post by: on September 3rd, 2009 | Filed Under Firearms, Gun smithing

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 (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.

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.

What is it?

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:

Receiver/Trigger Group: K4992 (with a marker's mark of '26' inside of a triangle)
Stock: 33616
Bolt carrier: 05676
Bolt: 35505
Barrel: (Odd character) 3276

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: Yooper John's SKS information.

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.

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).

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.

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.

Next up, cleaning!

Comments (One response so far)

Ghandi on Firearms

Post by: on August 3rd, 2009 | Filed Under Firearms, Real Life Rights

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 this book, nice and concise with the full majority and dissenting opinions.

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.

The first is Ghandi, in his autobiography:

"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)

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.

The second is another bastion of peacefulness, the 14th Dalai Lama, Tenzin Gyatso:

"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." (Seattle Times, May 15, 2001)

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.

Amazing how even those who choose non-violence recognize the inherent need for weapons in our culture.

Comments (No responses yet)

First Blood!

Post by: on July 24th, 2009 | Filed Under Firearms, Interests

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 the optics and bipod, in favor of good old iron sights (Yankee Hill 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).

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.

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.

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.

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.

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.

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.

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.

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.

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!

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.

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.

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!

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.

I'd embellish more, and add some pictures, but Firefox keeps crashing so I'll just hit publish.

Comments (No responses yet)

Ruger 10/22

Post by: on July 7th, 2009 | Filed Under Firearms, Real Life Rights

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.

"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.

5 months ago I was looking at building a second AR-15 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 Bass Pro Shops 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).

The man helping me said that Ruger had good stuff, and the 10/22 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.

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.

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.

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).

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).

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.

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.

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).

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.

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.

Comments (No responses yet)