adds searching function for judging win or lose