12-22-2014, 05:01 PM
(12-22-2014, 05:40 AM)Antidote Wrote: Make sense to me now since I tend to always use up all troops in battle I might overlook that. By detecting gold & elixir change, do you detect change in that screen region (pixelchecksum) or actually read gold & elixir to compare? How would it handle when you get 3 stars or battle end early (out of troops)?
Also I believe config file can be done in Autoit as well, requires very organized and flexible coding though. From what I see, your bot seems way ahead :D
This is the pseudo algorithm:
Quote:function waitForEndOfBattle() {
int delayInSeconds = config.getEndOfBattleDelay();
int resources = 0;
while(delayInSeconds > 0) {
int newResources = opponent.getGold() + opponent.getElixir();
if(newResources == resources) {
delayInSeconds--;
}
resources = newResources;
sleep(one second);
}
log.info("No resources change for "+count+" sec, Stopping battle");
surrender();
endBattle();
return image.wait(RETURN_HOME, 3000);
}
In the case the battle ends with 3 stars, the surrender() and endOfBattle() function do nothing because they did not detect either the surrender or the end of battle buttons.