Coder Combat is a real time one on one programming competition over the web. It attempts to simulate the emotions felt in a technical interview while also improving your programming skills. Competitors are paired up in a room and are then given an algorithm to solve. During the match each player will be able to see up to date progress on where their competitor is at at all times. Once someone solves the algorithm, the winner and loser will both be notified and a ten second countdown will prepare both competitors for the next match.
Coder Combat utilizes various technologies including
I use Angular.js on the front end with the two text editors being Directives, and a Socket.IO, Http, and CountDown service. My schema for Mongo involves a Title, Question, Parameter, and Answer. When a user clicks submit, an ng-click event is fired, I then take the code that was in his or her editor, parse it to be in the correct format, pass in the Parameter from the DB, evaluate it, then compare the result to the actual answer.
Socket.IO is the main contributor of this application. I used Sockets in order to keep a constant live stream going between both users and their editors.
The biggest challenges I faced were definitely related to Sockets and more specifically the use of rooms with sockets. For every connection that is made, I categorize that user into a specific room based on a certain algorithm. Being a live game, the user has the option to stay, disconnect, or refresh. This leads to a vast array or certain behavior that could happen in one specific room. This behavior needed to be somehow connected with other rooms and the behavior of the users in that room. For example, if there are two rooms each containing two users, the game needs to be able to detect if both rooms have someone disconnect, and then pair those remaining users.