azerothcore / mod-cfbg

Cross-faction Battleground for AzerothCore
MIT License
14 stars 42 forks source link

Fix(Core/CFBG): Balance algorithm #86

Closed Nefertumm closed 2 years ago

Nefertumm commented 2 years ago

Use an algorithm based on averages. Closes #78

Helias commented 2 years ago

Reading the code I don't see where you handled the case when:

who will be in the weak team? and why? the teams are balanced?

If Y will be in the strong team and X in the weak one, consider this other case:

I expect that K goes to the weak team and Z in the strong one, but consider that Z and K decrease the current avgLevel of both factions, how your algorithm will behave in this scenario?

In your algorithm you are considering the avg level of the team, but you are not predicting who is joining, you are only consider the "current player" that is joining but not the next-one that is in queue

Nefertumm commented 2 years ago

Regarding your first question: The players are the first to enter or after the hypothetical situation on the issue? In the hypothetical situation, the lvl 19 would go on the weak team and the teams would be balanced, because the algorithm tries to balance to the weaker team instead of the stronger team. On the second part, this is how the algorithm would be behave, which is wrong because I don't check for people in queue also. image In order to fix this current issue, I will need to check the queue too, you're right :)

I'll update this after monday hopefully, I have finals coming.

Nefertumm commented 2 years ago

While I was resting I was thinking about this problem, I tested the results with what you pointed and it worked. The logic can be improved so it wouldn't be so nested. Feel free to do it if you want, if not I'll do it after Monday.

Helias commented 2 years ago

I'll review the code and make some tests in these days, thanks!

Helias commented 2 years ago

Sorry, I could not test this :(. Did you test the scenario that I wrote?

Annamaria-CC commented 2 years ago

Whats the status on this?

Nefertumm commented 2 years ago

Only in-game testing needed for different scenarios like Helias pointed. I'll come back tomorrow from my holidays. I ran before a couple tests but it's a pretty big change to test alone due you'd have to test with a lot of chars simultaneously while having certain conditions.

Annamaria-CC commented 2 years ago

hmm whats the worst that can happen?

Nefertumm commented 2 years ago

Well, the worst that can happen can be unbalance :P