Rotates.org

January 4, 2010 - Non techies avert your eyes

The server is really starting to take shape now. Turns and phases flow along nicely, and I’ve spent the last few days working on the spellcasting system. If you’ve read the Google Code page on Spells you’ll know that the spells themselves are simply sandboxed Javascript functions. I had thoughts before about writing some kind of scripting language for the spells because I wanted maximum flexibility, but it dawned on me that simply giving the spells access to the game and board data themselves in the native language would be the best way to do it. I also not long after that thought about making the validation step the spell goes through beforehand (i.e. where it tells you you can’t cast the spell here, or you can’t cast it on this piece or whatever) in a similar manner, but subsequently rejected it for one very good reason: the clients also need to validate at their end, and they may not be written in Javascript!

For those interested in creating a client (and because the code isn’t yet ready for viewing!) here’s the current output of a test run on the server. Note that games, pieces and spells have a unique game ID, which is a letter followed by an incrementing numeric value. One of the current things I’m working on is cleaning up the code so all possible references are made to these UIDs, and not directly to the objects, as this will make things safer and more manageable within the engine at the expense of a little bit of performance (no doubt I’ll rewrite much of this at a later date so there are two ‘levels’ of code; the UID data-driven level that the users interact with, and the deeper object-driven stuff that processes things.

{
  "turn" : 1,
  "phase" : "select_spell",
  "interaction" : "all",
  "finished" : true,
  "actions" : [
    {
      "type" : "select_spell",
      "player" : "lewster32",
      "time" : 1262563476,
      "data" : {
        "spell" : "s0"
      }
    },
    {
      "type" : "select_spell",
      "player" : "bobster16",
      "time" : 1262563476,
      "data" : {
        "spell" : "s6"
      }
    }
  ]
}
{
  "turn" : 1,
  "phase" : "cast",
  "interaction" : "sequence",
  "finished" : true,
  "actions" : [
    {
      "type" : "cast",
      "player" : "lewster32",
      "time" : 1262563476,
      "data" : {
        "spell" : "s0",
        "target" : {
          "x" : 0,
          "y" : 1
        }
      }
    },
    {
      "type" : "spawn",
      "player" : "lewster32",
      "time" : 1262563476,
      "data" : {
        "x" : 0,
        "y" : 1,
        "occupant" : {
          "uid" : "p2",
          "owner" : "lewster32",
          "properties" : {
            "movement" : 1,
            "combat" : 7,
            "defense" : 8,
            "maneuver" : 6,
            "resistance" : 4
          }
        }
      }
    },
    {
      "type" : "succeeded",
      "player" : "lewster32",
      "time" : 1262563476,
      "data" : {
        "spell" : "s0",
        "target" : {
          "x" : 0,
          "y" : 1
        }
      }
    },
    {
      "type" : "end_turn",
      "player" : "lewster32",
      "time" : 1262563476
    },
    {
      "type" : "cast",
      "player" : "bobster16",
      "time" : 1262563476,
      "data" : {
        "spell" : "s6",
        "target" : {
          "x" : 11,
          "y" : 1
        }
      }
    },
    {
      "type" : "spawn",
      "player" : "bobster16",
      "time" : 1262563476,
      "data" : {
        "x" : 11,
        "y" : 1,
        "occupant" : {
          "uid" : "p3",
          "owner" : "bobster16",
          "properties" : {
            "movement" : 1,
            "combat" : 6,
            "defense" : 5,
            "maneuver" : 2,
            "resistance" : 4
          }
        }
      }
    },
    {
      "type" : "succeeded",
      "player" : "bobster16",
      "time" : 1262563476,
      "data" : {
        "spell" : "s6",
        "target" : {
          "x" : 11,
          "y" : 1
        }
      }
    },
    {
      "type" : "end_turn",
      "player" : "bobster16",
      "time" : 1262563476
    }
  ]
}

These are what every player will receive at the end of each phase. They contain each action performed by the players in the order that they performed them, and timestamped for reference and backup purposes. Players have relatively limited access to the game in terms of actions, just like in the original game. A player may select spells, cast spells, move and attack pieces and end their turn. From these actions however, more actions may occur, so a player casting a spell on tile x will set off a chain of actions, where the server rolls against the spell’s chance, then (if successful) performs the spell’s effect, which may be to spawn a new piece or whatever.

Soon I’ll be locking down the format of these outputs, and documenting the errors and notices a user receives directly. This will allow for anyone wishing to do so to begin planning or working on a client – and I sincerely hope people do!

December 31, 2009 - Progress

Just a small update to let everyone know I’m still working feverishly on Archaos’s server. It’s looking pretty good at the moment, and the server currently features:

  • Creating games
  • Joining and leaving games
  • Creating and moving pieces on the board
  • Extensive move validation (bounds checking, path checking, engagement checking etc)
  • A customisable turn/phase system (this has been an absolute pain in the arse to implement – but it appears to be working as intended now)
  • Full JSON messaging system (you talk to the server in JSON and it talks back to you in JSON, there’re no sockets, special protocols or proprietary formats)

The Google Code wiki is somewhat out of date (already!) as things slot into place during development, and I’ll update it as things become more solid. I’m currently using a private SVN, though as the project nears a working first version (and if there’s any interest) I’ll be happy to give access to the SVN – there’s a lot of experience and expertise out there, and I’d greatly appreciate a second opinion on aspects of the code!

December 29, 2009 - What have I created?

SCENE: DANK LABORATORY FULL OF OLD RUSTING BULBOUS MACHINERY, GLOWING FILAMENTS AND RAIN DRIPPING THROUGH THE OPEN ROOF ONTO THE STONE FLOOR

Lew: (Screaming) “MUHAHAHAHA!! IT’S ALIVE”

Ahem. Yes, I’ve been beavering away over the last few days and I can finally reveal a proper screenshot of some proper code doing something. Unfortunately, I’ve not started on a client yet, and I’m using a quickly thrown together browser-based console to work with it. However, it is a screenshot, and so I’ll upload it!

One of the fantastic bonuses of writing in Javascript is I have an interpreter with a great debugging suite at my disposal right from the outset with no messing on – Archaos’s core code is designed to run locally in a browser as well as server-side, and an adaptive messaging system will smooth the whole experience out so that what goes in and what comes out is the same wherever the clients or the servers are located.

December 26, 2009 - For people with Javascript-shaped eyeballs

I’ve started fleshing out the wiki on Archaos’s Google Code page – certainly worth a look if you’ve any technical interest in the project. Take a look and let me know your thoughts – I’ll be adding more content to the wiki as I sort out through my stacks of notes.

December 23, 2009 - Belated excuses

It’s been a very busy year for me, mainly due to my commitments at work (let me assure you this won’t be a long winded entry which eventually leads to ‘so thanks for your support but I quit’!) and as such the big project that I’m sure 99% of visitors to this site are waiting for is still under slow methodical planning and development.

It’s dawned on me that I’ve been very secretive even about the name of the project, so I think at the very least I owe you guys that – so here it is!

Archaos

I think this is slightly more pleasing than ‘Chaos Enhanced Enhanced’!

I’d also like to talk about the plans regarding its launch and features, because I’m taking quite a different approach to the norm. Early on in the planning I wanted to make sure Archaos could be playable by as many people on as many different formats as possible. The general idea I had was that I’d write the game in haXe and then generate the various sets of code for servers and clients from that one source, and ‘et voila’ I’d have a cross-platform game. Since then, I’ve spent a lot of time at work playing with various web-based JSON APIs, and I’ve watched some fantastic projects appear (such as node.js, Persevere and CouchDB) and realised that, in fact, Archaos’s core could live on the web as a data-based API.

It makes a lot of sense when you think about it – you have a scalable server with a scalable database, written in Javascript (a language which I simply adore), using JSON as its end-to-end data format, accessible by anything with a web connection. Being turn-based, it doesn’t need to rely on any complicated comet solutions, and (and here’s the really exciting part) you can make your own client in whatever language, format or platform you like!

I’m really big on open source and open web, and so it’s really exciting for me to think that, although I will still be creating clients in Flash and (with Flash CS4’s leave) for iPhone, there’ll also be a well documented API out there that can be used by anyone. You can easily have pure HTML/Javascript clients, text-based clients to run in terminal windows and so on – and no matter which client you use, you’ll be able to play Archaos with anyone else.

As I said before, I’ll also be making the server and client source available (though the server source will likely need a closed development phase after launch so I can work out bugs, security issues and exploits before I make it available to all) so anyone with a Linux box can host their own server – though I’m not quite sure why anyone would want to do this at the moment, as a server will handle many hundreds, or possibly thousands of concurrent games with ease, and take care of matchmaking, login and so on. In fact this area of development will probably result in the separation of the login/matchmaking master server from the core gameplay servers.

So, to summarise:

  • My current work focus has shifted away from a unified client/server architecture, and my time is now being devoted to creating a robust HTTP-based server for Archaos.
  • In tandem to the server work I’ll have to develop a client for testing purposes, and so the first client may be a simple HTML/JS or Flash visual interface.
  • Once these are at a satisfactory level, I will announce a beta period to work out bugs, and then shortly after that I will release full API documentation for the Archaos server (which will have its own snappy name, already got a few ideas) and allow interested parties to get the ball rolling on their own clients.
  • Finally, I’ll finish and release my own client for Flash, and hopefully soon after for iPhone.

As you can probably tell, I’m fantastically excited by this whole project; indeed I can’t see why this hasn’t been done before – though no doubt it has, and I’ve just not looked hard enough… I’d love to hear your opinions on all of this – and I’d also love to find out if other people have attempted something similar!

Edit: Looks like someone has thought of this – in fact pretty much verbatim! http://web.archive.org/web/20031129175919/http://www.openchaos.org/

November 28, 2009 - ColorShift 0.7 (eek!)

Hot on the heels of 0.6, now you can set offsets on a per-selector basis. This means you can alter multi-coloured websites in a relative way! Yay! Download it here.

Note the ‘styles’ item is now (correctly) called ‘attributes’.

Update: 0.71 quick bugfix release! Fixed not working in IE7 (boo!)

- ColorShift 0.6

Sooner rather than later it seems, you can now download Rotates ColorShift 0.6 and bask in its amazingness.

The main change is how you set your selectors; instead of writing your own jQuery to target the elements you want to change, you feed rotColShiftOpts.cssTransforms with an array of objects. This is what Rotates.org uses:

[
	{
		selector: "a, h2, h3, h4, h5",
		styles: [
			"color"
		]
	},
	{
		selector: "#header, #searchsubmit",
		styles: [
			"background-color"
		]
	}
]

Actually it was a bit of a struggle, as I wanted to abandon the DOM-based approach to changing the CSS of every individual element, and go for a global stylesheet change. Easy you say? Just .append/.text a style element. Well, yes, in all decent browsers. Sadly, the IE family seems unwilling to let you tamper with the style element so easily, and jQuery (at the moment) has no elegant way around it. So out came the ‘Lew hacking pants’ with the following solution:

ieStyle = document.createStyleSheet();

$.each(rotColShiftOpts.cssTransforms, function(i, ttrans) {
	newColor = getColorWithOffsets(hue, saturation, brightness, ttrans.offsets);
	var tstyles = "";
	$.each(ttrans.attributes, function(i, ts) {
		tstyles += ts + ": " + newColor + ";";
	});
	tmpTransforms += ttrans.selector + "{ " + tstyles + " } ";
});

if ($.browser.msie) { // *sigh*
	ieStyle.cssText = tmpTransforms;
}
else {
	$("style[title='colshift']").text(tmpTransforms);
}

Anyway the result is that you a) get a better, easier to use syntax for applying the changes to page elements, and b) can be safe in the knowledge the styles will be applied to all elements on the page (even generated ones)  just like CSS should be. Enjoy!

- ColorShift update coming soon

I’ve been playing with various Twitter widgets for WordPress, none of which have been quite ‘right’, so I’ll be creating my own. This has also spurred me to update ColorShift, as the fail is now showing in the code, and it needs a more robust way of applying colours to all elements, including ones added after page load.

Look out for a new version of ColorShift in the next few days, along with possibly a new mini-project in the form of my own Twitter widget for WordPress – jQuery driven (of course), semantic, configurable, and with optional caching and API limit safety features.

Website and content © 2009–2026 Lewis Lane