It would be great if you could view the source for the existing functions such as getNearest(), It would save much time reimplementing modified versions of them. For example if I wanted to make a getNearestArcher() method to enable my archers to focus the enemy nearest enemy archer at certain points, I'd take the existing function and just add an additional type check rather than writing my own function from scratch.
These types of games are really interesting and having this one available in the browser gives it a significant advantage over others such as http://aisandbox.com/ which when tried was a little too complicated to setup for casual usage.