HiKitty

Overdrive distribution and team storage

Jul 17th, 2012
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.58 KB | None | 0 0
  1. IMPORTANT: give and take update credits and liabilities for E/M
  2. --  liabilities:  what a player got from team (to unstall, or excess from others)
  3. --  credits:  what a player excessed to team
  4. --  excess:  metal will be distributed to others (if possible), energy will be used for overdrive
  5.  
  6. --0) 50% shared storage - 1/2 player, 1/2 team - to decrease amount of idle metal and make players contribute team storage.
  7.  
  8.  
  9.  
  10. --1) share away m as fast as possible
  11.         if team.m then foreach:player:give(M, team.m *player.storageLevel *(player.creditsM or 0) /max(allPlayers.creditsM, 1))
  12.         if team.m then foreach:player:give(M, team.m *player.storageLevel *(1- (player.liabilitiesM or 0) /max(allPlayers.liabilitiesM, 1) ))
  13.  
  14.  
  15.  
  16. --2) If a player e-stalls, it is worse as If you don't get m from overdrive asap
  17. --  --  Share (from team storage), but keep track of the bank balance between the player<->team
  18. --  --  If a player with liabilities dies, use his team share m-gain to pay it back to the creditors first.
  19. --  --  E has to be payed from team.creditsE, the team's e-storage.
  20. --  --  Max E-share to player:
  21. --  --  --TODO: % dependent on team size and allPlayers.liabilitiesE compared to allPlayers.creditsE and stallingPlayer.liabilitiesE.
  22. --  --  If a player with liabilities starts excessing, first pay back the liabilities, then give credits for the E/M.
  23.  
  24.  
  25. --3) Use team storage to:
  26. --  --  Let each player have a full metal bar, even if team storage is *nearly* emty!
  27. --  --  --  to make this team build more nanos and storages
  28. --  --  --  to get more free storage for the unexpected eco boosts (reclaim)
  29. --  --  More team.storageE reduced team.storageE.wobble
  30. --  --  --  Don't overdrive if team is excessing M - to reduce running math and fill up team.storageE
  31. --  --  --  wobbling percentages are more inefficient than constant ones
  32. --  --  Use it to keep the bank balance script simple (free storage somewhere every times if not excessing M).
  33.  
  34. --4) OnExcess:
  35. --  --  share to team
  36. --  --  if team excesses m, don't accept share and don't change any liabilities or credits
  37. --  --  if team excesses e, share excess for free (no liability or credit changes and don't affected by Max-E-share-to-player)
  38. --  --  --  to players without full storage (after processing 2) )
  39.  
  40. --5)
  41. team.eForOD = team.incomeE *team.storageE.level
  42. --  the bank balance tells, which player owns how much:
  43.         team.weight = 0
  44.     for _,player in pairs(players) do
  45.         player.weight = team.IncomeE *(player.creditE or 0) /max( team.allCredits - team.allLiabilities, 1)
  46.         team.weight += player.weight
  47.     end
  48.         player.eForOD = team.eForOD *player.weight /team.weight
  49.  
  50. --  NOTE: only players with credits can get OD ( team.IncomeE *0 /1+ == 0 )
  51.  
  52.  
  53. --6) global optimization and capping:
  54.     globalGrid = merge( allyTeam.localGrids )
  55.         local unused = team.eForOD
  56.     local overdrive = 0
  57.     repeat
  58.         globalGrid:balance( (globalGrid.eUsage or 0) + unused )
  59.         unused = 0
  60.         for _,grid in pairs( allyTeam.localGrids ) do
  61.             local cheat = grid.eUsage - grid.power
  62.             if cheat > 0 then
  63.                 globalGrid:kick( grid ) -- updates globalGrid.eUsage
  64.                 grid:balance( grid.power )
  65.                 unused += cheat
  66.                 overdrive += grid.mMake
  67.             end
  68.         end
  69.     until unused < 1
  70.     overdrive += globalGrid.mMake
  71.  
  72. --7) Overdrive distribution:
  73.     for _,player in pairs( allyTeam.players )
  74.             player:give(M, overdrive /team.eForOD *player.eForOD )
  75.     end
  76.  
  77.  
  78. --7) Base income distribution
  79. --  --  Everybody get base income of his own mexes until they payed back (The -75e is penalty enough).
  80. --  --  all the other base belongs to the team - evenly
Advertisement
Add Comment
Please, Sign In to add comment