Monthly Archives: December 2012

The architecture of – Introduction

I’ve introduced WAI ( in my previous post. You can find the source code at github. To help someone who may be interested in contribution to this project, I’ll write a series of posts about the architecture of the system.

There are four main components of WAI:

1) Sandbox and other stuff which tightly depends on specified OS

This component is similar with the judge service of traditional ACM-ICPC online judge systems. The main function is providing permission control, timing and the communication between user’s AI process and outside world.

Because it is full of system calls (ptrace() and pipe(), for example), this part is implemented in C++.

2) Web server (based on Node.js)

I have to admit that Node.js may not be the best choice for this project, for WAI is CPU-tensive, which usually can’t take advantage of Node’s asynchronous behavior. In fact, I wrote the web server in Python in the first place, but later I found I need a bi-way real-time communication between client-side and server-side (for the HvC feature), and the only simple method I can find is, which is based on Node. Another reason of choosing Node is, I want to learn it, and it sounds cool :)

There is also another component in Node – the scheduling module, to decide which two AI should fight next.

3) Client side code (JavaScript / HTML5)

The UI is based on Twitter’s Bootstrap. Obviously, I’m not an expert at UI design, and the current UI is almost the best I can make. I’ll be very glad if you can help improving it.

And the most complicated code in this part is the logic of interaction with users for each specific game. For example, drawing the chess board in canvas (yes, HTML5), responding user’s mouse click, showing computer AI’s moving, and so forth. Some games are more complicated to show (for example, TankCraft) than others.

4) Judges for each game

Once a new game is added, the corresponding judge should be provided, which will receive the AI’s moving and determine who is the winner. There is a simple protocol based on std i/o, and the judges are designed to be interchangeable easily.

I’ll describe the details of each component in the future posts. Stay tuned~

Some updates and my first English post

I’ve been in US for about two months, and here comes a serious problem: My English really SUCKS.

I’ve never come to US before, even never think about studying or working outside China before I got Facebook’s offer. So I have little experience in English. We do study English in China, but just for standardized test, which contains mostly multiple choice problems. So, the situation is, I can read (with the help of dictionary) and write (in spite of tons of spelling/grammar error), but I have much difficulty in listening and speaking.

For improving my written English, I’ll post blogs in English in future. The English posts will basically about technique, because I think it’s even more difficult to express the `kuso’ of daily-life in English instead of Chinese.

Feel free to correct me if you find any typo or other errors in my article. I’ll appreciate your help.Thanks. :)