Tic Tac Toe and Conway’s Game of Life in Javascript

For the Half-Real website (10 years ago!) I made two example programs to support the book’s discussions: an implementation of Conway’s Game of Life and a Tic Tac Toe program that plays perfectly by simply going through all possible game states.

Time passes, and I can no longer count on browsers running the Java applets that I originally wrote the programs in. They never ran on tablets and mobile devices either. And I dislike websites with broken applets.

So I have rewritten them to work in JavaScript. They feel like they always did, except they launch faster – and run on mobile phones and tablet:

PS. Tech notes: I did this using GWT, which compiles Java code to JavaScript. The good news is that GWT really works and consistently converts all Java logic to JavaScript. The more complicated issues concern (as we may expect) that all UI calls are different, and especially that Java is Thread-based, but JavaScript is callback-based, so any program flow that relies on threads (as in my case) has to completely reworked.

Notes on Running an Online World for 15 years

You know about that online world that launched in September 1997 and is still running? No, not Ultima Online, the other one.

I was reading Raph Koster’s notes on the launch of Ultima Online back in 1997, and it made me realize that the online world that I programmed also launched just over 15 years ago, nearly at the same time as UO. If you didn’t grow up in Denmark, you have certainly not heard about it, but it’s called Højhuset (literally high-rise, from the metaphor that it was a series of stacked rooms). It’s still running at www.n.dk (only go there if you speak Danish).

This is what it looks like: It’s made up of non-scrolling rooms in a diagonal grid. Users can dress up, chat, and so on as expected. Users have their own apartments which they can decorate. Here is a screen shot with a celebrity visiting:

Højhuset

And most importantly: You can have nice things. The world was always a bit of a compromise between a chat system and game-like elements such as inventories and a currency, but it turned out that this was quite a feature. There have historically been long-running feuds between users who think of it as a chat system, and those who think of it as a game with the goal of amassing the most items. I initially thought that this would be a problem, but in practice this created social cohesion in each group – this was a valuable lesson for a game designer, that an external enemy does give users reason to come back.

As someone who is into game definitions, the height of the “is-it-a-game-or-not” feud was when a user had found a “Player” class in my program, and used this as proof that yes, this was a game. (New game definition: A game is a piece of software that declares itself to be a game.)

My role in this was always as a subcontractor, but I have been providing support and updates for 15 years now. One of the things I did learn as a programmer was to document my code and avoid any quick & dirty fixes which could come back to bite me. The main program (in Java) has always run on a single server. At the height of popularity, there were 2000 simultaneous users, but the improving speed of servers always just always made it unnecessary to spread across multiple machines.

Of course, there were also numerous attempts at hacking the system, which always is a point of pride for a programmer. People still try, here is even someone posting some debug output from such an attempt on Pastebin.

There were also microtransactions going back to the late 1990’s (this mostly paid via text messages).

Having read & written so much about video games since, it is hard to remember what thoughts went into my head when I was first starting out on this project, but I had played MUDs at the time, and I am sure I had read an article about the need for artificial scarcity in virtual worlds. And the strength of scarcity was one of the things that made the biggest impression on me. In the very early versions, there was no automatic dropping of items – this had to be done manually by a superuser referred to as the “superintendent” (“vice”). When going online, that user would always be met with cries encouraging the dropping of items (“smid!” in Danish). I leave you with a bit of user art, in which the superintendent gets fed up with being asked to drop items.

 

Smid!

(There was actually a brief period of time in which a new chat system was introduced on the site to replace the one I made, but users demanded the old one back. Warms your heart.)

Closer to total Curation/Censorship every Day

This image shows the dialog box that a user received when trying to install Molleindustria’s already-censored game Phone Story. Turns out this is a lauded “anti-malware” feature called Gatekeeper in OS X Mountain Lion.

Users can change the settings, but many people experience the misleading dialog above, not telling the user the truth – that they cannot install the program because they have to enable non-certified apps/developers in system settings. But rather telling the user that the file is “damaged”.

Paolo has a longer discussion of it here, but it does seem like that Apple has made it possible for the dialog to mislead in order to dissuade users from installing software not sold through the Mac App store and/or made by a licensed developer.

[Note: It is unclear whether this dialog is intentional. Some people claim that it is not the default dialog, but some developers experience it nonetheless.]

I wrote about this scenario some time ago as “Fear of an App Planet“: that our ability to easily and transparently develop and distribute games for PCs and Macs is gradually eroding. Worrying.

Fear of an App Planet

(Returning to our regular schedule.)

With Apple announcing an App store for the Mac following the App Store for iPhones and iPads, it’s worth pondering what this means for video games.

  1. It’s a great way to allow the distribution of games of different scope, so why is this the first major commercial internet-based software store for a major operating system? Seems so obvious. (Though Linux users have long had similar systems, though only for non-commercial software.)
  2. The Mac App store will have similarly strict and semi-random policies as the iOS app store. As I have argued before, I think the app store policies are ambiguous and inconsistently enforced by design: this has the desired chilling effects of self-censorship among developers, while Apple can claim that it intended no such thing.
  3. It has historically been the case that console games were heavily controlled and censored, while PC and Mac games allowed for freedom of expression. Assuming that more software sales move from boxed and regular web to the Mac App Store, we are going to see the Mac becoming less of a platform for edgy and experimental content. You can still get your software elsewhere, but convenience matters.
  4. And again: there would be an uproar if a major bookstore censored books according to Apple guidelines, so why do we accept censorship for games?
  5. Which means that the potential future in which all games on all platforms are distributed through app store-like channels … that is a potential nightmare.

New version of Firefox due to FarmVille

If you are using Firefox, you have probably been asked to upgrade to 3.6.6 over the weekend. You may notice that the list of fixed bugs only has one item.

Yes, the primary motivation behind Firefox 3.6.6 is that 3.6.4 introduced problems for FarmVille players. (A new 10-second timeout for Flash sometimes prevented FarmVille from loading.)

From this we can learn that Firefox developers are not (willing to admit that they are) playing FarmVille. Obligatory critical comment in the bug report:

(I have a few comments about the prevalent anti-FarmVille sentiment, but more about that later.)

Guimark2: Some HTML, Flash, Java benchmarks

And now for something completely different.

My past as a Commodore 64 demo programmer means that I find benchmarks quite irresistible. What is the fastest way to accomplish a given task?

Following Steve Jobs’ denunciation of Flash as slow, Sean Christmann recently posted his Guimark2 test suite for comparing vector, bitmap, and text rendering across platforms. Sean built Flash and HTML versions of the tests. One of the clear results was that HTML5 just isn’t that fast yet.

But being mostly a Java programmer, I couldn’t help building Java versions (perhaps I wanted to counter the perception that Java is slow). You can try the Java tests here, Vector, Bitmap, Text and compare them to the tests on the Guimark2 page.

Here are the results from the two machines I tested on:

Test/OS XP, HTML XP, Flash XP, Java OS X, HTML OS X, Flash OS X, Java
Vector 11.9 21.9 20.7 4.5 19.8 31.9
Bitmap 4.3 12.7 208.2 13.0 12.9 42.0
Text 19.2 1.5 11.4 29.9 16.6 14.1

Test results in Frames Per Second (Higher is better)

As you can see, on my two test machines, the Vector test is fastest in Java on OS X, the Bitmap test is fastest in Java on XP (5 times faster than any other platform/language), and the Text test is fastest in HTML on OS X.

Is this always the case? No. As can also be witnessed on the Guimark2 page, these results are highly variable between different OS configurations, browsers. As far as I can make out, really high Java bitmap scores require an ATI or NVidia graphics card, and may not always be present on Windows Vista or 7. On OS X, Flash runs faster in 32-bit Safari, while Java runs fastest in 64-bit Safari (tested here). And so on.

Benchmarking is a lot more complicated than it used to be, but I just thought I’d share these results. The tests also link to the source code if you are interested. Feel free to post your results here or on the Guimark2 page.

PS. Test machines:

  • 2007 Lenovo ThinkPad T60p running Windows XP, Firefox 3.6, Java 1.6, Flash 10.
  • 2010 15″ MacBook Pro running Snow Leopard, Safari (64-bit), Java 1.6, Flash 10.

Tablets are Dead (history tells us so)

Behold the cover of the latest issue of Wired:

Behold the article “How the Tablet Will Change the World“.

Compare to another Wired prediction, from 1997. The browser is dead and will be replaced by “push” technology:

This is not to say that the iPad will fail.

But if history has taught us anything, it’s this: If something is on the cover of Wired, it’s future is in serious jeopardy. Iridium. The Long Boom. Sega.

Perhaps this is what Wired is: Current trends, extrapolated to the max, made into the strongest possible predictions about the future.