Fix paper-io bot
* Reset the movement array as soon as it hits it's land
This commit is contained in:
parent
2bea2e8b7a
commit
a1887b2b7d
@ -16,8 +16,6 @@ var GRID_SIZE = core.GRID_SIZE;
|
|||||||
var CELL_WIDTH = core.CELL_WIDTH;
|
var CELL_WIDTH = core.CELL_WIDTH;
|
||||||
var MOVES = [[-1, 0], [0, 1], [1, 0], [0, -1]]
|
var MOVES = [[-1, 0], [0, 1], [1, 0], [0, -1]]
|
||||||
|
|
||||||
var THRESHOLD = 10;
|
|
||||||
|
|
||||||
var startFrame = -1;
|
var startFrame = -1;
|
||||||
var endFrame = -1;
|
var endFrame = -1;
|
||||||
var grid, others, user, playerPortion = {}, claim = [];
|
var grid, others, user, playerPortion = {}, claim = [];
|
||||||
@ -53,16 +51,16 @@ function update(frame) {
|
|||||||
}
|
}
|
||||||
endFrame = frame;
|
endFrame = frame;
|
||||||
|
|
||||||
if (frame % 6 == 1) {
|
if (frame % 6 == (startFrame + 1) % 6) {
|
||||||
grid = client.grid;
|
grid = client.grid;
|
||||||
others = client.getOthers();
|
others = client.getOthers();
|
||||||
|
|
||||||
//Note: the code below isn't really my own code. This code is in fact the
|
//Note: the code below isn't really my own code. This code is in fact the
|
||||||
//approximate algorithm used by the paper.io game. It has been modified from
|
//approximate algorithm used by the paper.io game. It has been modified from
|
||||||
//the original code (i.e. deobfuscating) and made more efficient in some
|
//the original code (i.e. deobfuscating) and made more efficient in some
|
||||||
//areas, otherwise, the original logic is about the same.
|
//areas (and some tweaks), otherwise, the original logic is about the same.
|
||||||
var row = user.row, col = user.col, dir = user.currentHeading;
|
var row = user.row, col = user.col, dir = user.currentHeading;
|
||||||
var thres = (1 + 2 * Math.random()) * .01 * GRID_SIZE * GRID_SIZE;
|
var thres = (.05 + .1 * Math.random()) * GRID_SIZE * GRID_SIZE;
|
||||||
|
|
||||||
if (row < 0 || col < 0 || row >= GRID_SIZE || col >= GRID_SIZE) {
|
if (row < 0 || col < 0 || row >= GRID_SIZE || col >= GRID_SIZE) {
|
||||||
return;
|
return;
|
||||||
@ -70,6 +68,7 @@ function update(frame) {
|
|||||||
|
|
||||||
if (grid.get(row, col) === user) {
|
if (grid.get(row, col) === user) {
|
||||||
//When we are inside our territory
|
//When we are inside our territory
|
||||||
|
claim = [];
|
||||||
weights = [25, 25, 25, 25];
|
weights = [25, 25, 25, 25];
|
||||||
weights[dir] = 100;
|
weights[dir] = 100;
|
||||||
weights[mod(dir + 2)] = -9999;
|
weights[mod(dir + 2)] = -9999;
|
||||||
@ -143,6 +142,7 @@ function update(frame) {
|
|||||||
dir = claim.shift();
|
dir = claim.shift();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
claim = [];
|
||||||
//We are playing a little bit more cautious when we are outside and have a
|
//We are playing a little bit more cautious when we are outside and have a
|
||||||
//lot of land
|
//lot of land
|
||||||
weights = [5, 5, 5, 5];
|
weights = [5, 5, 5, 5];
|
||||||
|
Loading…
Reference in New Issue
Block a user