Miasma Community

Gaming Zone => [MiA] Servers => Topic started by: zeus on February 06, 2021, 19:45

Title: OPEN SOURCING THE PIGSPN & BALANCER
Post by: zeus on February 06, 2021, 19:45

There has been a discussion about fixing some problems potentially in both the balancer & pigSPN, however for that maybe open sourcing the source code could be useful

Thoughts? Github links?
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: Piglet on February 07, 2021, 13:28
The source for Freon is in the package you download. Feel free to let me know of any issues you see, and code to fix them.

Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: Piano on February 07, 2021, 23:00
What is pigSPN?
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: Piglet on February 07, 2021, 23:37
I think he means 3SPNv3225PIG.u
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: hagis on February 07, 2021, 23:38
3223 is on github https://github.com/mGm-Lizard/3SPNv3223

balancer is same really between that and mia vers
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: Piglet on February 08, 2021, 08:08
There are some changes that take into account how well each player is currently playing.


I tried removing the bug which was stopping the logic intended to prevent the same player from being swapped team several times in the same match. It worked but it meant that each swap that would have picked them picked the next best player.... which completely messed up the teams.

When player numbers are low the balancer doesn't work well.

At higher player numbers it sometimes does not appear to always get the team ppr as close as it could do. That may be because it only swaps two players
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: hagis on February 08, 2021, 18:51
the balancer does a good job on match start,. where things sometimes get confused is mid-match joins and leaves,. like you say perhaps it's to do with needing more than one swap to really sort it

I would say in general it works fine,. occasionally it doesn't but knowing the 'best' thing to do is sort of hard to do perfect programmatically

on SoL+HoC people (mostly admins) can move players between teams to help balance which is ok but I think actually the balancer generally gets close enough
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: Piglet on February 09, 2021, 10:39
The code has the option of forcing a recalculation whenever any player joins or leaves. We don't use that option as it could result in players getting moved every round.

However A CERTAIN UNNAMMED PLAYER WITH HIGH PPR regularly spectated at match start and then joined once the teams had been balanced. That meant that the game went from two balanced teams to one team having a VERY HIGH PPR PLAYER on it in addition - completely wiping out the balance in one move.

As a consequence I changed the code to do a recalculation of balance whenever a player with PPR over a certain threshold leaves or joins.

That works - however what we now see is the opposite impact when a very low PPR player joins the server. No balance action is triggered so now one team has a significant disadvantage.

We could change it it force a balance where a low PPR player joins or leaves - and only not balance when PPRs in a middle range join or leave - however it's really difficult to know how impactful that would be.

As things stand there's nearly always someone with admin rights on the server. They can trigger an attempt at re-balancing if they think it's needed. I don't know why sometimes that mid-game request seems to result in worse PPR averages than before the request. That shouldn't happen. Feel free to look at the code in the package to find out why.
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: Annihilator on February 09, 2021, 14:12
Quote from: Piglet on February 07, 2021, 13:28
The source for Freon is in the package you download. Feel free to let me know of any issues you see, and code to fix them.
True, and very much appreciated, but a GitHub repo would be highly beneficial regardless, IMHO.
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: Piglet on February 09, 2021, 14:14
I'm sure you're right. I just don't use it myself.
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: Annihilator on February 09, 2021, 14:22
Quote from: Piglet on February 09, 2021, 14:14
I'm sure you're right. I just don't use it myself.
VSCode + UScript Addon + GitHub Integration - a g00d and lightweight combination, simple to set up + use. Recommended.
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: Piglet on February 09, 2021, 15:45
Notepad++
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: Blub on February 09, 2021, 20:10
Quote from: Piglet on February 09, 2021, 10:39

However A CERTAIN UNNAMMED PLAYER WITH HIGH PPR regularly spectated at match start and then joined once the teams had been balanced. That meant that the game went from two balanced teams to one team having a VERY HIGH PPR PLAYER on it in addition - completely wiping out the balance in one move.


I WONDER WHO THAT UNNAMED PLAYER WAS  ;D
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: Stealer on February 09, 2021, 21:05
Quote from: Blub on February 09, 2021, 20:10
Quote from: Piglet on February 09, 2021, 10:39

However A CERTAIN UNNAMMED PLAYER WITH HIGH PPR regularly spectated at match start and then joined once the teams had been balanced. That meant that the game went from two balanced teams to one team having a VERY HIGH PPR PLAYER on it in addition - completely wiping out the balance in one move.


I WONDER WHO THAT UNNAMED PLAYER WAS  ;D

Thought it might be me, till I read the high PPR bit  :'(
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: Veica on February 10, 2021, 23:35
Quote from: Piglet on February 09, 2021, 10:39
That works - however what we now see is the opposite impact when a very low PPR player joins the server. No balance action is triggered so now one team has a significant disadvantage.

Hey c'mon man, you can use my name y'know!
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: nyrde on March 07, 2021, 14:50
Hello! One source of problems in the balancer could be that some people play it also with less players. When you have 20+ players you get shit more points than when you play with 8. So the appr is affected by the player number. Is it possible to do so that that player number affects the appr (only appr not game ppr) that in balancer the 16 players equals factor 1, 8 players is then 2, 32 players 0.5? so the formula is appr=ppr x 16/num_of_players...
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: nyrde on March 07, 2021, 14:52
Maybe we should call it something else than appr... weighted appr = wappr :D
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: nyrde on March 07, 2021, 15:05
Hmm... now that i think about it... it might not work very well... no it shouldnt be the number of players that it should be compared to... it should be the score. So wappr = average_total_score (16)/average_total_score_(number_of_players) x ppr...
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: Piglet on March 07, 2021, 15:21
It currently doesn't use any stats from games where there are fewer than 6 players.

It's really difficult to get it "right". If you think about it's actually better that it doesn't result in exactly even teams. Every match would be more of a stale-mate. 

As I said, all the code is there in the package. If you want to extract it and come up with good changes to the balancing code please do. I'll use anything that will make the game better.

UCC BatchExport 3SPNv3225PIG class uc ..\3SPNv3225PIG\Classes
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: nyrde on March 07, 2021, 17:57
Yeah... it was just a thought... I totally agree. And you know i don't think there is any way to make it perfect. And sometimes it's fun to dominate the other team. And the balancer as it is currently is working quite well... I think most matches end 7-10, 8-10 or 9-10... total domination is quite rare i think.
Title: Re: OPEN SOURCING THE PIGSPN & BALANCER
Post by: hagis on March 07, 2021, 18:41
if the pprs are within 1 whole ppr it's close enough generally,. unless one team is sucking or whatever and it gets to 0-6 or more which is v rare

the balancer is definitely not perfect and it could be different but at match start it does a decent job (it's the multiple joins and leaves in the middle of a match can sometimes mess things up)