algorithm - Creating a dynamic points averaging script -


i'm kind of person that's happy sit , use trial , error on extended period try , work out. totally stuck , thought perhaps may able point me in right direction.

i trying create script allow 1-6 players assigned number of objects each of has specific points value.

the script needs average out number of points each player awarded.

it needs able have new set of objects added distribute based on accrued number of points gained , try , distribute them keep total equal possible.

[tl;dr bit]

let's there 6 players.

in round 1 6 boxes "won": 2 big boxes @ "1000pts", 2 medium @ "500pts" , 2 small @ "250pts".

the script have award boxes 1 each player.

p1 1000 p2 1000 p3 500 p4 500 p5 250 p6 250 

let's same amount of boxes won in round two. script going have calculate gets keep scores close possible.

p1 250 p2 250 p3 500 p4 500 p5 1000 p6 1000  

would give totals of

p1 1250 ps 1250 p3 1000 p4 1000 p5 1250 p6 1250 

and on several rounds.

basically needs work out each round how award points whilst keeping total points each player close possible.

any appreciated concept of giving me headache in trying work out best approach let alone actual code itself!

i think there pretty simple solution should solve problem, in pseudo-pseudo code:

1 first assignemnent of "boxes" want, maybe random

2 order players depending of total value earned

3 assign new "boxes" lowest value highest value, starting player biggest score point.

4 goto 2

using convention, end in:

1° round ------------------- p1 1000 p2 1000 p3 500 p4 500 p5 250 p6 250

2° round ------------------- p1 1250 p2 1250 pr 1000 p4 1000 p5 1250 p6 1250

the new player order become: p1 1250 p2 1250 p5 p1250 p6 1250 p3 1000 p4 1000

and so, applying algorithm agian: p1 1500 p2 1500 p5 1750 p6 1750 p3 2000 p4 2000

3° round new player order become: p3 2000 p4 2000 p5 1750 p6 1750 p1 1500 p2 1500

and so, applying algorithm again: p3 2250 p4 2250 p5 2250 p6 2250 p1 2500 p2 2500

..it seems works.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -