Contracts 2: The Revenge
Mike requested some visual explanation of the contracts concept, so here it is, along with some grounding in Wikiup’s essential attitude towards data.
No truth
Each Class in the Wikiup comes in as many versions as there are opinions. Unlike the more familiar MediaWiki (i.e., Wikipedia) approach to content creation, there is no “official” version of the Class. Wikipedia provides the user with the most recent version of an entry, on the theory that the latest version more likely represents some sort of cumulative “truth”. But as anyone who’s seen the Evolution of Evolution will know, truth can be a very subjective thing. How much more so, then, with the entirely subjective representation of fictional data in a gaming environment.
For this reason, Wikiup simply stores each entry of a Class as a version. It’s not a “true” version, not a “false” version. Certainly, users will come along and rate each version, but that too is subjective. If a game developer doesn’t care what people think of the data, he can entirely ignore user ratings and go with what he thinks is right. If he doesn’t find a version to his liking, he can write one.

Multiple versions of a Class
No truth, just agreement
There may be no truth in Wikiup world, but there does need to be agreement. There’s not a lot of point having a common library if no one can find enough common ground to utilise anyone else’s work. We begin the process of agreement by naming Classes. A Green Dragon may mean many things to different people, but there are a few points of commonality (flying, magical lizard, perhaps) and we can loosely gather those points of agreement into the one class. We can also agree on some properties: strength, speed, power when attacking, defensive abilities, etc. We may disagree on what we want to call these properties, and we will certainly disagree on the specific values of those properties, but if I can find one that defines the concept I need to make manifest, then I can apply that to populate my game. But here’s where it gets tricky (and where contracts come in, at last!). I might have a game that requires the dragon to have six, sixty or six hundred properties. That’s a lot of variation to deal with. And if I’m working on a game that deals with six properties, I certainly don’t want to be wading around in a morass of six hundred.
So let’s bring in contracts:

The contract determines what certain Class types must contain
In this example, we have four different contracts. In fact, we have tiny stubs representing four contracts. An individual contract would need to define the required properties of all Classes used in the game, so we’re cheating a bit to keep things simple. We’re not defining the values of any of the properties, just the fact that these properties need to be defined by any Class using this contract. Under the contracts system, the Wikiup system will not accept any version of a Class which does not meet its contractual obligation. So if a client application attempted to define a Green Dragon under the supposed WiRPS contract that didn’t have a definition for Hit_Points, that version would be rejected to ensure that contracts were honoured.
Note that PokeUp only requires a few properties. WiRPS requires a few more. TwitchRing represents some monster simulator with dozens or even hundreds of required properties.
Meeting contractual obligations
Let’s look again at the Green Dragon versions.

Each version represented by a contract
Each version of the Green Dragon Class is compliant with a contract. Where a property is required, it is filled in. Note that this doesn’t mean that the definition is a “good” definition: that’s a decision for individual game developers, taggers and raters to make. All the contract does is ensure that the data implements the requirements. Note also that any well-designed user interface won’t show six hundred fields where only six are required. Authoring clients should also implement the contracts, revealing precisely the number of editable fields required.
Getting value out of agreement
So we have a bunch of versions and some of them are in compliance with one-another. Where does that get us? This is where we introduce the final piece of the puzzle: the client games.

Each client game implements a contract to filter data
Since each client game can also implement a contract (it’s optional, but very useful), they can ask for content that they know will suit their particular needs. A WiRPS character, abiding by the WiRPS contract will work in a WiRPS game. The developer might choose to tag a specific entry that she likes, but if she wants to rely instead on user ratings, it’s important to know that the version she receives will meet her needs. The two PokeUp games can draw from different versions, but the PokeUp contract means that the version will meet the minimum PokeUp requirements and won’t introduce bad data.
The Unknown Game has no contract. The red cross through the arrow might be a bit misleading. It can still get data, but the absence of a contract makes the nature of the data highly unstable (the developer can go through the database and tag specific versions of course). If the Unknown Game wants to gain the advantages of a contract, the developer can subscribe to an existing one, or, if nothing fulfills his exact needs, create a new one from scratch or by sub-classing.
Note that one of the big advantages of subscribing to a contract is the knowledge that someone else has already come along and defined a plausible gaming environment for you. They’ve considered what properties define a workable world for a particular purpose, and you can build off their work. As with other Wikiup features, this frees up the developer to focus on new features, rather than re-inventing old ones.
why associate a single contract with each version? what if the content server accepted any submission of green dragon, and lazily decides which contract(s) it meets.
so when i define my green dragon, instead of saying this is a WiRPS green dragon, I simply define all the attributes required for WiRPS. then when a green dragon meeting the WiRPS criteria is searched for, mine comes up as an option. this way mine will also come up as an option for any contract that represents a subset of WiRPS, even contracts that were created after my dragon.
this version would allow more sharing of objects between games, as instead of asking whether the object was created *specifically for my game*, it asks whether it meets the demands of my game.
@travis
Not unreasonable. I like the idea that a single version could be used for more than one contract, but I have some concerns it loses a few of what I see as the advantages of the contract.
First, presenting a content author or developer with a contract is a huge assistance in creation. It presents both author and developer with a known, working system towards which they can build. It reduces the number of properties the content author has to look at and thereby simplifies the UI when entering data. (I can imagine an answer where the content tool can enforce a contract, even if the system doesn’t innately require it. That would possibly solve the UI problem.)
Second, lazy assignment presumes that a definition which includes all the necessary properties is therefore suitably compliant with the contract. But I’m not sure this is necessarily the case. For example, two game systems might have an intelligence property, but one also has wisdom and intuition properties. The author of the first system presumes that intelligence represents all mental processes, while the author of the other shifts game balance by moving responsibility for certain processes to these other properties. I’d be concerned that we might end up with versions well-suited to one contract (and therefore highly rated), but poorly suited to others for which it might happen to qualify.
Finally (and this is an area where you know more than I, so I’ll defer if you think I’m wrong), I would imagine that searching the DB for compliant versions in this manner would be very slow. Surely it would be far faster to assign a contract ID to each class, rather than build a lengthy WHERE statement?
I appreciate your further input.
Good question and good answer
That’s the general idea that I had in mind. In a data storehouse for multiple games and game types, it seems to me that flexibility is important in the storage service and game and tool cohesiveness has to be left to the individual games and tools. Editors not tied to any particular game could even show a list of the contracts the current object meets and update it as attributes are added and removed, while editors with a more specific focus can simply offer a fixed list of required attributes.
That’s a really good point that I hadn’t considered. A partial solution could be that an *intended* contract is (optionally?) specified in definitions, and those are favored in queries. Submissions that don’t even meet their intended definition can be rejected outright. This devalues the flexibility somewhat though, because if I really want to create a game-agnostic creature it may just not show up anywhere.
Yes absolutely, though I suspect we’ve been thinking of different schemas all along. My concept has been that attributes of objects are in a separate table with their name and value and a relation to the object, trading speed of some queries for flexibility and space. This means that as new contracts are defined their attribute lists don’t have to be a subset of a master list that comes from the columns of the classes table.
I’m pretty sure this schema would just require one JOIN and a long WHERE statement to get the compliant objects list and do it all in one DB hit. If the storage service ended up scaling out to multiple application servers you may want to do the filtering in the application code rather than on the DB. With the hybrid approach from before the difficult task of finding all compliant objects could just be a fallback after searching by intended contract.
The idea has a lot less punch with intended contracts added in – it starts to feel like an unnecessary appendage.
So here’s a different idea: maybe querying for objects by a contract also gets objects in that contracts subclasses? It slows down the query for an object again but makes headway in the ‘meaning of intelligence’ mismatch issue.
I’m looking for a way to promote cross-game objects. Obviously multiple games could subscribe to the same contract, but these contracts still represent a big fragmentation of the content. Wikipedia is so excellent because millions of users collaborate on one big pile of content. If I can just decide to be a TwitchRing developer and work on only objects for TwitchRing contracts, how is this very different from the “share your character/board/…” stuff that’s already out there on a game-by-game basis?