Records now come from a file instead

master
sigonasr2, Sig, Sigo 2 years ago
parent 3702e60f95
commit 14a157b7e3
  1. 6
      data
  2. 33
      index.js
  3. 3
      run.sh

@ -0,0 +1,6 @@
886
38
8921
886
sigonasr2

@ -18,18 +18,31 @@ const newSnake = require('./wrapper.js')
const dotenv = require('dotenv');
dotenv.config();
const fs = require('fs');
let snake = newSnake(process.env.auth) // Login with the auth cookie in the secrets tab
var vals = fs.readFileSync("data", 'utf8').split("\n")
/*File Format:
`${LAST_DEATH}
${BEST_LENGTH}
${TOTAL_ATTEMPTS}
${TOTAL_LENGTH}
${BEST_SEEN}
${BEST_SEEN_WHO}
`
*/
horz_dir = LEFT
vert_dir = UP
LAST_DEATH = ""
BEST_LENGTH = 744
TOTAL_ATTEMPTS = 37
TOTAL_LENGTH = 8066
LAST_DEATH = vals[0]
BEST_LENGTH = vals[1]
TOTAL_ATTEMPTS = vals[2]
TOTAL_LENGTH = vals[3]
LAST_LENGTH = 0
BEST_SEEN = 764
BEST_SEEN_WHO = "Bot 2578"
BEST_SEEN = vals[5]
BEST_SEEN_WHO = vals[6]
TEST_REGIONS = []
APPLES_LIST=[]
targetApp={}
@ -43,6 +56,14 @@ snake.onDeath = function(reason) { // When the snake dies
LAST_DEATH = reason
TOTAL_LENGTH += LAST_LENGTH
LAST_LENGTH = 0
fs.writeFileSync("data",
`${LAST_DEATH}
${BEST_LENGTH}
${TOTAL_ATTEMPTS}
${TOTAL_LENGTH}
${BEST_SEEN}
${BEST_SEEN_WHO}
`)
snake.spawn() // Respawn
}

@ -0,0 +1,3 @@
while [ 1 ]; do
node index.js
done
Loading…
Cancel
Save