From 950758dfc0490b3f7e1e9162e4259438de2c7b04 Mon Sep 17 00:00:00 2001 From: 5h31k Date: Fri, 27 May 2022 14:33:24 +0200 Subject: [PATCH] Issue #113 - Add A* to rush Dungeon We don't take chests or fight for nothing. The general gain is better on the hardest dungeons (more time to kill enemies needed than first dungeon where the player can OS all enemies) --- enhancedautoclicker.js | 113 +++++++++++++++++++++++++++-------------- 1 file changed, 75 insertions(+), 38 deletions(-) diff --git a/enhancedautoclicker.js b/enhancedautoclicker.js index 89aa8a1c..609f2beb 100644 --- a/enhancedautoclicker.js +++ b/enhancedautoclicker.js @@ -378,7 +378,7 @@ function autoDungeon() { if (App.game.gameState === GameConstants.GameState.dungeon) { var dungeonBoard = DungeonRunner.map.board(); //The boss can be found at any time - if (foundBoss == false){ + if (foundBoss == false) { bossCoords = scan(dungeonBoard) } //Wander around until we can move to the boss tile @@ -410,46 +410,83 @@ function scan(dungeonBoard){ } } -function wander(dungeonBoard, bossCoords){ - var moves = [] - //Attempt to move to the boss if the coordinates are within movable range - DungeonRunner.map.moveToCoordinates(bossCoords[1], bossCoords[0]) - if (DungeonRunner.map.currentTile().type() == GameConstants.DungeonTile.boss){ - foundBoss = false - bossCoords.length = 0 - DungeonRunner.startBossFight() +function calculBestPath(dungeonBoard) { + // javascript-astar 0.4.1 + // http://github.com/bgrins/javascript-astar + // Freely distributable under the MIT License. + // Implements the astar search algorithm in javascript using a Binary Heap. + // Includes Binary Heap (with modifications) from Marijn Haverbeke. + // http://eloquentjavascript.net/appendix2.html + !function(t){if("object"==typeof module&&"object"==typeof module.exports)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();window.astar=n.astar,window.Graph=n.Graph}}(function(){function t(t){for(var n=t,i=[];n.parent;)i.unshift(n),n=n.parent;return i}var n={search:function(i,e,s,r){i.cleanDirty();var h=(r=r||{}).heuristic||n.heuristics.manhattan,c=r.closest||!1,u=new o(function(t){return t.f}),a=e;for(e.h=h(e,s),i.markDirty(e),u.push(e);u.size()>0;){var f=u.pop();if(f===s)return t(f);f.closed=!0;for(var p=i.neighbors(f),l=0,d=p.length;l0&&(this.content[0]=n,this.bubbleUp(0)),t},remove:function(t){var n=this.content.indexOf(t),i=this.content.pop();n!==this.content.length-1&&(this.content[n]=i,this.scoreFunction(i)0;){var i=(t+1>>1)-1,e=this.content[i];if(!(this.scoreFunction(n)