Thursday, July 9, 2009

AstroEmpires Database

Ever play "AstroEmpires"? AstroEmpires is a browser-based video game where players gather into large groups called "guilds". The more successful guilds usually have databases cataloging explored galaxies, planets and moons. I invented a "new" method of getting this information to a database hosted on the web so that everyone could share information in near-realtime.
I'll be taking it down soon but I thought I'd describe its implementation here.

First, I used a JavaScript running in GreaseMonkey (I made versions for Internet Explorer and Firefox) to scrape the data a given user could see while he clicked on different pages.
GreaseMonkey is a browser plugin that allows you to run scripts on top of any webpage you like after it has been loaded into the browser.
If the current galaxy being viewed was "unknown", a URI would be created with parameters and then a new "script" element would be added to the page with the "src" element pointing to my server.
Like so: src="http://mywebserver/script.js?update=true&sector=55:43:55:11..."

Of course, a server-side JavaScript isn't processed on the server. I had a Windows server on the other side running IIS and changed the .js extension to be treated like an 2.0 web page.
C# code generated JavaScript to be added back as the element on the fly based on what parameters where given. In this way, a SQL database also running on the server could be updated or queried.

I expanded the application to create reports of the "explored universe" on the same server that users could login to, and added "username" and "password" parameters so that only those authorized could use the site and the same authorization could be revoked if I so desired.

I eventually turned over most of the administration to a close friend and allowed him to change the database to Oracle. I allowed him to login to my server via RDP.
I considered writing an AJAX realtime chatroom application as well, but discovered this would be a significant challenge for a "spare-time" project related to a browser-based video game. :)


  1. I would be interested in learning how to do this. I am looking for suc Database for my guild also... I understand this is kept very secret and guarded, but im interested in learning and would like to actually see the script working on my browser. I think its wonderful that people can do stuff like this and thats why im looking into doing this for myself.

  2. Hi Mike,

    I have a proposal for you and would like you to contact me at


  3. I write Databases for Astro Empires. If you need one contact me at