Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IMPORTANT: give and take update credits and liabilities for E/M
- -- liabilities: what a player got from team (to unstall, or excess from others)
- -- credits: what a player excessed to team
- -- excess: metal will be distributed to others (if possible), energy will be used for overdrive
- --0) 50% shared storage - 1/2 player, 1/2 team - to decrease amount of idle metal and make players contribute team storage.
- --1) share away m as fast as possible
- if team.m then foreach:player:give(M, team.m *player.storageLevel *(player.creditsM or 0) /max(allPlayers.creditsM, 1))
- if team.m then foreach:player:give(M, team.m *player.storageLevel *(1- (player.liabilitiesM or 0) /max(allPlayers.liabilitiesM, 1) ))
- --2) If a player e-stalls, it is worse as If you don't get m from overdrive asap
- -- -- Share (from team storage), but keep track of the bank balance between the player<->team
- -- -- If a player with liabilities dies, use his team share m-gain to pay it back to the creditors first.
- -- -- E has to be payed from team.creditsE, the team's e-storage.
- -- -- Max E-share to player:
- -- -- --TODO: % dependent on team size and allPlayers.liabilitiesE compared to allPlayers.creditsE and stallingPlayer.liabilitiesE.
- -- -- If a player with liabilities starts excessing, first pay back the liabilities, then give credits for the E/M.
- --3) Use team storage to:
- -- -- Let each player have a full metal bar, even if team storage is *nearly* emty!
- -- -- -- to make this team build more nanos and storages
- -- -- -- to get more free storage for the unexpected eco boosts (reclaim)
- -- -- More team.storageE reduced team.storageE.wobble
- -- -- -- Don't overdrive if team is excessing M - to reduce running math and fill up team.storageE
- -- -- -- wobbling percentages are more inefficient than constant ones
- -- -- Use it to keep the bank balance script simple (free storage somewhere every times if not excessing M).
- --4) OnExcess:
- -- -- share to team
- -- -- if team excesses m, don't accept share and don't change any liabilities or credits
- -- -- if team excesses e, share excess for free (no liability or credit changes and don't affected by Max-E-share-to-player)
- -- -- -- to players without full storage (after processing 2) )
- --5)
- team.eForOD = team.incomeE *team.storageE.level
- -- the bank balance tells, which player owns how much:
- team.weight = 0
- for _,player in pairs(players) do
- player.weight = team.IncomeE *(player.creditE or 0) /max( team.allCredits - team.allLiabilities, 1)
- team.weight += player.weight
- end
- player.eForOD = team.eForOD *player.weight /team.weight
- -- NOTE: only players with credits can get OD ( team.IncomeE *0 /1+ == 0 )
- --6) global optimization and capping:
- globalGrid = merge( allyTeam.localGrids )
- local unused = team.eForOD
- local overdrive = 0
- repeat
- globalGrid:balance( (globalGrid.eUsage or 0) + unused )
- unused = 0
- for _,grid in pairs( allyTeam.localGrids ) do
- local cheat = grid.eUsage - grid.power
- if cheat > 0 then
- globalGrid:kick( grid ) -- updates globalGrid.eUsage
- grid:balance( grid.power )
- unused += cheat
- overdrive += grid.mMake
- end
- end
- until unused < 1
- overdrive += globalGrid.mMake
- --7) Overdrive distribution:
- for _,player in pairs( allyTeam.players )
- player:give(M, overdrive /team.eForOD *player.eForOD )
- end
- --7) Base income distribution
- -- -- Everybody get base income of his own mexes until they payed back (The -75e is penalty enough).
- -- -- all the other base belongs to the team - evenly
Advertisement
Add Comment
Please, Sign In to add comment