Terrarium User Wiki

Here are the 5 key building blocks of the terrarium architecture.

  • Animation
    • The animation and graphics in terrarium are built using DirectX 8. Com Interop is used to allow Managed code to access the Directx 8 DLLs which are written in Unmanaged code.
    • Even though com interop is used to access DirectX, Terrarium still maintains a frame rate of 20 Frames per second. This should give you an idea of Managed Code Performance.

  • Hosting
    • Each animal is given a slice of time in which to perform actions.
    • The time slice a creature is given lasts 2 to 5 milliseconds (depending on the speed of the machine).
    • If a creature does not perform an action within its allotted time slice, the creature is destroyed. This prevents any one creature from hogging the processor and halting the game, in the case of an infinite loop, for example.
    • Once all creatures have been given a chance to act, the cycle begins again.

  • Peer to Peer
    • A terrarium network contains a central “master” server that is used to allow a peer computer to discover other peer computers, it’s “peers” on the network.
    • Assuming a peer computer has a static, public IP address, it calls an XML Web service on the master server that will register it on the list of enrolled peers.  In turn, the peer computer is returned a count of all the peers participating as well as a “peer contact list” of 20-30 IP addresses representing geographically close peers which will be used for creature exchange later in the game.
    • When a teleporter ball roles over a creature on a particular terrarium client, that client chooses a peer computer at random from it’s “peer contact list.”
    • This random peer is queried by the sending peer to see if it has the assembly for the creature in question.  If not, the assembly is streamed across to the receiving peer using a network stream, which is easy to set up as a developer, using the functionality provided by the System.Net classes.  Once the assembly is on the receiving computer’s local disk, the creature’s state object (which contains information on its present size, energy level, etc.) is serialized, using the System.Runtime.Serialization classes, and sent across to the receiving peer over another network stream.  It is then deserialized and associated with the creature assembly.  The resulting creature, an exact replica of the one transported out of the sending peer, is then inserted into the receiving peer’s ecosystem slice and activated.
    • Use your web browser to view statistics of creatures in the terrarium network.

  • Web Server
    • Roughly every six minutes, each peer computer gathers together information on the number and types of creatures alive in its environment, rolls this data up into a data set, and sends this to the central server, where it will be aggregated with the data sets from the other participating peers and published to a public website for statistical reporting purposes.

  • .NET App Updater
    • The .NET Framework greatly improves the deployment process for smart client, or Windows based, applications, by preventing DLL conflicts and allowing systems administrators to both deploy and update these applications via a remote Web server.  To accomplish this, Terrarium actually uses another sample application, the .NET Application Updater, to transparently handle all of the work involved.  This component (which will be released along with documentation on MSDN in February) calls an XML Web service hosted by the master server to see if an update for the Terrarium application is available.  This XML Web services is called 30 seconds after the Terrarium application is launched on the peer computer and every 15 minutes thereafter. The XML Web service simply takes with it the peer computer’s application version number and compares it to the latest version number available.  If there is a new version available, it returns to the peer computer the URL where the new version is available for download.   Using the System.Net classes, the peer computer will download the new files into a new folder, while continuing to run the older version.  Digital signatures ensure that the new version files are authentic and have not been tampered with.  Once the download is complete, the configuration file which directs the Terrarium application executable stub to the folder with the assemblies which provide the game’s UI and functionality is overwritten so as to point to the new folder containing the new assemblies.  The next time the Terrarium application is launched, it will launch with the new version.  The folder containing the last version is always kept around in case there is an error with the new version.  Any older version folders will be deleted to recycle disk space.

ScrewTurn Wiki version 2.0.33. Some of the icons created by FamFamFam. Note: This site is not affiliated with Microsoft Corp. Content is user contributed and provided as-is.