added new feature for pattern-based play.