From 5e7e6a4798ea9a41a0763c29152a1a36cb31345f Mon Sep 17 00:00:00 2001 From: Clemens Tolboom Date: Sat, 11 Jun 2016 17:34:26 +0200 Subject: [PATCH] Add SnakeParamsBySize #290 as part of #275 + #292 --- bot.user.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/bot.user.js b/bot.user.js index 4dabbefa..ddbad537 100644 --- a/bot.user.js +++ b/bot.user.js @@ -899,6 +899,52 @@ var scheduler = window.scheduler = (function() { // TODO: checkCollision() needs refactoring; it should return but not set direction } }, + { + id: 'SnakeParamsBySize (experimental)', + active: false, + description: 'Make snake params change on snake size', + + lastLengthGroup: 0, + + getPriority: function() { + // Lower limit of snakeLength criteria used below + var lengthGroup; + var snakeLength = 0; + + snakeLength = Math.floor(15 * (fpsls[snake.sct] + snake.fam / fmlts[snake.sct] - 1) - 5) / 1; + if (snakeLength == 0) { + return 0; + } + var opt = bot.opt; + + if (snakeLength < 5000) { + lengthGroup = 0; + + opt.foodAccelSize = 20; + opt.foodRoundSize = 1; + } else if ( snakeLength < 10000) { + lengthGroup = 5000; + + opt.foodAccelSize = 40; + opt.foodRoundSize = 5; + } else { + lengthGroup = 10000; + + opt.foodAccelSize = 60; + opt.foodRoundSize = 10; + } + if (lengthGroup != this.lastLengthGroup) { + lengthGroup != this.lastLengthGroup; + // No need to update UI yet. + // userInterface.onPrefChange(); + } + + return 0; + }, + execute: function() { + // NOP + } + }, { id: 'HuntForPrey (experimental)', active: false,