moved AI routine into NPC class