I’ve introduced WAI (http://w-ai.org) 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 Socket.io, 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~
Recent Comments