code to find winning move of player