Skip to content

Instantly share code, notes, and snippets.

@a-ignatov-parc
Last active April 1, 2018 22:26
Show Gist options
  • Save a-ignatov-parc/69013369213cee37dcfd to your computer and use it in GitHub Desktop.
Save a-ignatov-parc/69013369213cee37dcfd to your computer and use it in GitHub Desktop.
Script for picking up drone's code in Infamous Second Son Paper Trail mission (https://infamouspapertrail.com/dupmodified_trackerdrone)
(function() {
var code = [],
length = 6,
exeptions = {},
shuffle = {},
freeze = {};
function generate() {
for (var i = 0; i < length; i++) {
var digit = Math.floor(Math.random() * length),
usedShaffledDigit = false,
skip = false;
if (freeze[i]) {
continue;
}
for (var shuffledDigit in shuffle) {
if (!shuffle[shuffledDigit][i]) {
digit = shuffledDigit;
usedShaffledDigit = true;
break;
} else if (shuffledDigit == digit) {
skip = true;
break;
}
}
if (skip) {
i--;
continue;
}
if (exeptions[i] && exeptions[i][digit]) {
if (usedShaffledDigit) {
shuffle[shuffledDigit][i] = true;
}
i--;
continue;
}
code[i] = digit;
}
}
function check() {
$.get('/pages/guessdiff', {
guess: code.join('')
}).done(function(response) {
if (response.solved) {
console.info('Succeed attempt! Code: ' + code.join('') + ' Attempts left: ' + response.remaining);
} else {
var diffArr = response.diff.split('');
console.log('Failed attempt! Code: ' + code.join('') + ' Diff: ' + response.diff + ' Attempts left: ' + response.remaining);
for (var i = 0, length = diffArr.length; i < length; i++) {
switch(diffArr[i]) {
case '0':
case '1':
if (!exeptions[i]) {
exeptions[i] = {};
}
exeptions[i][code[i]] = true;
if (diffArr[i] == 1) {
if (!shuffle[code[i]]) {
shuffle[code[i]] = {};
}
shuffle[code[i]][i] = true;
}
break;
case '2':
freeze[i] = true;
break;
}
}
if (!response.remaining) {
exeptions = {};
shuffle = {};
freeze = {};
console.log('-----');
}
tryAgain();
}
});
}
function tryAgain() {
generate();
check();
}
tryAgain();
})();
@Soulreaper6461
Copy link

could your code be altered to use charcacters instead of numbers??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment