Tao of the Machine

Programming, Python, my projects, card games, books, music, Zoids, bettas, manga, cool stuff, and whatever comes to mind.

Dope, geen uitverkoop

Megadef will be out soon. I want it.

Posted by Hans Nowak on 2003-08-01 12:56:27   {link}
Categories: music

The importance of being selfish, part 2

From the comments on my original post, it turns out that some people don't have a problem with the usage of self to indicate instance attributes, but they don't like that it has to be included in the method definition.

I can't channel Guido, so I don't know what his intentions were when this feature entered the language. I don't know if it was a well-thought-out design decision, or more of a hack. But what I can do is explain why I think self in the method header is not a bad idea.

When you consider a method like

def foo(self, x):
    print x

then self is passed as the first argument... and this is exactly what happens under the covers. The object *is* passed as the first argument. The Python method definition doesn't try to hide things from you, which I consider rather good.

But wait, when you call this method, you only use *one* argument, right? While the method definition shows two parameters!

Yes, no, not really. You call a method like this:


The arguments are obj and 42. So there are two arguments being passed, not one. The first one just happens to have a different position. Of course, we could write

someclass.foo(obj, 42)

which would be clearer with respect to the argument list (two in method definition, two in method call)... but we don't usually call methods like that.

Another point is that there's no magic involved here. In a method like

def deposit(self, amount):
    self.balance = self.balance + amount

usage of self is perfectly natural... it is passed in the argument list, so it's no surprise that you can use it in deposit's local namespace. Now consider Object Pascal (but I could have used Java or C++ as an example as well):

procedure Deposit(Amount: Real);
    Balance := Balance + Amount;
    // or: Self.Balance := Self.Balance + Amount;

From a Pythonic point of view, both lines use a form of "magic". The first uses a variable Balance that seems to come out of nowhere. In second, it's an attribute of Self, but Self itself seems to come out of nowhere. Of course, we know that Balance is an attribute of the object, and Self signifies the object itself; and this is not hard to learn. But neither construct would work in a Pythonic namespace model. At least not without introducing magic, an implicitly defined self or something... but the line "explicit is better than implicit" is in the Zen of Python for a reason.

There's another reason why this kind of magic might not work very well in Python: the distinction between functions and methods is blurry. This is a function:

def f(a, b):
    print a, b

f(3, 4)  # prints 3 4

However, we can easily turn it into a method by sticking it into a class:

class Foo: pass
Foo.bar = f
foo = Foo()
# prints something like 
# <__main__.Foo instance at 0x00926700> 42

# or we could do:
Foo.bar(foo, 42)  # two arguments :-)

or rip it back out:

g = Foo.bar.im_func
g(1, 2)  # prints 1 2

So, the difference between functions and methods isn't all that sharp, like it is in e.g. C++, or Object Pascal. This could well be a reason not to introduce magic self behavior.

Again: I don't know if this feature was deliberately added or not. I don't think it's all that bad, though. To sum it up: you see what's going on; no magic tricks; and it's in sync with Python's dynamism and namespace model.

Posted by Hans "how could it be otherwise?" Nowak on 2003-07-31 18:30:40   {link}
Categories: Python

Day 7: Microprose Magic

The real title is Magic the Gathering, but I'm calling it Microprose Magic here to avoid confusion with the Magic the Gathering CCG.

In the middle 90s, I knew nothing about Magic. In spite of that, I bought some old Inquests at a bookstore and attempted to fathom this mysterious game, with its spells, summonings, enchantments, and countless mythological and fantastical creatures.

Some ads in the magazines talked about an upcoming PC game, made by Microprose, that would enable you to play Magic against the computer. That would be good, since I didn't anybody who played the game (back then). Sure enough... after a long wait, in early 1997 I found a copy of the game in a computer store. Cost me ƒ 100, and I didn't have a job at that time. Also, the game required 16 Mb of memory, while my computer only had 8 Mb. In spite of all this, I decided to buy it anyway.

Well, I didn't regret it. The game ran slow, but it did run. It allowed me to dip in a pool of hundreds of cards. Not just the cookie-cutter cards they crank out today, but the real stuff from the first sets (Alpha/Beta/Unlimited, Arabian Nights) and 4th Edition. Imagine building your deck with Black Lotuses, Moxen, Ancestral Recalls, and lots of other powerful cards. 1)

Microprose Magic was *the* way for me to learn the game. It let me sharpen my skills in several ways. First of all, there was some kind of "adventure" setting where you got to travel from town to town, solving quests, battling opponents and collecting cards to strengthen your deck. This world (called Shandalar) was interesting. You got to battle all kinds of opponents using any of the 5 colors. Ante, currently considered "not done" by WotC, was used a lot, and made sense; if you lose your battle, you lose you ante card, otherwise you win your opponent's ante.

You could also duel the computer. Just select a deck for you and your opponent, and you're ready to go. Since a deck builder is included, this was a great way to test decks, or just to play a casual game. The computer doesn't mind if you feel like playing in the middle of the night, nor does it care if you come with a twisted and illegal Channel/Fireball deck.

One of the best games I ever played, with great replay value. However... fast forward to 2003. Shandalar cannot really be played anymore on modern computers, because everything moves too fast. In addition to that, the game is difficult to get to work on Windows 2000 and XP. I did get it to work eventually, but the expansion set (Spells of the Ancients) cannot be used. Too bad, because some good cards are in there. So now all that's left for me is the Duel. Too bad it didn't scale up to modern operating systems. emoticon:sadley

Some people were disappointed about this game. It didn't do what Microprose had promised earlier, viz. allowing two people to play over the Internet. Also, the AI had some serious flaws. And the experience just wasn't the same as playing against a human opponents. However, to me, it was the greatest game in years.

(Note: Microprose's version is not to be confused with Magic the Gathering: Battlemage, nor with Magic Online.)

Some reviews: Games Domain, Gamespot, Adrenaline Vault.

GameFAQs: Magic the Gathering, Spells of the Ancients.

Update. Some people wanted to know how to make this game work on Windows 2000/XP. Here's what you do:

  1. Make sure you have the patch. Version 1.25 I believe. Google for downloads.
  2. Set the executables to "Windows 95 compatible". If your system doesn't support this in an obvious way (not sure if Win2K does), Google for SETWIN95.CMD. Use this to set the compatibility mode.

Shandalar will be too fast, but at least the Duel and Deck Builder should work.

1) For those not familiar with the game: certain early cards are considered to be very powerful, so much in fact that they have been banned from tournaments (or restricted), and haven't been reprinted in recent sets.

Posted by Hans "although greatly prized by falconers, the Zephyr Falcon is capricious and not easily tamed" Nowak on 2003-07-29 19:32:26   {link}
Categories: games

Day 6: Age of Wonders

Now this game isn't so old. I played it first in 2000 (I think), and still do. (OK, so that's only three years ago, not very impressive... but to some people, a game from 2002 is old. emoticon:sm_eerie)

A quick description: It's a turn-based RPG/strategy game, a bit like Heroes of Might and Magic. You start alone (or with a small party), and gain followers, conquer cities (or enter an alliance with them), fight battles, etc. You can choose from a plethora of spells to aid you, although you'll have to learn most of them first.

So far, it sounds pretty much run-of-the-mill. These days, many games have all these features and more. What makes AoW special is that (IMHO) everything's done exceptionally well. Great soundtrack, good graphics 1), impressive special effects, and addicting gameplay.

I like the interesting beasties that are at your disposal. Not just the ubiquitous orcs and dwarves and such, but also dragons, eagles, lizard people, frost beasts, nymphs, scorpions, and much more. I also like the spells. Destroy cities with huge blasts of fire. Freeze whole areas. Conjure elementals. Or do more subtle things, like increasing a town's income.

There's a bunch of features that are pretty common in this kind of game... you can choose to do seperate scenarios or to follow a storyline; there's automatic battle versus "manual"; you can micro-manage cities and tell them what to build (a bit like Civilization); etc. I'm just mentioning these so you know these features exist, not because they make the game special. :-)

All in all, a good game. (And it has cheats, so it doesn't frustrate me no end. :-)

1) Some reviews described the graphics as "dated" because it didn't support the really high resolutions, and it didn't use a 3D engine. If that is the case, then I love dated graphics. I like my dragons to look like dragons, not like a bunch of polygons with awkward movement and unrealistic lighting, thank you very much. (Their latest product, AoW: Shadow Magic, seems to stay true to this format, fortunately.)

Posted by Hans Nowak on 2003-07-28 13:49:37   {link}
Categories: games

Day 5: World Games

Another C64 game that I remember fondly. The games are not getting newer; this one must have been released in late 1986 or maybe early 1987, if I'm not mistaken.

In the middle/late 80s, there was a software company called Epyx, known for their high-quality games. Their list of successes includes Summer Games, Summer Games II and Winter Games, where multiple players could compete in a number of Olympic events. I guess this idea got old after a while (there's only so many sports you can do), so they came up with disciplines that were a bit more unusual. This resulted in World Games (and later California Games, which is the #1 download at c64.com).

The first discipline in World Games is weight lifting, which is also an Olympic event, but most of the other ones are pretty much uncommon. You get to jump over barrels (on ice), dive from a cliff, toss cabers, and ride a bull in a rodeo. Other events include slalom skiing, log rolling, and sumo wrestling. The games take place in various parts of the world, hence the name.

For those who are unfamiliar with Summer Games and its sequels, it is played like this. You set the number of players (1-8), name them, and choose what country they represent (there's a number of flags to choose from, and the national anthem is played when you pick one). You can then compete in all or any of the games. After each game, points and medals are awarded to the winners, and a scoreboard is updated. In other words, you get to play your own Olympics. emoticon:loveit

The games are not for the heavy-handed. An infamous game like Decathlon required waggling the joystick as fast as possible. Not so in World Games. To get a decent score, you need timing, a sense of rhythm, sometimes quick reactions. For example, getting up to speed to get over the barrels doesn't require that you move your joystick extremely fast. That "strategy" will not get you anywhere; rather, you have to move the stick in a certain rhythm, to have your skater gain speed. That's not all; there are also timing issues: don't jump too early or too late; same goes for landing.

Similary, Slalom Skiing is a Decathlon player's nightmare, and considered by many to be the most difficult of the 8 events. The skier isn't easy to control, and with all the obstacles in the way, it's hard enough to make it to the finish line safely, without the additional requirement of passing through the flag ports.

On the other hand, other games require other techniques. To win Bull Riding, you have to a keep a close eye on what the bull's doing, and move your joystick accordingly. For Cliff Diving, it's most important to keep an eye on the wind direction and speed before you jump.

While the games are essentially serious (and not slapstick-like like Alternative World Games (which I never played, BTW)), there's a lot of humor, although it's not immediately obvious. For example, if your weight lifter doesn't put down the weights when he's done, there's a chance that he will crash through the floor. When your bull throws you off, he laughs at you. Ditto for the pelican that watches when you unceremoniously fall on your face after diving from the cliff. (And he hides his face with his wing when you hit the rocks at the side of the cliff!) And when you put too many barrels up, the skater looks at you and scratches his head. (There's more, but I won't give away everything here.)

Graphics and sound were very good for that time, by the way. It's a bit pointless to discuss them, because these days everybody has much better equipment...

Get World Games at c64.com. There's also a (silly) FAQ, but it's really for the NES, and apparently the games weren't exactly the same as on the C64.

Some reviews: Zzap! 64 issue 19, and an article in German. (The Zzap! 64 site has some scans back online, so you can also check the original review as it appeared in the magazine. See issue 19.)

Posted by Hans Nowak on 2003-07-27 14:53:44   {link}
Categories: games, nostalgia

Day 4: Hat Trick

This is a fairly unknown game even in C64 circles. Indeed, the version I played (and still play) was for the Commodore 64, but it's possible that there were releases for other systems as well.

Hat Trick is a one-on-one (or two-on-two, if you count the keepers) ice hockey game. At first glance, it has significant things going *against* it: unspectacular graphics, boring sound effects, and difficult controls. One might wonder why it is on my games list. Simple: because it's extremely playable.

You might not think so at first. Your player is difficult to control. But this is where the realism comes in. Do you really expect an ice hockey player to be able to stand still immediately when he wants to? Of course not; inertia plays a very important role when on the ice. Therefore, your player moves slowly from a standstill position, takes a while to slow down when moving at top speed, and doesn't change direction immediately when you want to. It takes some time to move your player around skillfully.

The same goes for shooting at the goal. Back in the day, with a joystick, it was a bit easier than it is now, using the cursor keys on a PC keyboard. The computer controlled keeper is generally good, at least until you discover ways to trick him. On the other hand, you control both your player and your keeper, simultaneously. If you move your player up, your keeper will go up as well, etc. This takes some time to master too, since you need to keep an eye on both; failure to do so will leave great openings for the opponent.

There are three levels (easy, medium, hard); they're really not all that hard anymore once you figure out how to move your player effectively, and how to score. Once you reach that point, the first (easy) level may actually be a bit more difficult than the others, because the opponent is less predictable than on the higher level. Challenges that keep the game interesting are: trying to make as many goals as possible (my old record on the C64 was 24-1, but I think I've beaten that last year or so), and, trying to play "the other side". If you've mastered red (plays from right to left), and beat your opponent with 20 goals, that doesn't mean you can do the same playing blue. In fact, chances are that you will lose when playing it for the first time... ^_^

Download it here (at c64.com; warning: if you're into C64 games, you might not come back anytime soon). A good C64 emulator for Windows is VICE.

Posted by Hans "bully for you" Nowak on 2003-07-26 12:11:10   {link}
Categories: games, nostalgia

Site updates

Some parts of the site have been revamped a little. Well, kind of. There's also a rudimentary FAQ now. Oh, and Kaa can be found in the download section now too.

Posted by Hans Nowak on 2003-07-26 12:08:12   {link}
Categories: general

Generated by Firedrop2.