Added type protection to simAgent, agents(), etc.

agent<A> now enforces that A is an Agent subclass, and likewise for
agents<A> and countAgents<A>, plus the equivalent for Goods, Markets,
and Others.