Web server version - * See also dave.ascape.voters2.VoterScape.java */ public class Voter

* See also dave.ascape.voters2.VoterScape.java */ public class Voter extends CellOccupant { private int supportedParty = 0; private int temp = 0; private int numParties = 0; public Voter() {} public void initialize() { super.initialize(); numParties = ((VoterScape)scape.getModel()).getNumberOfParties(); supportedParty = randomInRange(0, numParties-1); } public void scapeCreated() { getScape().addInitialRule(MOVE_RANDOM_LOCATION_RULE); getScape().addRule(ITERATE_AND_UPDATE_RULE); } public void iterate() { CellOccupant [] neighbors = getHostCell().getNeighboringOccupants(); int chosenNeighbor = randomInRange(0, neighbors.length-1); CellOccupant chosenAgent = neighbors[chosenNeighbor]; temp = ((Voter) chosenAgent).getSupportedParty(); } public void update() { supportedParty = temp; } public Color getColor() { switch(supportedParty) { case 0: return Color.blue; case 1: return Color.red; case 2: return Color.black; case 3: return Color.orange; case 4: return Color.white; default: return Color.green; } } public void setSupportedParty(int p) { supportedParty = p; } public int getSupportedParty() { return supportedParty; } public int getNumParties() { return numParties; } public void setNumParties(int n) { numParties = n; } }
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

Leave a Reply