how was chess invented