Advertisement
Guest User

Untitled

a guest
May 27th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var S = generateS(),
  2.     answer = S[Math.floor(Math.random()*S.length)],
  3.     guess = [1,1,2,2];
  4.  
  5. console.log('Hidden code: ' + answer);
  6.  
  7. while (true) {
  8.     var response = compareCodes(guess, answer);
  9.    
  10.     console.log(guess, response);
  11.    
  12.     if (response.black === holes) {
  13.         console.log('You have won the game!');
  14.         break;
  15.     }
  16.    
  17.     S = removeCodes(S, impossibleCodes(S, guess, response));
  18.     guess = minimax(S, allCodes);
  19. }
  20.  
  21. // sample output
  22. Hidden code: 1,6,4,5
  23. [ 1, 1, 2, 2 ] { black: 1, white: 0 }
  24. [ 1, 3, 4, 4 ] { black: 2, white: 0 }
  25. [ 1, 4, 1, 5 ] { black: 2, white: 1 }
  26. [ 1, 1, 1, 6 ] { black: 1, white: 1 }
  27. [ 1, 6, 4, 5 ] { black: 4, white: 0 }
  28. You have won the game!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement