get number of creeps screeps

JavaScript
var count = Object.keys(Game.creeps).reduce(function(p, c, i, a) {return p + (Game.creeps[c].memory.role == "aRole" ? 1 : 0)}, 0)

Source

Also in JavaScript: