Cowboy Programming Game Development and General Hacking by the Old West

January 12, 2007

Programming Bio

Filed under: Game Development — Mick West @ 11:22 am

I first started programming games in 1979, aged 12, when my Grandfather bought me a Casio FX-180p, a programmable calculator that had just 38 steps, and a display of just the usual ten digits. Nevertheless I managed to whittle away a few games from that meager space, including a gambling game where you had to guess if a random number you had was bigger or lower then the computer’s random number, and you could bet an amount of money. I had the game code memorized since every change to it meant re-entering the entire program (not much of a chore with only 38 button presses). I have since forgotten it.

My first real computer was the Sinclair ZX81, with 1K of memory, and a 3.2Mhz 8-bit processor (coincidently, that’s exactly 1/1000th the clock frequency of my current computer, and 1/2000000th the memory). I swiftly upgraded to 16K, and wrote some simple games.

But my programming really took off with the Sinclair Spectrum. 48K of memory, high resolution color graphics. Luxury. I wrote games, I hacked the hardware. Still all just at a hobbyist level, although I dreamed of working in the games industry.

Then I went to UMIST (Manchester, England) to “study” computation. During my last year here I got an Atari ST, an immensely powerful machine with 512K of RAM, a 16-bit processor at 8Mhz and a floppy drive. Truly this was the pinnacle of computing! I messed around with this computer to the exclusion of all else, including attending classes.

Upon leaving university with a degree, I got a job as a game programmer at Binary Design in Manchester, earning the vast salary of £6500 (about $10,000), which actually seemed like a lot back then. The first game I worked on (with two other programmers) was “Steve Davis World Snooker”, a 2D snooker game that was incredibly simplistic. The most valuable lesson I learned during development was that people perceive human attributes in random behavior. This happened after a producer told me that the positional play (where the white ball ends up after a shot) was “too good” in beginner mode. In fact the computer only concerned itself with potting balls, and never even calculated where the white ball would go after, making the “positional play” essentially random.

The next game at Binary was “Rotox”, a rather odd game based on the premise that a 2D rotating playfield was fun. I had way too much creative control on this game, which meant it was late and rather strange. Shortly before it was finished I arrived at work to find all our Atari ST computers had been replaced by Vic 20s. Shortly after this we found the company had declared bankruptcy.

I then went to work at Tiertex for less than a year, churning out an arcade conversion “UN Squadron”. The art process for this game consisted of using a video frame grabber to take pictures of the screen, and then an artist would trace the images to create game art. Tiertex was actually fun, since round the corner was a pub that gave free pizza with a purchase of two pints or more, so come noon we would head round there and begin the relaxed afternoon.

I left Tiertex in the company of an artist to go work at Ocean, where I did three games: Darkman, Parasol Stars and Lethal Weapon. Of these Parasol Stars was by far the best, probably because I was not involved in the game design. I have since learned a lot from my mistakes.

After finishing a conversion of Lethal Weapon to the Sega Genesis (which I think was never released) I got a job in the US, at Malibu Interactive, formerly Acme Interactive. There I co-programmed a Battletech game on the Genesis. Malibu was then in something of a development limbo, and lots of people left to start their own companies. I was approached by Joel Jewett to start a company, the first game was going to be “Skeleton Warriors”, apparently going to be something better than Power Rangers. Eventually I agree, and tell Joel we would need an artist, so we team up with Chris Ward.

The rest is history, or at least Wikipedia:

http://en.wikipedia.org/wiki/Neversoft

Cowboy Scrabble Programming

Filed under: Cowboy Programming — Mick West @ 10:39 am

(This is just a programming anecdote.   If you want to know how to program something that plays scrabble, then look here: http://www.gtoal.com/wordgames/scrabble.html)

A couple of years ago I was trapped in Truckee, California, snowed in somewhere up a mountain in a little cottage, with no electricity. It was the holidays, and I was visiting with the in-laws, and we’d just had a rather unsatisfying game of Scrabble. Unsatisfying because we had no dictionary, and so no way to validate challenges, which makes the game even less visceral than normal.

So my laptop still had a few hours of juice left, so I resolved to write a quick scrabble word checker. As it happened I already had the list of valid scrabble words(ospd.txt), which can be downloaded from http://web.mit.edu/rwbarton/Public/ospd.txt

At first I though a quick batch file would do the trick, but after a few minutes poking I got annoyed, and decided to simply brute force it, and write it in plain old C++, just to pass the time. Half an hour later I came up with this monster (stripped slightly):

		w = (char*)argv[1];

		char * p = new char[10000000];		// 10MB
		FILE * x = fopen ("C:\\ospd.txt","rb");
		for (int i=0;i<10000000;i++)
			p[i] = 0;
		fread (p,1,10000000,x);

		int len= 0;
		while (w[len])
		{
			if (w[len] >= 'A' && w[len] <= 'Z')
				w[len] -= ('A'-'a');
			len++;
		}

		char *s = &p[0];		// w = search pointer to start of word

		int valid = 0;
		while (*s != 0)
		{
			int letter = 0;
			while (letter < len)
			{
				if (s[letter] != w[letter])
					break;
				letter++;
			}
			if (letter == len && (s[letter]==0x0a || s[letter] == 0x00))
			{
				printf ("%s is GOOD\n",w);
				valid = 1;
			}
			while (*s != 0 && *s != 0x0a)
				s++;
			if (*s == 0x0a)
				s++;
		}
		if (valid == 0)
			printf("%s is BAD\n",w);

Now there’s some hackery, quite embarrassing really. It’s a good example of Cowboy Programming because:
– It’s long and messy code
– It’s using an ad hoc solution to something that has been solved many times before

But the key thing is that it works. It’s a perfect solution to the given problem in the sense that it solves the problem perfectly. But it’s nothing beyond that.

Of course, you can do the same thing in one line of Ruby:

puts IO.readlines("ospd.txt").include?(ARGV[0]+"\n")

But I did not have Ruby (or Perl) installed, and since I’m no Ruby expert, and had no Internet access, that one line of Ruby could have taken me longer to write than the 50 lines of C++.

However, had I persevered a little, I could have figured out the batch file:

@echo off
for /F %%f in (ospd.txt) DO if "%%f"=="%1" @echo %%f IS GOOD!

In hindsight, what should I have done, wanting to be a “good” cowboy programmer? Well, my goal was to solve the problem as quickly as possible, and I knew the code was never going to be looked at or used again. I knew that very simple solutions existed, but I did not know how to get to them. I knew I could get to those simple solutions eventually, but I did not know how long it would take. On the other hand, I knew if I programmed in C++, the code would be long and messy, but I knew exactly how I would write it, and I knew roughly how long it would take, about 20 minutes.

So, the choice was a short and elegant solution in between two minutes and two days (if I had to wait until we escaped the snow), or a long and messy solution in twenty minutes. Take the money, or open the box? I experimented briefly, and then chose the known quantity. The messy code was written. Done.

Powered by WordPress