Reset blocked regions when trying new iterations

master
sigonasr2, Sig, Sigo 2 years ago
parent c3b0f2e2dc
commit fcfd6e1e98
  1. 8
      index.js

@ -25,8 +25,8 @@ horz_dir = LEFT
vert_dir = UP vert_dir = UP
LAST_DEATH = "" LAST_DEATH = ""
BEST_LENGTH = 744 BEST_LENGTH = 744
TOTAL_ATTEMPTS = 36 TOTAL_ATTEMPTS = 37
TOTAL_LENGTH = 7848 TOTAL_LENGTH = 8066
LAST_LENGTH = 0 LAST_LENGTH = 0
BEST_SEEN = 764 BEST_SEEN = 764
BEST_SEEN_WHO = "Bot 2578" BEST_SEEN_WHO = "Bot 2578"
@ -187,7 +187,10 @@ snake.onTick = function(obj) { // When the game updates
if (--appleDepth===0) { if (--appleDepth===0) {
return true; return true;
} else { } else {
var myRegions = [...TEST_REGIONS]
while (APPLES_LIST.length>0) {
var newApple = APPLES_LIST.shift() var newApple = APPLES_LIST.shift()
TEST_REGIONS=[...myRegions]
targetApp={x:newApple[0],y:newApple[1]} targetApp={x:newApple[0],y:newApple[1]}
diff_x = x - targetApp.x diff_x = x - targetApp.x
diff_y = y - targetApp.y diff_y = y - targetApp.y
@ -214,6 +217,7 @@ snake.onTick = function(obj) { // When the game updates
} }
} }
} }
}
if (Math.abs(diff_x) > Math.abs(diff_y)) { if (Math.abs(diff_x) > Math.abs(diff_y)) {
if (diff_x > 0) { if (diff_x > 0) {
if (dir !== RIGHT && findPath(LEFT, x - 1, y,appleDepth)) { if (dir !== RIGHT && findPath(LEFT, x - 1, y,appleDepth)) {

Loading…
Cancel
Save