Space Station

Modelling worlds

I went for another run today. Two and a half miles in 21 minutes. Certainly not my fastest time but I'm trying to avoid more injuries.

In other news, I'm writing software that allows one to arbitrarily model a world and agents in the world which can move around and freely interact with it. There's an interesting distinction between things in the world and the words to describe them. You might have a "box" and the word to describe that is, not surprisingly, "box". However, what if you have two boxes? You use adjectives such as "big" or "wooden" to describe them.

You also have verbs such as "take", "drop", "move", etc. Because Perl allows you to assign custom attributes to subroutines, it's fairly easy to implement verbs.

sub describe : Verb(look) {
    my $self = shift;
    my $adjectives = $self->_printable_list( $self->adjectives );
    return "$adjectives " . $name;  # this is actually cached

With that, the verb "describe" and its synonym "look" are automatically added to the vocabulary and you can just do this:

print $agent->describe($box);

However, because we automatically get synonyms, we can also do this:

print $agent->look($box);

That works because the Agent class has a can_do() method which checks to see which verbs or their synonyms are in the vocabulary and, if they exist, it calls the $box->describe method.

My goal is to eventually add an English grammar on top of this so that the user can run a shell and interact with the world in natural language. Of course, while this is clearly beneficial for text adventures, it actually can be used for any setting where the user wants to be able to model a world and interact with it. You could use this to set up a virtual text-based "work center" where your employees can wander from area to area in the world and communicate with other employees, take memos, etc. Of course, it's not that I think anyone will actually do that, but it's possible.

  • Current Mood: busy busy
I think it's a great idea
Expanding the vocabulary and API to include a user-friendly front end that plain English speakers could use to develop environments would be wonderful!

Fairie G (somewhat geeky girl)
I'd be really interested to see what you're working on (if it's meant to be available eventually), as my alife project involves me creating a very similar sort of setup. I've got some agents running about in a 2d world right now, and am building up their interactions a bit.
No. That's not my intent. I want to create software which can generally model a world. That it happens to be useful for writing a MUD is a coincidence.
So what's the motivation here? I assume there is something specific you want to do with it? There's been quite a lot done in this area, are you trying ot bring something specific or is this just an exercise?
Much of the fundamental reasons are on my technical journal. I haven't detailed them in-depth here as I don't want to bore folks too much.

Suffice it to say that I'm exploring modeling arbitrary data. The current state of database theory is primarily limited to relational (which sucks), heirarchical, multi-value (MV) and OO. Heirarchical and MV aren't in widespread use and OO tends to merely be a layer on top of relational databases. Much of my personal work is dedicated to better understanding relational modeling and I don't get that if I'm forced to use an existing package.
This just seems like a perfect use of OOP, where you create a thing and the thing knows inherently what actions can be done to it and how it interacts with the world. Instantiate the mirror and it knows it can be shattered, whereas the box does not have that ability (unless avatar strength > some limit or avatar uses an item with a 'shatter' ability on the box), but i digress.

I still think it's a novel approach to data storage and retrieval. This certainly looks to me like it sets up for a virtual (Shadowrun style) data-warehouse where interaction with data objects occurs according to the actions defined within the meta-data (controls?) of the object itself.
Shadowrun? I remember a game like that. What is it?

OO programming is still fairly primitive in many respects (though it's far better than many other paradigms). OOP isn't enough (I want logic programming -- something which is terribly important even if it is underused) and the debate over multiple inheritance versus interfaces versus mixins would just go away if people understood how to use traits (traits and a Perl implementation). And, of course, many folks don't have a clue about how to program OO style. They wind up with a bunch of procedural code with OO wrappers.

There's also the problem of OO persistence. Typically this is done in a relational database but since standard SQL does not allow recursion or multiple values in fields (due to First Normal Form), it's quite limited. Thus, one often finds one object model or code is sharply limited by the underlying persistence mechanism. Right now, I'm trying to create a system whereby I have exactly what I want at the top and later I'll try to figure out a valid persistence scheme. (You can see Logic Programming in Perl to get a rough idea of what I'm looking for).
So the question that keeps nagging me here: Are you writing this for yourself or for others to use? SImply because most people are unable to properly code OO does not mean it's not a sweet way to go. Fuck procedures, the object should literally be treated like an object in the real world. It's self contained and just works. Now if there are certain things (actions, universal laws) that that every object in the world needs to be subject to, then they simply inherit that from the main object instantination (create) and have all their other 'templated' attributes passed in to the same create statement (or are automagically included, whichever the designer prefers). Then the other additional object's components (actions, characteristics) are all put in place during the single create call. Hm.. where was I?

Oh ya shadowrun is an interesting roleplaying game world set in the not too distant future (about 60 years). It's a fun mix of many elements that is now in it's 4th incarnation that introduced a game where Gibson's Neuromancer type of world is reality. It's quite fun since the Matrix (years before any movie) is the place where deckers (hackers/techs) move around a virtual universe that consists of all the world's computers (or those that are connected to the matrix) as avatars with custom written programs in their pockets. I've not played in years but it's always been a very interesting look into technology and security.
"...the debate over multiple inheritance versus interfaces versus mixins would just go away if people understood how to use traits (traits and a Perl implementation)."

Someone has a new hammer in their arsenal. ;)

I smell a future article on Yet another one that sister_madly won't understand, mind you, but another article.

Yeah, I'd like to write this up. Right now, I just sent off another version of Class::Trait to Steven Little. It renames the is() method to does(). This avoids conflicts I've been getting with Test::More::is().
"This avoids conflicts I've been getting with Test::More::is()."

Isn't that....ironic? :-P
I think I missed the humor. Ironic how?

Incidentally, I'm now the maintainer of Class::Trait. It will be interesting to see how that works out.