added score function for ai