Inspiration
At its very core, Agario is a game of patience. You either go in for the risky kill, or play it safe and stay small. In many ways, it is a representation of human nature.
What it does
Intelligario is an Agario clone that uses computer algorithms to figure out where to go and what to kill. More interestingly, it allows human input through the live adjustment of an "aggression" factor, telling the AI if it should play it safe or blaze a path of glory.
How we built it
Both the front end and back end are built off of JavaScript. Communication is accomplished between server and client through Socket.IO. Graphics are done through Fabric.JS (and ultimately HTML5 Canvas).
Challenges we ran into
We used Dijkstra's algorithm to search the game board and determine the destination of each and every bubble. Ignoring the fact that JavaScript (a weakly typed language) is terrible for this, performance was less than satisfactory. Despite JavaScript's claim to fame as a non IO-Blocking event model, it is nonetheless single-threaded in 99% of cases and thus lags in the event of a long running script. As a result, we used a relatively new technology that none of our team members had experience with - JavaScript Workers. The JavaScript implementation of multi-threaded processing, JS Workers allowed us to run Dijkstra in the background while the animation proceeded smoothly in the foreground. Furthermore, HTML5 Canvas was a relatively new topic to all team members.
Accomplishments that we're proud of
We implemented Dijkstra's algorithm in Java-freaking-Script. To us, that was quite an accomplishment in and of itself. JavaScript's extensible and flexible object model, while great for the modern challenges of modern web development, is terrible for performance and stability focused game applications.
Furthermore, there was a vast amount of math involved in the project. Apart from the constant distance calculations, our code both effortlessly projected the 250x250 grid onto a larger monitor and simplified target waypoints. The latter is particularly interesting - Dijkstra's algorithm, when approximated, generates multiple waypoints in a general direction. This presented two major problems: A, it resulted in increased computational workload, and, B, it caused our blob to double back. Why? Since the dijkstra was run asynchronously, the outputted results were actually based on where the blob was a few moments ago. This was obviously not what we wanted, so we devised a brilliant but simple solution - compare the slopes between adjacent waypoints and remove the ones that lie on a similar line.
We are also proud that we slept a lot!
What we learned
JavaScript isn't as terrible as we thought for algorithmic and performance applications. Agario, while a simple game on the surface, is actually incredibly difficult to implement in a short amount of time. We also learned that Socket.IO is finnicky, and that geometry problems are a massive headache :P
What's next for Intelligario
Maybe we'll become viral, maybe we won't. Either way, this was a fun experience!
Log in or sign up for Devpost to join the conversation.