Gotcha! Fake MMO Asteroids April fool :)

Haven’t most April fools jokes got a bit silly lately? They’re more just funny than actually fooling you. This year, I thought I’d raise the bar with a completely fake MMO Asteroids, but I could never imagine so many of you would be taken in. I’m so sorry.

It all started around a year ago. There’s an example on my CreativeJS course where circular particles exert a little force on each other and they wander around rather pleasingly. An attendee decided to make them triangular and point in the direction that they’re moving in and voila! A system of circling, avoiding, flocking AI bots emerged.

All I had to add was some basic collision detection, bullets, and despite the simple behaviour rules, it was very pleasing, and very convincing. So I thought I’d make it more obvious – I added a “kill mode” that kicks in after a random time – surely you’ll realise it’s fake when every single other ship turns on you and mows you down? But instead, many assumed it was anti-spam or AI bots gone wrong.

Many amazing comments followed on twitter, most really impressed, a couple a little dismayed that everyone was picking on them. I couldn’t help but feel sorry for Ekene Ijeoma who simply tweeted ‘help’ as all the other ships turned on him. (It’s his screen shot in the header).

But some suspicion emerged. Kudos to Jon Schall who was the first commenter on the post. But even Jon didn’t quite realise it was an April fools for a while (he blames lack of coffee).

There was a steady stream of traffic during the day, but things really took off in the evening when it made it to the top of Hacker News. The comment thread started in awe, then confusion, and then anger as people realised it was fake.

I must admit that it made me giggle reading the thread as various theories emerge. The “kill mode” starts randomly, and yet many thought that their actions were somehow triggering it. Someone suggested clearing their cookies to reset the weird occurrences. But of course, one or two figured out that you could pull your network cable out and the game still worked fine. 🙂

The sad truth is that if it was real, it probably wouldn’t be as dynamic or as much fun, and there’d certainly be fewer players. Rob Hawkes has made in-roads with Rawkets, but making it reliable, scaleable, and most of all fun is a huge challenge. Maybe I’ll try it for real some day and find out (not that I’ll ever be able to convince you that it’s real from now on…)

It’s been great fun, a fascinating experiment, and I hope you had fun. And if you were taken in, I really hope you see the funny side. The only question is, how will I get you next year..? 🙂

[UPDATE] just thought I’d add this highly amusing thread from OverClockers

Node.js experiment: MMO Asteroids

I’ve had my eye on Node.js for a while now so I jumped at the chance to attend Remy’s excellent workshop a couple of weeks ago. Most people associate node with websockets but actually node is a hugely versatile platform capable of running powerful servers and web-apps.

That said, anyone who knows me will know that I’m fascinated by real-time multi-player games (remember my Lunar Lander trails?) so the first thing I’ve done is put together a little demo to test out the MMO capabilities of the node.js socket server. It’s a Asteroids-esque space shooter, with one rocket per person, use the cursor keys to fly, and space to fire.

Synchronisation

It’s a very early prototype, I’m still working on the system to keep all the ships in sync, so you might see some strange movement. I haven’t tested it with that many connections yet so it’ll be interesting to see how well it holds up under fire – please spread the word so I can help to test how it scales up!

There’s been some interest this week with Mozilla’s BrowserQuest (also based on node.js) and that uses a point and click to move mechanism. This is a classic way to reduce the amount of bandwidth and it gets around latency issues, as each move is just a single message to and from the server.

Dead reckoning

It’s much much harder to create a system with free movement and collisions, as all the data the server gets for each player is already out of date. I use a primitive form of ‘dead-reckoning’. As well as the position data, I also send the server the current velocity and a time stamp.

The data for each player is sent to the browser, along with the time-stamp and velocity. It’s then up to each client to smooth out that motion, and predict where each ship should be now, if the player carried on along that trajectory. Of course this is quite an inaccurate system, and I’m still refining the algorithm

Security

Any in-browser game is fundamentally hack-able. That’s why I’ve set up an ‘authoritative server’ system. Although the browser updates all the physics for the player, the server authenticates the ships movement to make sure there’s no funny business! The collision detection is performed locally and then the damage is verified and reported by the server.

Node.js

I’ve been really impressed by the performance and accessibility of node, apparently the V8 JS engine that powers it is can in some cases be 30% of the speed of native compiled C++ code. And there have been huge advantages in using the same JS code on the server and client. I’m looking forward to seeing how well it scales.

Next steps

It’s a really early demo, and I have lots more work to do, but please test out the mechanism, and let me know how the synchronisation and dead reckoning feels. There may still be the odd glitch. I’ll be keeping an eye on it over the next couple of days so I’m sure there’ll be the odd drop-out. Let me know how it works for you!

Play MMOsteroids

[UPDATE] yes, yes check the date. Full confession.

Giving ElectroServer more memory

So after last time, I thought I’d given ElectroServer more memory, but it turns out I hadn’t. I’m not exactly sure why, but I suspect it’s something about how Media Temple is set up.

So rather than call the main ElectroServer app (which is just a shell script), I’m opening the ElectroServer jar file, and that way I can tell java how much memory to use (and other options) as parameters.

I’m pretty sure Java is installed somewhere on Media Temple (you need to install the dev tools) but I couldn’t find it anywhere! And if I just typed java it couldn’t find it. I even ran a find command, but it was nowhere! But then I realised that the Java runtime is packaged with ElectroServer in the jre folder!

So with a bit of fiddling I worked out that I could start ElectroServer with more memory by running the jar file, but I had to do it while in the server subfolder within the ES install.

../jre/bin/java -Xmx128M -jar lib/ElectroServer4-bootstrap.jar -mode StandAlone -config config/ES4Configuration.xml

where 128M is the amount of RAM made available.

[UPDATE]

There is a better way! Thanks to Paul Hayes (a colleague at Plug-in Media, see comments below) I have now realised that ElectroServer’s main app is nothing more than a shell script that you can edit. Furthermore there is a line you can uncomment right at the top to change the Java parameters :

# Uncomment the following line to add additional VM parameters
# INSTALL4J_ADD_VM_PARAMS=

Change this to :

# Uncomment the following line to add additional VM parameters
INSTALL4J_ADD_VM_PARAMS="-Xmx512m"

Where 512 is the amount of RAM in Mb you want ElectroServer to use.

ElectroServer security sandbox violation error

I suddenly started getting a really weird error from Flash when trying to connect to ElectroServer :


Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: http://games.seblee.me/moonlander/MoonLanderViewer.swf cannot load data from 72.47.193.154:9899.

I posted to the ElectroServer forums and quick as a flash, Teresa got back to me – apparently ElectroServer was running out of memory. But apparently that’s not surprising – all Java gives it is 64Mb by default! But before I could fix it I had to stop ElectroServer from running, which isn’t easy when it’s running in the background.

Earlier Teresa had told me how to do this.
Continue reading “ElectroServer security sandbox violation error”

Multi-user gaming in Flash – Lunar Lander tests

Lunar Lander multi-user tests

Lunar Lander multi-user tests

Anyone playing my Lunar Lander game won’t know it, but we’re spying on them! The game gets around 20,000 hits a month, which is very roughly one a minute or so, so I thought it’d be the perfect vehicle to test out some real-time gaming techniques.

I’ve replaced the original game with one that transmits your position to ElectroServer, although you won’t notice any difference at all. The only way to see the all the current players is via the swf below :
Continue reading “Multi-user gaming in Flash – Lunar Lander tests”

Further adventures with ElectroServer

As there has been a lot of interesting talk on my recent live chat example I thought it’d be nice to actually see what you’ve been saying! So I checked out the Logging Chat By Room tutorial on the ElectroServer wiki.

After some minor tweaks I got the Java extension compiled (the methods should not be marked @Override as the class isn’t extending anything) and tested them locally – all was fine.

So I uploaded them to the server and restarted but ElectroServer wouldn’t come back! There was a Java error message and it was just way beyond my capabilities to troubleshoot it. Thankfully, Teresa from ElectroServer checked the forum at 7.30am on a Sunday morning and responded to my plea for help! She assures me that she’s not usually so ultra-responsive but I have yet to see evidence of that! So far, the support I’ve got from Teresa is just phenomenal.

I never did quite get to the bottom of what happened, but I suspect it was a problem with a persistent room as I had been playing with those settings in the web admin interface (frankly without really knowing what I’m doing 🙂 ) . But I fixed it by reinstalling ElectroServer with these instructions, and I was back where I started! I’m still working on getting chat logging done, but in the meantime I wanted to try something a little more interesting to me. There’s a tutorial on the ElectroServer wiki which extends the chat example and shows everyone’s mouse as they move it around!

And here’s what it looks like screen captured :

And here’s the actual app!
Continue reading “Further adventures with ElectroServer”

Installing ElectroServer on MediaTemple

Further news to report on my ElectroServer adventures! I’ve now got an ES4 installation up and running on a MediaTemple Dedicated Virtual server. It was actually pretty easy too, thanks to this tutorial from Greg Sidbury.

I had no problems following although there are a couple of bits that confused me. The first was that the download link didn’t work so I just found the Linux RPM link on the ElectroServer download pages and used that, which for the current version is :

[not available]

The other thing that got me is that I put in the domain name into the ES4Configuration.xml which didn’t work. I should have put the ip address for the virtual server (which you should find in your Media Temple account or you could always just ping your domain from a terminal window).

Once I’d opened the ports and started the server running I tried to telnet in to port 9898 (the default chat port) but it was refused. So I edited the crossdomain.xml on the main webserver to include the IP address of my home internet connection and it seemed to be OK after that. (At least I think that’s what fixed it!).

So apart from a few minor hassles it was pretty seamless and only took me an hour or so. I must admit to feeling way out of my depth, this isn’t something I’m particularly expert on so please feel free to comment with further advice 🙂

Installing ElectroServer on Mac OSX

[This post is obsolete – ElectroServer doesn’t seem to exist any more]

What else to do in the Christmas holidays but finally get my head around ElectroServer? 🙂 Of course the first (sometimes significant) hurdle in getting started with any multi-user technology is just installing the server on your machine! ElectroServer4 (ES4) is Java based so it should work on OSX, but most of the documentation is for Windows, so I spent today installing it on my MacBook and thought I would share what I learned.

ES4 runs on Java 1.6 and OSX is shipped with 1.5. You can find instructions on getting the update here, but whatever you do don’t complete the steps to make 1.6 the default Java Virtual Machine (JVM), otherwise FlexBuilder won’t work any more!

Now you need to download the Unix package (the one marked “without JVM”) on the ElectroServer downloads page [sorry, no longer available], and unzip it somewhere suitable (I put it in my documents folder).

Then open up a terminal window and navigate into the folder where you unzipped it. (Handy shortcut : type “cd” followed by a space and then drag the folder from the finder onto your terminal where the full path name will be inserted).

There’s a file in here called ElectroServer that you run but you need to tell it where to find the latest JVM. According to this rather useful thread [link no longer available] you can do this by typing :

export INSTALL4J_JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/

And then start the server normally by typing :

./ElectroServer

At which point you should see the happy message :

16:28:08,523 [main] INFO  DisplayLogger  - 
-=-=-=-=-=-=-=-
Starting ElectroServer 4.0.6
-=-=-=-=-=-=-=-
Computer Information
	Operating System: Mac OS X
	Operating System Architecture: x86_64
	Processors Available: 2
	Memory Available: 682Mb
-=-=-=-=-=-=-=-
Virtual Machine Information
	Virtual Machine Vendor: Apple Inc.
	Virtual Machine Version: 1.6.0_17
 
 
16:28:14,863 [pool-1-thread-1] INFO  DisplayLogger  - 
-=-=-=-=-=-=-=-
ElectroServer has started successfully

After several hours of fiddling around this was somewhat of a relief.

The next problem was that I couldn’t navigate to the admin panel which by default you can find at 127.0.0.1:8080/admin. But whenever I pointed my browser at it all I got was an empty binary file in my downloads folder. Thank goodness for Twitter where Matt Bolt saved the day with his tweet :

@sebleedelisle Make sure you’re using https, not http – I run into this constantly 🙂

Thank you Matt! I have no idea how I would have figured that one out without you! So I just navigated to https://127.0.0.1:8080/admin and it worked.

I expect to be furthering my adventures in ElectroServer over the next few days so I’ll keep you informed of how I get along.