Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var S = generateS(),
- answer = S[Math.floor(Math.random()*S.length)],
- guess = [1,1,2,2];
- console.log('Hidden code: ' + answer);
- while (true) {
- var response = compareCodes(guess, answer);
- console.log(guess, response);
- if (response.black === holes) {
- console.log('You have won the game!');
- break;
- }
- S = removeCodes(S, impossibleCodes(S, guess, response));
- guess = minimax(S, allCodes);
- }
- // sample output
- Hidden code: 1,6,4,5
- [ 1, 1, 2, 2 ] { black: 1, white: 0 }
- [ 1, 3, 4, 4 ] { black: 2, white: 0 }
- [ 1, 4, 1, 5 ] { black: 2, white: 1 }
- [ 1, 1, 1, 6 ] { black: 1, white: 1 }
- [ 1, 6, 4, 5 ] { black: 4, white: 0 }
- You have won the game!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement