Retrain Sucks!!!

ElliotTheKid

Approved user
Joined
Feb 3, 2016
Messages
16
I noticed that the retrain button didn't spread troops evenly throughout the barracks, I bet everyone did. So i made a solution the devs can implement to the game to make everyone's life easier.
You can check it out here: http://ideone.com/bvap0p
I tried it out with my own troop composition and it Works, if you want to try it out with yours just post it! I recognize it sometimes misses by 15s but, cmon... you won't even notice.

I'd appreciate if any moderator could post an answer just to know my work wasn't in vain :). And if they wanna reward me with some crowns ;), go ahead! In-game name: Williemaster
 

Trotuar

Approved user
Joined
Jan 31, 2016
Messages
22
I appreciate your effort but a simple dump of the code i believe is not very usefull.
A simple pseudocode will suffice.

SortTroops(troops) in descending order of training time (i believe in the game they do the reverse or not at all)
While troops to train
Train the first troop (the longest time) in the barack with lowest time to finish.

it's not the perfect algorithm but it's optimal and guarantees better results tahn the actual one.
 

ElliotTheKid

Approved user
Joined
Feb 3, 2016
Messages
16
In the game they just drop troops on each barracks so each barracks train the same amount of troops no matter how long they take to train. My solution is just like yours but it is more optimal

It does the same simulation as yours but also uses binary search thus giving a better result. If pseudo code is required i'd gladly post it, and if anyone wants to give me their troop composition so i cant test it out and see if it works, please do.
 

Trotuar

Approved user
Joined
Jan 31, 2016
Messages
22
I do not know your solution. I was too lazy to reverse engineer. Besides you do not know if they are using c++ or plain c or a scripting language.
Try to be simple in your description and golden rule document what you are trying to do not what you are doing.
By the way binary search is just a search in an ordered tree, so i do not know where is the difference unless you are explaining the algorithm.
To be honest i see the point in solving this bug because is a simple one and can improve easily the feel of the game, I believe there are tones of REALLY annoying bugs which should be addressed imediately.
 
Top