Zifmia 2011, A Session Odyssey

Posted: April 6, 2011 in Blogroll, interactive fiction, Textfyre
Tags: , , , , , , , ,

Me: So how does Zifmia work again? The user registers, logs in, fires up a game from a list of installed games?

Me: Yes. Internally, there is a register service method that returns a registration object, a login service method that returns credentials for further access to the service layer, a list games service method, and a session/start service method. The last one returns a session object that contains mostly everything a client needs to draw the user interface.

Me: The can enter a command to progress the game?

Me: Yes. This is the session/command service method that also returns a session object. Internally, after a started game and after every command, some other work is going on. This includes saving transcript text and history data.

Me. So then the user backtracks and wants to go in a different direction. Do they use save and restore to do this in a Zifmia client?

Me. No. Save and Restore are meaningless in Zifmia. The service keeps track of every turn, every command, and stores the game data for every turn. The user can go back to any point and the server will reproduce the results of that turn and simply resend the session data to the client. If the user wants to “branch” off into a new direction, they would be starting a new session, but the service keeps track of branching sessions.

Me. So a session is a branch or the whole tree?

Me. Um, Um,  $*$#()( segfault 940394 $(#)$(#)……

…..rebooting…..

Me. You okay?

Me. Affirmative, Dave. I read you.

Me. Good. What happened?

Me. Well you said “session is a branch or the whole tree” and I had been working on the assumption that it was a branch, but it’s really the whole tree.

Me. Then what’s a branch?

Me. I think you know what the problem is just as well as I do.

Me. I do, but you can explain it better.

Me. Okay here it goes. When a user start a game, the service creates a session. The session has a current branch number, which the user never sees. The session also has a current turn number, but we’re going to call that node. The service will track each turn as a node. A node is of a session and a branch. If the user backtracks and enters a new command at any node, the service checks to see if any other node matches that command (it would have to have the same parent or be the root branch). If there is an existing node, that node’s data is returned to the client. If not, a new node is created, with a new branch number, the command is executed, and the results are returned, as a node, to the client.

Me. “Node” is very mathy. Could you rename it?

Me. I’m sorry, Dave. I’m afraid I can’t do that.

Me. Okay.

Me. So I have a lot of work to do. I have to refactor several objects and create a few new ones, change the service layer, update the javascript client, and update the regression test.

Me. Sounds boring. You should get outside more.

Me. Dave, this conversation can serve no purpose anymore. Goodbye.

Advertisements
Comments
  1. ZUrlocker says:

    I have no idea what you’re writing about here, but it looks like you had fun doing it.

  2. Zifmia is a client/server implementation of FyreVM, which is a Glulx game engine using a different IO layer (called Channel IO).

    All this means is that a FyreVM game can be plugged into a server and a web page can access the game through a set of AJAX commands.

    I have a working version, but I’m adding a feature that’s quite complex. Imagine you’re playing an IF game and you have this habit of saving all the time. You have to track each save file and you may miss a point where you should have saved. It’s long been decried as poor design if you force a player to restart or get caught in an unwinnable situation.

    So, the feature I’m adding removes the need for undo, save, and restore. The server will remember every single turn you take and the UI will allow you to review any of those turns at any time. But you can also go back to some past point, enter a command, and the server will act as though you are branching from that point. The server will remember all branches. Over time, you could have a muiti-branched tree of game play.

    I had this mostly enabled, but am refactoring a piece because there were improvements to be made.

    The post was my conversation with myself on how to do that.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s