Tao of the Machine

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

.py

I would get a .py domain name, but they're $240, and require local presence. Oh well. emoticon:nosmile

Posted by Hans Nowak on 2004-03-19 19:32:08   {link} (see old comments)
Categories: internet

Yesterday's technology tomorrow

Via Language Log: Yesterday's technology tomorrow.

"Tomorrow's technology today. [...] And I suddenly realized that is the exact opposite of what I want. I don't want tomorrow's technology today. I want yesterday's technology tomorrow. I want old things that have stood the test of time and are designed to last so that I will still be able to use them tomorrow. I don't want tomorrow's untested and bug-ridden ideas for fancy new junk made available today because although they're not ready for prime time the company has to hustle them out because it's been six months since the last big new product announcement. Call me old-fashioned, but I want stuff that works."

The blog post goes on with a few examples: WordPerfect, Adobe Acrobat Reader, etc. Yes, I agree, it does appear that for a lot of commercial software, every upgrade is really a downgrade... it adds a lot of features you don't need, often removes features you did need, and takes more memory and hard disk space.

Acrobat Reader 6 is a good example. A few months ago, my version 5 somehow broke, so I went to the Adobe site for the latest version, which was 6. Turns out it's quite a bit slower than its predecessor, especially when starting, when it loads all this stuff that I don't need. It also changed the "find" feature, and changed some keys around, apparently arbitrarily (e.g. Ctrl+N, to go to a page number, is now Shift+Ctrl+N).

Operating systems are another, very obvious, example. Upgrading from Windows 2000 to XP gives you a few useful features and a lot of bloat, some of which is eye candy that slows the computer down. Since I got my first PC in 1991, I've needed a new one every two years, because by then it would be too slow, incapable of running the latest software, lacking in memory and hard disk space, etc. Back in the day, a new computer at least got you some real improvements: better graphics (CGA -> EGA -> VGA -> SVGA), better sound (PC speaker -> Sound Blaster), memory above the 640K limit. These days, what are the improvements? Sure, a faster processor and more memory/disk space is always nice, but aside from that it will just be the same old stuff. 3D cards? I don't need or like them, and think it's ridiculous that anno 2004 you need one to play an adventure game.

It is developments like these that sometimes make me highly dissatisfied and make me want a Mac, an SGI or an Amiga. emoticon:smile Or make me want to go back to the time of the command line.

On the other hand, there are some benefits as well. Interpreted languages like Python have become valid tools for mainstream programming projects. That wouldn't have been possible on memory-starving, slow machines. And ironically, I can play Broken Sword 1 on the GBA emulator, because modern PCs are powerful enough to support such a thing. Bloated software wants more memory and faster processors, but has the unintended side effect of paving the way for dynamic programming languages, emulators and other niceties.

So I guess I'll just install the older versions of some software (while they still work) and enjoy some of the positive side effects of bloated software without actually using it. emoticon:wink

Posted by Hans Nowak on 2004-03-19 18:14:56   {link} (see old comments)
Categories: general

Adventures in writing adventures

AMK writes about interactive fiction with Python. " In text adventures, usually every single object is unique, so it's a minor irritation that you have to write classes and then instantiate the class. It would be better if you could automatically instantiate each class."

Yes, I noticed this too. A while ago, I came to the conclusion that straight OO may not be right for writing adventure games. Sure, it *seems* like a great match. You have objects for things, people/creatures, rooms, and maybe other stuff like mechanisms. An object's properties can easily be stored in attributes: lamp.on, player.inventory, etc. And mailbox.open() is the method that is called when we open the mailbox, of course. Sounds wonderful.

Except that it doesn't work all that well in practice. The problem mentioned by Andrew is just one out of many. It seems kind of redundant to have a class and an instance. Also, if you go for the mailbox.open method and friends, then there are some interesting decisions to make. How do these methods map to commands? What method is called when doing give X to Y and on what object? What about use X with Y (a Lucasarts favorite :-) ? More in this old article.

Of course, it's not *impossible* to write an adventure in Python using OO, far from it; it's just less convenient than it could be. A few ideas for ways around it:

Idea #1: Use classes, and classes only. Make all methods classmethods, all attributes class attributes. Would this work in real life? No clue. One obvious drawback is that you'll have to define the methods the usual way, *then* make them classmethods.

Idea #2: Self-style objects. This would work (assuming my code is correct, it was just something to play around with), but has an obvious drawback as well: you'll need to add methods on the fly. Something like this:

def window_open(self):
    if self.open:
        print "The window is already open, you dork."
    else:
        self.open = 1
        print "You open the window."

# 'window' is a Self-like object
window.open = window_open

Both ways seem kind of unpythonic.

Lately I have been tinkering with a system that uses a mixture of OO and procedural/functional style. Some ideas:

  • There are only a few classes: Room, Object, Person, Player, World (the game engine)... that's about it.
  • Objects, rooms and characters in the game do not derive from these classes. Rather, to make a new Room, you create an instance of it, and stick stuff in it.
  • To add code for actions, you don't add custom methods to these instances. Rather, you write a function (e.g. get_default), associate it with a command ("get"), and register it with the game engine.
  • Within such functions, you can check which object (room, character, etc) you have (if obj is apple, etc), and take appropriate action, possibly by calling other functions.
  • You can set an object's attributes on the fly, which is useful for setting status etc.
  • A special kind of attributes are those whose name ends in _response. This is a string that represents the default answer when a certain action is done or attempted to the object. For example:

painting.get_response = "Who would want an ugly painting like that?!"
# when doing "get painting" in the game, this will be the
# response

(Although normally you'll set this attribute when creating the painting instance.)

More about this in this older post. Someday I might actually try to write an adventure with this... So much time, so little energy. :-(

Posted by Hans Nowak on 2004-03-18 12:56:38   {link} (see old comments)
Categories: Python, games

Quotable quotes

from 1986:

We make rock 'n roll. LL Cool J is rock 'n roll. Run DMC is rock 'n roll, the Beastie Boys are rock 'n roll, Public Enemy is rock 'n roll.
--Bill Adler, Def Jam/Rush Productions

That is one of the things I'm fighting for, that rap beat is viewed as rock 'n roll. It's not R&B. As a matter of fact, we have closer alliances with heavy metal than anything else.
--Chuck D

Posted by Hans Nowak on 2004-03-17 17:36:33   {link} (see old comments)
Categories: music

My first macro

The other day I wrote my first real Lisp macro. Yay! (Not counting macros from tutorials, etc.) It's a first step in harnessing some of the amazing power of Lisp.

This macro implements a C-like ++ (postfix) operator:

(defmacro ++ (x)
    `(let ((old-x ,x)) 
      (progn 
       (setq ,x (+ ,x 1)) 
       old-x)))

and it's used like this:

(setq magic 42)
(print (++ magic))  ;; like magic++ in C: sets magic to 43, returns 42
(print magic)       ;; 43!

Nothing special, and maybe not very useful, but it's always nice if you have an idea and it can actually be implemented in a few lines of code. :-) This may be an important step on the road to more Lisp. A long, long road, I suspect. Not that I will leave Python anytime soon... I'll still need to get some actual work done.

[Update #1] Some people pointed out that the macro isn't 100% safe. More about this problem here. The safe solution is quite ugly, IMHO (using gensym to make sure there are no variable name clashes). I guess variable name conventions can be very useful here.

(It's a bit quiet here in the Python and Parentheses topic exchange. Anybody else join in?)

Posted by Hans Nowak on 2004-03-17 13:59:34   {link} (see old comments)
Categories: Lisp

5K Chess

(via Keith Devens) 5K Chess. Amazing indeed.

Posted by Hans Nowak on 2004-03-17 13:55:56   {link} (see old comments)
Categories: games, internet

Spam, spam, spam

Well, sort of... More like virii and link-harvesting robots.

I received this mail today:

Hi there! Sorry for an e-mail out of the blue, but I just did a search for the term anime basket download fruit on Google and found zephyrfalcon.org ranked 41. Since I publish a related website about Flowers (it's strictly informational, so I'm definitely NOT a competitor of yours), I'd like to link to your site.

My site is one of the best resources for info in our category (I think you'll see that my site is pretty clean and high quality, and I only request to link to other quality sites for exchange). Because of this great info, I get a pretty decent amount of visitors...so if I link to you, your site should get some nice traffic as well.

So you know, I've already linked to you and will keep it there for a few days until I hear from you. If you're interested in swapping links for good, please reply back so I can get you all of the pertinent information.

Thanks!

Carrie Soefel
RAC IM: 785952.

This *almost* sounds like an actual human writing me to swap links. That happens sometimes, and I occasionally do trade links with sites. However, this one seems fishy. "I've already linked to you"... where is your site, then? Where am I supposed to link to? Also, it's not unlikely that I show up on a Google search for "anime basket download fruit" (especially now that I've mentioned it twice in a blog post emoticon:smile)... however, my site has nothing to do with flowers, and neither does that search term. (It's a search for the "Fruits Basket" anime.)

So, this isn't real, and a quick Google search confirms this.

Then we have the "Notify about using email account." (Sounds a bit like "all your bases...")

Dear user of "Zephyrfalcon.org" mailing system,

Some of our clients complained about the spam (negative e-mail content) outgoing from your e-mail account. Probably, you have been infected by a proxy-relay trojan server. In order to keep your computer safe, follow the instructions.

For details see the attached file.

Cheers,
The Zephyrfalcon.org team

Hmm, I wasn't aware there was a zephyrfalcon.org team, other than me... :-)

And then there's this one:

Hi, Hans! 50% discount for cigarettes!

Marlboro $18.95
...lots of brand names omitted...
PARLIAMENT $23.27

Start smoking today! http://OHOMiFXL.cigaretesstore.net/lord/

Um, yeah. Who doesn't want to receive a happy fun mail that encourages you to start smoking?

Posted by Hans Nowak on 2004-03-16 23:04:02   {link} (see old comments)
Categories: internet

Bad business practice

About a week ago, I was at the local PetCo to get cat treats and such. I usually check out the betta fish in pet stores, and this time was no exception. However, much to my dismay, most of the bettas they had seemed sick, afflicted by fungus and ick.

That happens, fish get sick, but I would have expected people to recognize and treat the disease. Fungus and ick are not fatal, all they take is a little medicine in the water, if diagnosed in time. And it's kind of hard *not* to notice, since the fish gets white spots (ick) or fuzz (fungus). In this case, they didn't notice the diseases, nor treated them; as a result, many fish showed the symptons, and one fish had his whole body covered with fuzz.

Gullible as I am, I bought one fish that looked healthy, to "rescue" it. To little avail, it appears now... a few days later, the fish developed fungus as well, and died not long after.

In comparison, the two bettas I got from Petsmart recently are doing well; they're active and making bubblenests.

I'm not sure I will shop at this Petco again... at least not for fish. If you sell live animals, you should at least know how to take care of them. No matter if they're only $3 or so... they're still living creatures. If you're not willing to take care of them, then don't sell them. emoticon:frown

Posted by Hans Nowak on 2004-03-14 20:44:36   {link} (see old comments)
Categories: bettas

--
Generated by Firedrop2.