PBBG Engine Update

by Cameron Albert 27. November 2007 16:06

Work continues on Perenthia and my PBBG Engine. I think I got the core PBBG engine framework complete, at least complete enough to start porting over the content items from Perenthia. My goal is to get a small area working with a few items, monsters, etc. before I port over the entire database.

I am hoping to improve performance in this new version as well as complete several of the features I didn't get implemented in Beta 1. The engine uses a lof of in memory objects while still persisting the world to the database. Running a lot of this in memory will eat of memory on the web server but will hopefully improve performance in regards to interactions from users. The main bulk of the places or rooms will be loaded up into memory when the application starts. Along with this load will be a load of NPCs and items located in towns and designated areas. Then, whenever a player logs in and begins playing their player object will be loaded into memory as well. At regular intervals the world state will be updated and player objects persisted to the database. Inactive player objects will be saved and then discarded from memory until the next time the player logs in.

Loading these objects into memory will keep the database connection initialization and IO traffic to a minimum and help speed up actions such as moving around and engaging NPCs. Since I don't know of anyone actually doing this I'm not completely sure it will work. :) My testing so far is working great and at most I may need to beef up the RAM on the web server.

I am still planning for a January release of Beta 2 and depending on how that beta goes; a full release in the early Spring.

SQL 2005 XML Data Type, Stored Procedures and Lists

by Cameron Albert 14. November 2007 17:41

I've seen a lot of stuff out there regarding the SQL 2005 XML data type but most of it is just regurgitates the MSDN documentation. That's fine and all but what about practical uses of it? Well, I have a practical use sample. In building my persistent browser based game Perenthia I have a concept of a Place. A place is a virtual space in which objects are stored. For Perenthia the places represent the various rooms or tiles players move around on. The place or room has exits defined that allow the player to move from one place to the next. The exits are the typical directions; north, south, up, down, etc. In the database I have a Places table and a PlaceExits table. The Places table stores all the information regarding a place and the PlaceExits table stores the placeId along with a directionId and destinationId so I know what exits are available in any room and what rooms they lead to.

The simplified schema for the places would be:

 Places Tables

 In the stored procedure that retrieves the place information I use the following query snippet in the select clause:



                e.DirectionId        AS "@directionId",
                e.DestinationId        AS "@destinationId"
                dbo.PlaceExits e
                e.PlaceId = p.PlaceId
            FOR XML PATH('exit'), ROOT('exits')
        ) AS ExitsXml

    FROM dbo.Places p 

 This creates an XML fragment I can then parse in the application to fill a collection of Exits on the Place object.

When saving place information I pass XML generated from the Exits collection in a stored procedure like so:

CREATE PROCEDURE dbo.Places_SavePlace  (@PlaceId int, @ExitsXml xml)

From within the save procedure I perform an update or insert of the place data and then execute the following sql to insert and update the exits for the current place:

    -- Exits

    -- Process the existing exits first

        DestinationId    = e.ex.value('(@destinationId)[1]', 'int')
        @ExitsXml.nodes('/exits/exit') as e(ex)
        PlaceId = @PlaceId
        AND DirectionId = e.ex.value('(@directionId)[1]', 'tinyint')

    -- Process any new exits

    INSERT INTO dbo.PlaceExits
        ObjectId, DirectionId, DestinationId
        e.ex.value('(@directionId)[1]', 'tinyint'),
        e.ex.value('(@destinationId)[1]', 'int')
        @ExitsXml.nodes('/exits/exit') as e(ex)
        e.ex.value('(@directionId)[1]', 'tinyint') NOT IN
            SELECT DirectionId FROM dbo.PlaceExits WHERE PlaceId = @PlaceId

This is working pretty well and keeps me from having to loop through the exits in the application and make multiple database calls. 

Templates and Objects

by Cameron Albert 13. November 2007 17:23
My PBBG engine being used for the Perenthia 2 beta will consist of templates and objects to define all game related world objects. Everything within the virtual world will be an instance of an object or object record. Each object record will be based on a template instance or template record. Using this model I will be able to add templates for things like swords, monsters, etc. and then create object records for each in game instance.

Tags: , ,

Game Development | Perenthia PBBG

Game Play Considerations

by Cameron Albert 13. November 2007 13:58

What I am wanting to do with this next beta version of Perenthia is to provide players with several avenues for advancement and various activities they can participate in either solo or against other players. I think I've got the database and engine design felxible enough to allow this so I've been putting together lists of activites, quests, etc. that the players will be able to do in game.

I want new players to be able to feel a sense of accomplishment early on but I don't just want the monsters to get harder as they level, I want the whole game dynamic to change as you gain more experience. An example of this might be that in early levels you are runnning around the wilderness killing various monsters but as you level up the monsters stop giving experience, forcing you to venture into some of the dungeons. In the dungeons you find harder monsters but also encounter situations where other skills come into play such as solving puzzles, etc. Then as you move beyond these levels you will need to start aquiring heavy duty items such as a ship or airship in order to venture into the mountains or cross the oceans. These are just basic ideas I've had and want to be able to incorporate them into the game to make the fun and challenging at all levels instead of just another level treadmill game. I know I get bored of most role playing games after the first 10 levels or so because it is just the same thing over and over again. I am hoping that I can break out of this mold and create a fun and lasting experience for players. 

Tags: , , ,

Game Development | Perenthia PBBG

Performance and Browser Based Games

by Cameron Albert 9. November 2007 10:31

One of my biggest concerns for my persistent browser based games, aside from gameplay, is performance. Persistent browser based games have the same issues that normal client/server applications have in regards to internet latency but with a PBBG you do not have a persistent socket in which to push data from the server. This limitation makes it difficult to to real time player activites. Most PBBGs seem to be strategy games operating on a turn based daily type of cycle. This is probably the most useful model but what if you do want to offer real time interaction? Real time interaction can be handled via AJAX in that you can poll the server for new information every few seconds but you could run into some serious performance issues if you send a lot of data down the pipe when actions occur. For that reason I am trying to work out an AJAX based system for downloading game content in the background while the player moves about the world. Once I get the Silverlight components built and tested I should be able to accomplish the same things with Silverlight and provide a nicer user experience.

I think I got just about everything ready for my new PBBG engine so now I can start writing the database queries for the standard commands the system will accept. I am focusing on performance as much as possible for this new engine. Perenthia is working OK but is a little slow when moving around. I can reduce this somewhat by performing asynchronous calls to preload a lot of the data on the client but I still need to stream line everything. After all, in order to move I don't need the player profile description coming back from the database, I just need the information related to moving. 

Tags: , , ,

Game Development | Perenthia PBBG

Database Model for a PBBG

by Cameron Albert 9. November 2007 00:22
I've worked on some large projects in the past with 500+ database tables but I have yet to see any persistent browser based games or any games get up that kind of table count. I only have 61 tables in Perenthia right now with a few more features to add which could possibly add another 10 tables. I would be curious to see a larger model, to see what kinds of things are handled. Right now I have tables for users, roles, places, things, avatars, skills, attributes, quests, guilds, professions and an assortment of lookup tables for things like item conditions, materials, titles, levels, etc.

Tags: , , ,

Game Development | Perenthia PBBG

PBBG Engine Core Object Structure

by Cameron Albert 6. November 2007 13:20

The core of my PBBG Engine consists of a Place and an Object. A Place is a spacial definition and can represent a room, world, universe, etc. An Object is anything that can reside within a place, meaning all people, monsters and items are Objects. The Places and Objects are defined using meta data so that properties of an Object are the meta data of the object. This meta data is stored in a seperate table from the object and retrieved as XML when an object is queried. Places work in much the same way with a few pre-defined fields such as the name and x, y, z location of the place. Going this route will allow me to have different objects defined in different games without having null database fields that are not used in all games.

Another example would be a Sword. In Perenthia a Sword dervies from Weapon which dervies from Thing which implements the Object interface required by the PBBG Engine in order to persist the properties of the Sword in the database. I can then create instances of the Sword class when Swords are crafted or purchased. Each level of inheritence can implement properties that will persist for each Sword instance created.

Sword : Weapon : Thing : IObject 

So far it seems to be working pretty well and with the XML features of SQL 2005 the querying of the data is very fast. I am hoping to get Perenthia ported over to this new framework soon as it will provide a more flexible system and allow me to manage game content a little easier. 

Some New Stat Panel Designs

by Cameron Albert 1. November 2007 23:52

Here are some of the new stat panels I have been working on for the persistent browser based game Perenthia. I may use these for other games just depends on the game. I am making these into server controls that will render divs without the INamingContainer scheme of naming so they can be accessed a little easier via JavaScript and my AJAX calls.

Perenthia Stat Panels 


Tags: , ,

Game Development | Perenthia PBBG

Engine Structure

by Cameron Albert 30. October 2007 00:05

I am structuring my PBBG game engine to be as flexible as possible in order to build various types of games. In order to do that I need to abstract out the components of the engine. Since persistent browser based games are, well, browser based, I decided to follow the normal n-tier model. I am creating a data tier, my actuall database, an application tier which is the engine and will handle client connections, authentication, commands and reading and writing to the database. On top of the application layer will reside the game layer which will be customizable libraries that will use and access the application layer. This follows along the MUD driver and MUD lib pattern where my engine will be the driver which will persist data and handle all communications and my MUD libs or games will be written in an OO fashion to take advantage of the game engine.

The engine is being written in C# and in such a way to take advantage of features of ASP.NET such as HttpModules and HttpHandlers. 

Command Processor

by Cameron Albert 23. October 2007 00:10

For my PBBG Engine I am developing a command processor independent of the client interface. The reason for this is that I want to be able to build different interfaces such as a mobile interface, silverlight and/or flash interface. I want all the interfaces to process the same commands and be able to handle the same output from the server in order to update the UI components.

What I have come up with for the command request to the server is a simple pipe delimited string:


Where CMD would be the command to send to the server and the AUTHKEY would be a key generated when the player logs in through the authentication service that uniquely identifies the player for that session.

The response from the server will be JSON formatted objects and I still have not figured out the complete structure yet. The things I need to send back to the client would be:  An array of messages to display to the player, player's new position should they move, the player stats when in combat, their current target and any other players or mobiles they encounter. Could end up being a large set of data for certain actions so we'll see about performance there.

Tags: , , , , ,

Game Development | Perenthia PBBG

Powered by BlogEngine.NET
Modified Theme by Mads Kristensen

About the Author

CameronAlbert.com I am Senior Software Development Consultant specializing in Silverlight, WPF and the Microsoft .NET Framework. 

I have released an iPhone game called the Adventures of Puppyman that was built using ExEn and am currently working on a WP7 and iPhone version of Perenthia soon to be released.

View Cameron Albert's profile on LinkedIn
See how we're connected

Follow cameronalbert on Twitter


Recommended Books

Silverlight 4 Business Application Development - Beginner's Guide:


Microsoft Silverlight 4 Business Application Development: Beginner’s Guide