for (int i = 2; i <= 12; i++) { oi = orderByInit(0, i, 0, order, oi);
for (com.sun.java.util.collections.Iterator i = plist.iterator(); i.hasNext();) { final Player player = (Player)i.next(); order[oi++] = player.getId();
    private void determineTurnOrder() {        // determine turn order        int[] order = new int[game.getNoOfPlayers()];        int oi = 0;        for (int i = 2; i <= 12; i++) {            oi = orderByInit(0, i, 0, order, oi);        }                // count how many entities each player controls, and how many turns we have to assign        int MAX_PLAYERS = 255; //XXX HACK HACK HACK!        int[] noe = new int[MAX_PLAYERS];        int noOfTurns = 0;        for (Enumeration e = game.getEntities(); e.hasMoreElements();) {            final Entity entity = (Entity)e.nextElement();            if (entity.isSelectable()) {                noe[entity.getOwner().getId()]++;                noOfTurns++;            }        }        // generate turn list        turns = new int[noOfTurns];        ti = 0;        while (ti < turns.length){            // get lowest number of entities, minimum 1.            int hnoe = 1;            int lnoe = Integer.MAX_VALUE;            for (int i = 0; i < MAX_PLAYERS; i++) {                    if (noe[i] > 0 && noe[i] < lnoe) {                            lnoe = noe[i];                    }                    if (noe[i] > hnoe) {                            hnoe = noe[i];                    }            }            // cycle through order list            for (int i = 0; i < order.length; i++) {                if (noe[order[i]] <= 0) {                    continue;                }                /* if you have less than twice the next lowest,                 * move 1, otherwise, move more.                 * if you have less than half the maximum,                 * move none                 */                int ntm = Math.max(1, (int)Math.floor(noe[order[i]] / lnoe));                for (int j = 0; j < ntm; j++) {                    turns[ti++] = order[i];                    noe[order[i]]--;                }            }        }        // reset turn counter        ti = 0;    }