Phoning it in 2: Special Edition

April 23, 2008

Still snowed under, so here’s today’s Hober: Raph Koster and the future of gaming.

Also, something that’s been on my mind. I can’t think of any good way to turn it in to blog post, since to do it justice would need real psychology. But, here it is: experts rush in to criticize addiction to massively multiplayer online games, which almost by definition require social interaction, bonding, and community interaction. What if instead, it’s the 21st Century’s version of the concept of the Third Place, which is roundly agreed to be, in fact, beneficial?


Phoning it in

April 21, 2008

It’s Dead Week, and you know what that means: re-runs.

Here: Music in Video Games.

(Dead Week is the week before exams when it’s supposed to be quiet — “dead” — so you can finish term papers and projects. Half the professors take it as an opportunity to kill you with work.)


Calculated Response, Part 3

April 18, 2008

Almost a year ago, while my blog was still in its infancy, I issued an indictment against the responses I saw to what happened at Virginia Tech that past week. Now that we’ve gained some perspective on the event, I don’t think much has changed. Now, in some ways, those earlier words are dated. Fred Thompson had his shot at the Presidency, and it didn’t happen. Life goes on.

However, the above-documented response was echoed once again in the latest incident of college violence. This time, it was only one girl, Eve Carson. However, if anything, having one person as the focal point for all the attention makes her easier to rally around than a number of people who all might have done great things, but won’t.

Over the past weeks, I’ve variously been asked to “wear Carolina blue to honor Eve Carson’s memory” and to do likewise to, I am not making this up, “take a stand”. The first request is a manifold problem, given that not only do I have no Carolina blue clothing, but I have no memories of Eve Carson. The second request is so patently ridiculous that it’s probably best responded to in my father’s words: “Oh, yeah, the criminals will really think twice when they know you’ll change your wardrobe in response to violence.”

On the other hand, I’d like to think that I’m taking a stand, here, in these pages, especially with these more seriously-toned essays. But I’ve never taken a stand in any local public forum, because I don’t think it’ll do much good. Take the local student newspaper, for example. Following Eve Carson’s death, they printed a sidebar that listed a student’s options for self-defense on campus, which pretty much extend to folding batons and no further. I’m sure they thought they were helping the community, but they were also providing authoritative documentation for anyone who wanted on exactly how defenseless students are on campus.

So why don’t I write them a letter to the editor? Maybe even a guest editorial? Because it wouldn’t actually change anything. There is a mindset, a way of not just thinking, but living, where the best response to a criminal with a gun is to have a moment of silence. This is a mindset that casts aside actually effective solutions in favor of things that are easily accomplished and instill a sense of piousness.

You can’t change a mindset with a letter. On the other hand, I do what I can to advocate for calculated responses in long-term discussions that have the potential to shift one’s mindset, such as the Society meetings I attend whenever possible. I’m not sure if I’ll ever actually win any of them over to my way of thinking, but at least I can make them consider it.

And maybe one day, they too will be disappointed in the fact that the best that college can do to try and secure their campus is to increase police patrols. Maybe we should let people protect themselves, instead?


How to learn to play guitar (or, how I learned to play guitar)

April 16, 2008

“Awwwright, man! You totally nailed that Dragonforce guitar solo and five-starred that song. You finally beat Guitar Hero, which means it’s time to get a real six string!”

Sound daunting and expensive? Well, it is. But the good news is that in six years, when your XBox 360 is obsolete garbage, your then-very beat up guitar will still be quite serviceable. Assuming you have good strings to play it on, and some picks left, and haven’t blown out your amp at the time. But that’s really getting ahead of the game.

The first step to learning to play guitar is to upgrade the locks on your door. Once you start ripping out mad riffs, the babes are going to begin attempting to force entry into your Place of Rock (PoR). Unfortunately, the only state that allows the use of lethal force to protect yourself in such a situation is Texas, under their castle doctrine. And, if you weren’t aware before, if your music is “killer” as in “coroner”, you’re doing something wrong. Opening fire on fans is always wrong.

The next step is to decide who you like more: Gibson or Fender; this will determine which brand of guitar’s cheaper version you get. For Gibson, you’re looking at Epiphone, for Fender, head on over to Lenovo.

But what about actually choosing between the two of them? I mean, Hendrix played a Fender Strat, but that short dude in AC/DC plays a Gibson SG. Well, there’s your answer. If you want to live to a ripe old age and enjoy your money like AC/DC, then get a Gibson. Otherwise, go with the Fender. It worked for Kurt Cobain.

Depending on how much you want to pay and the quality of guitar you want, you’ll next need to figure out where you are on the value-crappiness curve. If you’re looking for a crappy guitar and want to pay nothing for it, start hitting up your buddies, to see if they have one sitting, gathering dust in a closet. If you’re lucky, some other gamer-turned-rockstar has already given up the dream so he can five-star Green Grass and High Tides on Expert (good luck!), meaning you can probably swipe his axe without him so much as knowing.

Otherwise, try hitting up specialty music boutique shops. This is important because, unless they are owned by the RIAA, they will let you try the goods before you pay for them. This leads us the next problem: putting the f***ing thing on.

Yes, the strap will become tangled. No, don’t mess with it, just try and act cool. Eventually, roadies will deal with this crap while you eat out of your bowl of brown M&Ms. Now, you’ll notice something immediately: it feels like you have a very large skillet strapped to your body. This is natural. While it may look cool from ten feet away on some other dude, when it’s actually occupying the space normally reserved for your fanny pack, it’ll seem kind of like grappling a hovercraft. (Unless of course you are grappling a hovercraft, or you’ve accidentally picked up a steel guitar, in which case you actually do have a very large skillet strapped to your body.)

Now comes the fun part. As a way to implement a backdoor licensing program to use guitars, the government has mandated that all guitars that you pick up will have unlabeled knobs. Just turn them all to ten and see what happens. But first, make sure to turn the knob on the amp labeled “Metallica” to ten as well.

However, now you’re really in a pickle. You really need to play something or risk looking like Former President of the United States Jimmy Carter being attacked by a “swamp rabbit”, but you have no idea to play a guitar. You could either pick blindly at the strings and hope something cool comes out (which, given the four thousand possible frettings on a standard guitar, is statistically unlikely), or just play Smoke on the Water by Deep Purple. It’s the middle two strings. Start playing and you’ll see what I mean.

The downside to this, of course, is that by doing so, you will piss off not only everyone in the store, but the owner too. Of course, you should always be sure to obey any signs he’s posted such as “No Stairway” or “No Smoking”. If you see the latter sign, it means he’s had it with Deep Purple and will likely treat you like Pete Townshend did his guitars. (You know, the ones they glued back together after a show so he could smash them again the next night.)

And now that you’re in the ambulance after insisting that it wasn’t legally justified for him to beat you up for playing three chords (it is, read the Patriot Act), you should really consider the fact that you’re still medically uninsured.

And once you’re out of surgery, if you wish to remain that way, under no circumstances inquire of your doctor, “Can I play the guitar anymore?”


Sieve of Eratosthenes in Python

April 15, 2008

Okay, today’s is gonna be a quick one. It’s the Sieve of Eratosthenes in a relatively straightforward way, in Python.

This is actually relatively typical of my usage of Python. It’s not terribly efficient, computationally, since it searches through list many, many times. It’d be relatively easy to use more lines and make the algorithm even more efficient, but that would require more effort and (more importantly) more lines of code. Part of the beauty of Python is its simplicity and conciseness.

def sieve(max):
	#Takes in a number, and returns all primes between 2 and that number

	#Start with all of the numbers
	primes = range(2,max+1)
	#Start running through each number
	for i in primes:
		#Start with double the number, and
		j = 2
		#remove all multiples
		while i * j <= primes[-1]:
			#As long as the current multiple of the number
			#is less than than the last element in the list
			#If the multiple is in the list, take it out
			if i * j in primes:
				primes.remove(i*j)
			j += 1
	return primes

You’d probably be well-served grokking the process, if you haven’t already. To quote my father, “Everyone should understand the Sieve of Eratosthenes.” Plus you’ll probably see it again soon. Next week will probably be the Sieve in one line, thanks to Python. It’s pretty fancy.


More like “Economics Online”

April 14, 2008

Ever since I stopped playing World of Warcraft a few weeks after I got to college (some correlation there), I’ve been meandering from game to game. I suppose this is how most gamers are, but spending “only” a month or so on any given game seems short after you play one game for two or three years. Now, I played other games, of course, but the mainstream of my time was WoW.

I’ve gone through all of Valve Software’s catalog, especially the Orange Box, as well as Call of Duty 4 and BioShock and the excellent Half Life 2 mod Insurgency. But in the last week I’ve become utterly charmed by a new and different massively multiplayer game, EVE Online.

This is a space-based game where you fly around in a galaxy of some five thousand solar systems populated by five races. Some parts are patrolled by the galactic police, but the vast majority is a sort of lawless waste where the corporation that owns the space makes the rules.

By objective criteria, this is a role-playing game: you start off in a small ship with few skills, and spend time improving your ship, skills, and wealth, usually forming alliances and performing tasks for others. In this particular capacity, it’s mediocre, really. The quests are unoriginal and at times far above or below your level ability.

But where EVE shines is the economy. Where, in WoW, the best way to get magical items was to kill computer-controlled monsters, here it’s a matter of buying them. Well, not magic items, but really cool ships and weapons and so forth. But who do you buy a battlecruiser from? Well, a shipmaker of course. And the shipmaker builds it with materials he buys from a miner and using blueprints he buys from a printer. And the miner takes the money he gets from the sale and buys a bigger mining ship, or a better mining laser. And it just keeps going.

And for those of us that are recreational economists, this is all very fascinating. Which is why the developers of the game ended up hiring an Economics Professor to act as the EVE Economist, who now puts out quarterly financial reports, tracking things like galactic deflation despite an increasing money supply and trying to come up with a good representative statistic similar to GDP. There also seems to be a custom that the last three or four pages be dedicated to all kinds of wacky graphs, which are always fun to look at.

Similarly, there are plans in the works for a galactic election of a nine players to form the Council of Stellar Management that will act as advisors to the developers on the issues most pressing to the playerbase.

It’s been said before that directly competing with WoW is almost impossible, and the developers of EVE aren’t even trying. They’re taking a completely different route that has me completely suckered in.


Local Politics

April 11, 2008

The debate over gun control is taking place, right in my own back yard. For the past week, not a day has gone by that the day’s issue of The Technician hasn’t included arguments pertaining to the the ban of firearms on campus.

I guess it really started even longer than a week ago, when a few letters to the editor, printed in the Campus Forum section, started to bring some attention to the issue, and gained a few responses. But the reaction was rather minimal.

However, after last Friday, matters became somewhat less simple. In that issue, two articles on the topic were published, as I detailed: a balanced article discussing the formation of the campus chapter of Students for Concealed Carry on Campus and an editorial lambasting the idea with frankly unoriginal and trite arguments.

And so it’s been, back and forth, each day bringing more articles and letters in the paper, until today I found it amazingly devoid of any commentary on the subject. It’s a been a fun ride so far, and I don’t think it’ll be over just yet. I know that I personally am planning to research the claims of a staff columnist who is currently punctuating the debate with his article stating, essentially, that statistics are meaningless in this argument.

It’s been a good run, though, because the arguments so far seem to closely mirror the debate as I’ve seen it played out elsewhere.

  • 2 April: Fairly straightforward coverage of the argument in favor of concealed carry. Includes mention of Appalachian Law School shooting where students who retrieved guns from their cars stopped a shooter.
  • 3 April: A letter commending the previous day’s letter and stating quite plainly that if you would like to rely on the police to protect you, that’s your choice, but the author would like to be able to choose to protect herself.
  • 4 April (the day of the SCCC article): Author expresses sympathy for people who feel threatened and think they have to carry a concealed weapon. Recommends that police are sufficient protection and that “justice” should be left in their hands.
  • 7 April: Four letters all taking the editor to task for being alarmist and biased. Perhaps favorite part of the whole debate: “People who are actually mentally stable will not only have a way of protecting themselves, but also will be the ‘first responders’ in the growing fad of mass murders on college campuses. I read where one student said it would be ‘frightening’ to know that people were walking around with concealed firearms. My first thought upon reading that was that the scariest horror movies are ones where the victims have no way of defending themselves.”
  • 8 April: One author states that pepper spray is an adequate compromise between guns and defenselessness. Another takes the editorial cartoonist to task for his portrayal of a 7-person shootout in the library, given that only 1 in 100 people are licensed for concealed carry.
  • 9 April: Police are good enough protection and carrying a gun around on campus is “not necessary.” Concludes with, “Your job as a student at State is to get an education. If you want to protect campus, join the police force.”
  • 10 April: One author: we wouldn’t need guns if we were all just better people. Another praises the methodology of an article presenting research and studies to back up its claims. A third defines and invalidates two logical fallacies being used in the argument against concealed carry.

Summarized this way, we start to see trends. The argument against is based on relying on the police, while the argument in favor is largely just asking for the option to protect oneself. As I said, relatively consistent with the real world.


Priorities

April 9, 2008

At my place of employment, I recently had to blow the dust off of about 900 lines of Python code I wrote for one-time use (so that I can use it a second time). Joking aside, the process has actually been both cathartic and frustrating. See, the code was built to run once, not to be pretty or maintainable or particularly efficient. (Quote from my boss: “As long as your machine doesn’t smoke, it is not a bad idea to start [the program] up at the end of the day and let it run.”)

But on a geek level, the same geek level that wanted to implement yesterday’s quicksort three ways for kicks, I want the code to be clean. Six different classes all read in file data in mostly the same way; it would be possible to use inheritance to remove the file I/O code that I copied and pasted from one class to another, which would probably reduce the whole project by 100-200 lines.

But it’s really not necessary. The code runs, and the file reading is so dead simple that it will never need to be changed (hah!), and so I never get around to it. In short, to quote myself in a message back to my boss, “It’s kind of embarrasing to see how little best-practices code I used. I might rewrite this on personal time, just as a mental exercise in remembering what fast-and-dirty code looks like and how to avoid it.”

Now, make no mistake, the indication of willingness to do this in off-time makes clear that this is simply trying to write beautiful code. However, I can’t help be reminded of this ordeal when I read this:

Busy Productive
Rolls their own Uses someone else’s
Makes it “elegant” and “extensible” Makes it work
Responds to your email within a few minutes Responds to your email within a few days
Ready. Aim. Aim. Aim. Ready. Fire. Aim.
Makes the boss happy Makes the client happy
Seeks consensus Encourages creative self-expression
Writes a detailed specification Implements a prototype
Looks like they’re busy Looks like they’re slacking off
Finishes it this evening Finishes it tomorrow
What else can we add? What else can we remove?
How should we fix this? Do we need to fix this?
Sees the toolchain as a competitive advantage Sees the user-kickassness as a competitive advantage
Let’s get everyone’s feedback on this DO IT

And really, I think I’m just humoring myself. After all, as the man says, the world is full of interesting problems to be solved, and none of them should have to be solved twice. This problem is, quite really, solved. When I have so many other software projects to work on, and ones I’m purposely ignoring, rewriting this “throw-away” code just wouldn’t be right.


Quicksort in Java

April 8, 2008

Following on from last week’s implementation of quicksort in Python, we have a Java implementation to do the same thing. However, this version requires a bit more work, since Java is a lower level language than Python.

See, in programming, you’re working within a spectrum where at one end you have CPU-intensive code, and at the other is memory-intensive code. This is something that I’ve never been taught in class, but is an important tenet of efficient programming, which is really an art of finding a good balance between the two extremes that also minimizes each.

This quicksort is a good example of that, because of the way Java uses arrays of a fixed length. What this means is that, if you make your list 10 items long, and need to put 11 things in it, you will have to copy the entire list into a larger list that will accommodate 11 elements. You can’t just tack another item on to the end of the list, which makes life fun some times.

For example, let’s say that you have a 100-item list that you’re giving to this quicksort. How large do each of the three lists need to be so that none of them will ever be overfilled? Well, the obvious answer is 100 items. So you sort your original 100 items into the three 100-item lists, and then run the quicksort on them.

With the original list, you needed to sort into 100-item lists, because you knew that you had 100 “good”, (non-zero) items to sort. (The reason all the sub-lists have to be 100 items is because it is possible, if exceedingly unlikely, that all 100 items in the original list would end up in one list.)* But now, with each sub-list, it’s exceedingly likely that each of they don’t have 100 “good” elements. At any rate, what we have after the first iteration is three 100-item lists, which are, statistically, each only a third full. But we can’t bank on them each being 33 items, because it is possible that one could be 99 items as easily as 2 items.

Now we have the problem set up, so let’s look at it from the CPU-heavy and memory-heavy perspectives. The memory-heavy way would be to quite simply keep using 100-item lists, so that you’d always be sure that you’d never run out of slots in your lists. But what this will result in, eventually, is some lists that are 100 items long, but only holding 2 “good” items.

So how about CPU-heavy? In this approach, we would dimension each of the original sub-lists as being 100-items long where each item is the Java “null” variable. (We have to use “null” instead of zero because zero might actually be a meaningful statistic in the sort.) We would then pass the partially-filled sub-lists into the quicksort, which would then scan through the list of 100 items and find how many were “good”, and then dimension the lists to that number.

For example, let’s say the original 100 items gets split into three lists of 100 items, but let’s pretend that we’re like Java and don’t know how many good items are in each. So the first list gets quicksorted, lessThan. But before it starts actually sorting lessThan, the program would run through and count how many of those 100 entries weren’t “null”. Let’s say it gets that the number there is 23; it will then make each of the sub-lists 23 items long.

If you’ve stuck it out this long, here’s the good news: it’s about to get easier. Unsatisfied with either the CPU- or memory-heavy implementations, I decided there had to be a better way, and there is. See, both of these implementations require a lot of resources because they don’t know how many “good” items are in the list. But since the lists are being built at run-time, it is actually fairly trivial to keep track of how many “good” items are put in, by just incrementing a counter every time you put an item into one of the sub-lists.

*Writing this out, it occurs to me that if you choose one item as your pivot, then only the equalsTo sub-list could ever possibly contain 100% of the passed-in list. All others could be at most one less than that, which should be reflected in the list creation statements. It also occurs to me,

	public static int[] quicksort(int[] inlist){
		//Hack around lack of default parameters
		return quicksort(inlist, inlist.length);
	}

	private static int[] quicksort(int[] inlist, int length) {

		//This is our base case. If the list is one or shorter, spit it back out
		if (length <= 1){ return inlist; }

		//Our sub-lists
		int[] less = new int[length];
		int[] equal = new int[length];
		int[] greater = new int[length];

		//Our counters to keep track of the number of "good" elements in each
		int ltsize = 0;
		int eqsize = 0;
		int gtsize = 0;

		//Take our pivot
		int pivot = inlist[0];

		for(int i = 0; i < length; i++){
			//Take every item in the original list
			//And put it in its rightful place in
			//one of the sub-lists
			if (inlist[i] < pivot){
				less[ltsize] = inlist[i];
				ltsize++;
			}
			else if (inlist[i] > pivot){
				greater[gtsize] = inlist[i];
				gtsize++;
			}
			else if (inlist[i] == pivot){
				equal[eqsize] = inlist[i];
				eqsize++;
			}

		}

		//Find the sorted versions of the lists
		less = quicksort(less, ltsize);
		//Equal doesn't need to be sorted
		greater = quicksort(greater, gtsize);

		//Our list to return
		int[] ret = new int[length];
		//The index of the end of the list
		int retPointer = 0;

		//Put less into ret
		for(int i = 0; i < ltsize; i++){
			if (less[i] > 0 ){	ret[retPointer] = less[i]; }
			retPointer++;
		}

		//Put equal into ret
		for (int i = 0; i < eqsize; i++){
			if (equal[i] > 0) { ret[retPointer] = equal[i]; }
			retPointer++;
		}

		//Put greater into ret
		for (int i = 0; i < gtsize; i++){
			if (greater[i] > 0) { ret[retPointer] = greater[i]; }
			retPointer++;
		}

		//We're done!
		return ret;
	}

Reflections

April 7, 2008

There’s something real particular about 2 am that makes a fellow such as myself particularly reflective. I’m not sure what it is, but at times like these, you don’t question such things.

Also, I know some readers are particularly keen on gleaning my personal status, and I don’t mind at all obliging them to a little view into how things are going every once in a while.

This past weekend is a paragon of the kinds of times I’ll look back on and wish for more of. A little bit of class on Friday, then to work for a few hours, then some take-out pizza and an evening (until 1am) with my closest of friends, playing D&D Fourth Edition with pre-release materials. We are so eager to learn the secrets of this new system that in a year’s time will be utterly pedestrian and second nature to us that we are taking to scraping together every bit we can of public games to re-create them in our own lives.

But there’s also the larger issue of spending hours with people you’ve known for time periods longer than high school. The bonds will certainly be tested, and often in unexpected ways, but even though you might disagree as to who benefits from NAFTA, you’ll still be able to come to a consensus that Israel is one bad ass country.

And if it had ended there, I might even be content. But that evening, during a dessert run to Goodberry’s, I became wholly consumed in a discussion of computers and their programming. I can remember a time when I was unsure of my career path, and I understand those days. But somewhere during my four last years of public school, I came to the realization that programs would be my living.

It’s certainly easy to posture on such a subject, but I think the most defining moment that tells me I’m on the right path was when I spent a full five minutes gesturing to my good friend and fellow computer scientist while rambling on about recursion. All the while, I was holding a Goodberry’s Carolina Concrete in my hand, even gesticulating with the spoon full of vanilla ice cream and chocolate chips. And I was more interested in base cases and infinite loops than such a delicious treat. That’s certainly a statement.

In short, the future is looking good. But the present, as it so often is, is somewhat disappointing. Unfortunately, I’m finding my programming classes to be rather boring in straightforward, which I chalk up to a combination of previous knowledge of the subject matter and an intuitive learning of the new material.

Take linked lists for example: I distinctly remember some years ago, during high school, at some shindig or another, asking Greg what this “linked list” that he was talking about was. He explained it to me, and at the time it seemed silly to me, but at the time I hadn’t had to write any data structures of my own, so it doubtlessly would. Then consider the idea of operating on them recursively: recursion was a topic I covered in my high school computer science classes and in my recreational programming. While using it to iterate through the list would not be immediately obvious to me, once it was proposed, it was a straightforward acceptance of the utility of such an approach. The additional half hour of justification for it in class was just unneeded.

Holy crap, that was a tangent. So anyways, Goodberry’s, and Friday evening. Well, that night, after the get together adjourned for 12 hours, to reconvene and carry on at 1pm on Saturday, I went directly home and set to coding, staying up hours longer until a rather unwise hour to be well rested for the following day. And then all of that day, in parallel with the gaming and debauchery, I kept on coding.

What I’m left with is a product which I didn’t know how create when the weekend started, but by pushing into the online documentation and puzzling things out, I produced a useful product that I’m actually quite proud of. Coupled with the satisfaction I gain from such projects at my place of employment, I know that I’m headed in the right direction.