Brandon's Blog

7/3/2006

Smackage

Well, I promptly dispatched my major internship project this morning, so there’s a bit of downtime available as things regroup from that major shock of progress.

Although I am unable to scan or otherwise capture the document from here, I have prepared a very cool little dependency tree for the project-management side of this Great Python Re-Write experiment.  I got the append() (enqueue) and about 10% of the pop(0) (dequeue) side of the command queue written, if you consider the parser and handler calling systems as the unfinished 90% of the “queue” as a whole.

The parser, as can be said for well over half of my top-level unfinished items, is basically assembling a new set of Legos, as Python was nice enough to do most of the work essentially in advance.

The “handler calling system” is my term for the thing that takes the command:

lo ca

from the parser in parsed form ([0] -> “lo”, [1] -> “ca”) and does a letter-to-letter sloppy match against a table of command-to-function mappings.  I am cursed with the curse of knowing how CircleMUD worked (good memories, on the whole!), so my handler works like its handler.

Its handler used a priority matching system, such that some commands (the command is the zeroeth parsed token, “lo” in the example) take precedence over others, even when the lower-precedence token would normally be alphabetically “superior” to the high-power one.

This allows the input socket (okay, the “player”) to type “l” (as in leopard, if the font is funky) to mean “look,” even when the first command starting with the letter L is “leer.”  This non-alphabetic matching is a bit of a pain, but Python should make it easy with the startswith() string method.

Writing the whole dang thing in the language I was originally planning to embed as a scripting language means that all handlers are bound and required by programmer’s fiat to be modular, extensible, and arbitrary.  Even “go” and “look,” the big daddies of them all.

Needless to say, it’s fun watching Python’s prototyping efficiency whip butt against C++.  I had the entire skeleton player/denizen/character/entity (née “object” in Sigma C++, where “object” is not a keyword) at least gasping for air in about five minutes, as opposed to days with C++’s constant file.cpp/file.h dance.

Pretty good stuff.  I’m getting over the hump of doing things “over again” and starting to see things look new and interesting…