state pattern learning