meepen / salien-bot

Steam Summer Sale 2018 "Salien" minigame bot - runs in console or browser
MIT License
417 stars 103 forks source link

Stuck on planets with no high threat tiles? #31

Closed EinarGissurar closed 6 years ago

EinarGissurar commented 6 years ago

There's a tiny problem with the current build that's only an issue when you're focusing on leveling up.

Since the code focuses on selecting planets with the highest progress, you end up on worlds where all the high threat (and eventually the middle threat) tiles have been used up, while planets that still have those tiles available are still available.

I messed around with the GetBestPlanet function, so that it selected the planet with the lowest progress. Here's what I did: ` const GetBestPlanet = function GetBestPlanet() { let bestPlanet; let worstPlanet; let maxProgress = 0; let worstProgress = Number.MAX_VALUE;

if (!GAME.m_State.m_mapPlanets)
    return;

for (let planetKV of GAME.m_State.m_mapPlanets) {
    let planet = planetKV[1];
    if(planet.state.active && !planet.state.captured && planet.state.capture_progress > maxProgress) {
        maxProgress = planet.state.capture_progress;
        bestPlanet = planet;
    }
    if(planet.state.capture_progress < worstProgress) {
        worstProgress = planet.state.capture_progress;
        worstPlanet = planet;
    }
}

if (worstPlanet) {
    console.log(`selecting planet ${worstPlanet.state.name} with progress: ${worstPlanet.state.capture_progress}`);
    return worstPlanet.id;
}
/*if(bestPlanet) {
    console.log(`selecting planet ${bestPlanet.state.name} with progress: ${bestPlanet.state.capture_progress}`);
    return bestPlanet.id;
}*/

} `

This works for me as the bot is now selecting the least progressed planet.

I'm wondering now if this should be added, where the bot priorities low progress planets, while player is still leveling up.

meepen commented 6 years ago

GetBestPlanet only runs once so it's not exactly the best place to choose this, but if you want to try and find other planets before selecting a zone you can try that as well, but you would need a state to track them.