1

Here's my aim - to take the ASCII roguelike Angband and create an online console where users can play the game server-side. From my superficial viewpoint this seems like it should be doable - as there are REPL consoles that can be displayed online for a multitude of languages, so interpreting the language shouldn't be a problem, right?

Ideally, it would be as simple as running the game on the server and displaying the output to the client-side browser. Is this at all possible?

Intenex
  • 1,907
  • 3
  • 20
  • 33
  • 3
    Start writing code. And yes, it's entirely doable. I recommend just using this: http://bellard.org/jslinux/ (it saves all that silly "rewriting" stuff, although I'm not entirely sure on the practicallity ;-) –  May 25 '12 at 00:38
  • 3
    [Is there an interpreter for C?](http://stackoverflow.com/questions/584714/is-there-an-interpreter-for-c) – Blastfurnace May 25 '12 at 00:40
  • 3
    It might be worth it to look into Google Native Client – Mike Kwan May 25 '12 at 00:42
  • @MikeKwan Link please! (Let's keep up these obscure yet nifty approaches :-) –  May 25 '12 at 00:44
  • Oh right. http://code.google.com/p/nativeclient/ – Mike Kwan May 25 '12 at 10:22

2 Answers2

5

Probably the simplest -- and coolest -- solution to this sort of thing is Emscripten. It's literally a LLVM -> JavaScript translator. You can generate LLVM bytecode using a C compiler (using llvm-gcc or Clang), so this is a reasonably short path from C to JavaScript.

You will, of course, still need some JavaScript "glue" to create the HTML UI. Emscripten isn't quite that magical. :)

1

As a member of the Angband devteam, I would certainly be interested in following your progress. A couple different approaches you may want to investigate include

  • If you want to invest less work and are willing to put up with some security issues (or do the work to lock it down properly), Shell in a Box is an AJAX terminal emulator you could easily use to connect a browser to a shell. There are others.
  • konijn started work on a Javascript interface for his Angband variant Hellband. I don't believe it's complete or stable, but it could be useful as a model.
justarobert
  • 241
  • 1
  • 2