The script uses the Weighted Inclusive Gregory Method for reallocating surplus votes. The quota for election is (number of votes)/(number of seats + 1) rounded up to two decimal places. At each stage of the count, if more than one candidate has surplus votes, the largest surplus will be transfered first. All ties are broken randomly.